Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dismiss on backtesting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Dismiss on backtesting

    Hello

    When I try to backtest a simple strategy on NQ 09-10, 1 min bars I get som places where the entry an exit price is above or below the actual bar itself. It also look as the rules in my strategy is not followed in this situations.
    In the attached image, you see a short entry at 1.45 PM whith a entry atn 1816,50 and exit at 1814,-. The bar itself have a High on 1812,75 and low on 1810,50.
    I have tried to reload all data for the NQ 09-10, but the same thing is still happening. This happends several times in the backetest.

    The code for the signal is:

    SMA sma5 = SMA(BarsArray[
    1],50);

    if (Falling (sma5) &&
    High[
    0] > Bollinger(2, 14).Upper[0]
    )
    EnterShort();

    The "BarsArray[1]" is a 5 min, and profit target is set to 10 ticks

    I have a NT 7.0.0.18
    Hope you can help me.

    best regards
    Stiblo



    Attached Files

    #2
    Stiblo,

    Have you filtered your logic to be within the correct BarsInProgress context?
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      This is the code:
      publicclass Bollinger : Strategy
      {
      privateint target1 = 10;
      privateint stop = 9;
      protectedoverridevoid Initialize()
      {
      Add(PeriodType.Minute, 5);
      Add (Bollinger(2, 14));
      SetStopLoss("",CalculationMode.Ticks, stop, false);
      SetProfitTarget(CalculationMode.Ticks, target1);
      CalculateOnBarClose = true;
      }
      protectedoverridevoid OnBarUpdate()
      {
      if (ToTime(Time[0]) >= ToTime(13, 0, 0)&&
      ToTime(Time[0]) <= ToTime(16, 0, 0))
      Variable0 = 1;
      else
      Variable0 = 0;
      EntryHandling = EntryHandling.UniqueEntries;
      SMA sma5 = SMA(BarsArray[1],50);
      if (Position.MarketPosition != MarketPosition.Flat) return;
      if (Variable0 != 1) return;

      if (Rising (sma5) &&
      Low[0] < Bollinger(2, 14).Lower[0]
      )
      EnterLong();

      if (Falling (sma5) &&
      High[0] > Bollinger(2, 14).Upper[0]
      )
      EnterShort();
      }

      Comment


        #4
        You will most definitely want to filter your OnBarUpdate() with BarsInProgress.

        Code:
        if (BarsInProgress == 0)
        {
             // logic;
        }
        You can find a discussion of this here: http://www.ninjatrader-support.com/H...ameInstruments
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thank you. I try that

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by AdamDJ8, 05-07-2024, 09:18 PM
          2 responses
          15 views
          0 likes
          Last Post -=Edge=-  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          46 responses
          4,099 views
          3 likes
          Last Post tradgrad  
          Started by usasugardefender, Today, 01:42 AM
          0 responses
          1 view
          0 likes
          Last Post usasugardefender  
          Started by haas88, 03-21-2024, 02:22 AM
          15 responses
          182 views
          0 likes
          Last Post haas88
          by haas88
           
          Started by brianfnoel, Today, 01:24 AM
          0 responses
          6 views
          0 likes
          Last Post brianfnoel  
          Working...
          X