Reply

Order valid bars for Tradestation or Multicharts

2 replies

eastpeace

Customer, bbp_participant, community, sq-ultimate, 305 replies.

Visit profile

3 years ago #266949

Hello,

I have asked questions about Bars valid of stop entry order setting for TS/MC before. I think it is redundant for TS/MC, because it has not been used after the declaration.

https://strategyquant.com/forum/topic/about-enter-at-stop-setting/

But now it is necessary for SQ development team to re-analyze and deal with this problem. I got some documents from the Tradestation forum recently . After testing and comparing, I think the valid bars is necessary. And it can be implemented in several ways. Code snippet for reference as below.  All have been tested  in MC.

# Method 1, BarNumber

fastma = Average(c,9);
slowma = Average(c,18);

if fastma crosses over slowma and BarNumber>1 then begin
lentryprice = Highest(h,8)[1]*1.03;
lcount = BarNumber; // mark the bar index when buy setup is true
end;

if marketposition<> 1 and BarNumber< lcount + 12 then //keep the buy order active for 12 bars after the buysetup buy(“cross buy”) 1 contract next bar at lentryprice stop; # method 2 , use MRO function histogram = XAverage(c,closelen) – XAverage(open,openlen); //setup for entry orders and initial stop for first entry bar if histogram crosses over 0 then begin buyprice = high + Average(truerange,10)*.5; longexitprice = Low[1]-Average(truerange,10)[1]/2; end; if MRO(histogram crosses over 0,10,1)>-1 and histogram>0 then // keep order active for 10 bars
buy(“LE”) next bar at buyprice stop;

// MRO return value > -1 means that in the recent 10 bars, histogram cross above 0,that is buy setup condition.

#method 3, like method 1, But it is more readable by setting the variables.

//accumulate to count the bars after setup
countL = countl + 1;
countS = countS + 1;
if price crosses above boll_up then begin
setbar = high;
countL = 1; //reset the bars count after setup
end;

if price > kcu and countL<=5 then //keeps order valid for 5 bars
buy next bar at setbar + (chanrng*chanpcnt) stop;

 

 

 

I hope the development team can improve theTS and MC backtest engine and support bars valid setting truly.

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

3 years ago #266970

Hello,

a pending order is valid for a single bar in TradeStation engine. It means it has to be placed again on each new bar while an entry is still valid (true). Hence the orderBarsValid is not useful for TS/MC engine

https://www.multicharts.com/discussion/viewtopic.php?t=51384

0

Rick

Subscriber, bbp_participant, sq-ultimate, 1 replies.

Visit profile

5 months ago #283854

Hello,

 

As mentioned in the forum of Multicharts, the order keeps being generated for every bar as long as the condition is valid. But what if the condition becomes invalid after one bar. In the pseudo-code, the order is still there for x bars and can be executed if the price reaches it. In multicharts, it disappears. This causes discrepancies between the implementations.

0

Viewing 2 replies - 1 through 2 (of 2 total)