Not logged in
Viewing 2 posts - 1 through 2 (of 2 total)

Forums>StrategyQuant>General Discussion>Order valid bars for Tradestation or Multicharts

  • #266949 |
    Customer
    261 Posts

    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.

    #266970
    tomas262
    Administrator
    1535 Posts

    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

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

You must be logged in to reply to this topic.