Login Page - Create Account

Support Board


Date/Time: Fri, 29 Mar 2024 11:11:24 +0000



[Programming Help] - ACSIL Buy/Sell Exit Executes Perfectly in Replay but Not Live

View Count: 623

[2020-02-09 23:49:18]
User650124 - Posts: 6
Hi, I've been struggling on troubleshooting what's going with my strategy lately and so I'm turning to the support board for some help and ideas. I use a crossover condition to exit trades in my strategy and when I replay backtest it works perfectly, but when I'm live trading for some reason the trades are exiting randomly when they're not supposed to. The trade log is indicating that the exits are being triggered by my strategy so I've ruled out anything with the sierrachart trade management. My entry conditions have been working perfectly, just a discrepancy in the exits. I've let the strategy trade live then backtested over the same data later and seen the same results, where the trade exits are seemingly being triggered randomly in live but in replay they've been triggered perfectly. An example of my exit condition code is below, If anyone has any ideas please let me know. Thanks!


      // Buy Exit Condition
    else if (sc.CrossOver(sc.BaseData[SC_HIGH], sc.Subgraph[12]) == CROSS_FROM_BOTTOM &&
    AbsQuantity > 0)
    {
      int Result = (int)sc.BuyExit(NewOrder);
      if (Result > 0) //If there has been a successful order exit, then draw an arrow at the high of the bar.
      {
        BuyExitSubgraph[sc.Index] = sc.High[sc.Index];

      }
    }

[2020-02-10 21:23:53]
bradh - Posts: 846
Depending on how you are backtesting, you could be seeing unrealistic results. Also, you may want to change your if statement to check for the bar being closed:


else if (sc.CrossOver(sc.BaseData[SC_HIGH], sc.Subgraph[12]) == CROSS_FROM_BOTTOM &&
AbsQuantity > 0 && sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED)


The most accurate backtest is to do Replay with Calculate at Every tick, even though it uses more CPU, it is the closest to how the system will behave with live data.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account