Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CrossBelow not working on live data

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

    CrossBelow not working on live data

    Hello,
    I am seeing a weird problem where my Strategy seems to work fine on past data but when the live ticks come in it suddenly doesn't work. I know I must be doing something fundmentally wrong here...

    protected override void OnBarUpdate()
    {
    if (FirstTickOfBar && Position.MarketPosition == MarketPosition.Flat)
    {
    if (CrossBelow(RSI(rSIBarLen, rSIMALen), RSI(rSIBarLen, rSIMALen).Avg, 1))
    {
    Print(Instrument.FullName + " Sell Short!");
    DrawArrowDown(Guid.NewGuid().ToString(), true, 0, High[0] + 2*TickSize, Color.Red );
    }
    }
    }

    When I first enable this on a live 5 minute chart, all the crossvers "happen". But as the real time ticks come in, the visual chart updates but the crossover never seems to happen as I never see the print or the DrawArrow. However if I disable and re-enable, then the crossovers that didn't occur when live, do get generated once they are history.

    Any idea what simple concept I am missin here? I have included Prints as well and the values are fine preceding the CrossBelow() call.

    Thanks in advance for any help!

    #2
    BigRunningBack, first of all welcome to our forums here - which CalculateOnBarClose setting do you use with this script? False?

    Comment


      #3
      Hi Bertrand and thank you for the welcome!

      I have

      CalculateOnBarClose =
      false;

      So on the first tick of the new bar if I look back one, it should be the last completed bar.

      Comment


        #4
        BigRunningBack, for realtime runs with COBC = false I suggest running with the lookback increased to 2 to makeup for calling on the currently developing bar. Thus conditions you had for COBC true need to reference one bar further back to express the same.

        Comment


          #5
          Thank you Bertrand, what you said made sense when I thought about it and sure enough it is working now.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          59 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          143 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          161 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          97 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          276 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X