Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using, OnBarClose Indicator in OnEachTick Strategy.

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

    Using, OnBarClose Indicator in OnEachTick Strategy.

    Hello

    I have a vWAP indicator, "The ones from userAppShare".
    When added to a chart and run OnBarUpdate they work as intended and shows whats needed.

    I have a strategy i want to run OnEachTick for live trade management.

    on BarsInProgress == 0 && IsFirstTickOfBar
    I have a strategy that uses alot of stuff and vWAP and this works fine.

    I am adding the indicator like this.



    private OT_vWAP SetupvWAPInd;

    SetupvWAPResetPeriod = NinjaTrader.NinjaScript.Indicators.OTIndicators.OT _vWAP.Periods.Daily;

    else if (State == State.DataLoaded)
    {

    SetupvWAPInd = OT_vWAP(Close, SetupvWAPResetPeriod);
    SetupvWAPInd.Plots[0].Brush = Brushes.Black;
    AddChartIndicator(SetupvWAPInd);

    }​


    when i add the indicator to my chat it draws vWAP at one place and when i add the strategy it draws the vwap excatley above, 100% identical place.


    but when it then runs live it does not draw the same place and it seems to be caused but the strategy running OnEachTick.

    How do i some how acomodate for this ?

    you see the yellow line is the indicator added to the chart and the black is the strategy plotting the same line.

    Icould easily re-program the indicator but i was wondering if there were some easier and more generic way to acomodate for this.

    Click image for larger version

Name:	billede.png
Views:	194
Size:	27.5 KB
ID:	1323816
    Last edited by donto; 11-06-2024, 04:49 AM.
    Donto
    NinjaTrader Ecosystem Vendor - otrading.dk

    #2
    Hello donto,

    Thank you for your post.

    Hosted indicators will inherit the hosting strategy's Calculate setting. So if your strategy is running OnEachTick, any hosted indicators will also use OnEachTick.

    If you only want the indicator's value to update once per bar, a workaround is to only call the indicator when IsFirstTickOfBar is true.

    Comment


      #3
      Hello Gaby,

      Thanks you for your assistance.

      I am aware if the "if (IsFirstTickOfBar)" how ever that requires the bar index to be changed in the indicator.
      is there no hack to use on the strategy ?

      I have already re-written my indicator to support OnEachTick with a manual boolean.
      Is there any way to determine from the indicator if the strategy and indicator is at the moment running OnBarClose vs OnEachTick ?

      like
      if (Calculate == calculate.OnEachTick)

      And then i can set my bar index variable from that.


      When using indeicators from strategies etc.. is it always the indicators, OnBarUpdate that runs first or last or what is the sequence logic here ?
      Donto
      NinjaTrader Ecosystem Vendor - otrading.dk

      Comment


        #4
        Hello donto,

        I'm not sure what you mean by "isFirstTickOfBar" required the bar index to be changed in the indicator? This isn't true - using IsFirstTickOfBar doesn't require you to change anything within the indicator's code.

        You can check the Calculate setting that way, but keep in mind that this won't change that the indicator is always going to inherit the hosting strategy's Calculate setting.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        52 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        43 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        47 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X