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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          649 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          576 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X