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:	56
Size:	27.5 KB
ID:	1323816
    Last edited by donto; 11-06-2024, 04:49 AM.

    #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.

    Gaby V.NinjaTrader Customer Service

    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 ?

      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.
        Gaby V.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by giogio1, Yesterday, 03:18 AM
        4 responses
        17 views
        0 likes
        Last Post giogio1
        by giogio1
         
        Started by jkop123, Today, 07:05 PM
        0 responses
        2 views
        0 likes
        Last Post jkop123
        by jkop123
         
        Started by jkop123, Today, 07:04 PM
        0 responses
        2 views
        0 likes
        Last Post jkop123
        by jkop123
         
        Started by DayTradingDEMON, 09-08-2024, 11:25 PM
        12 responses
        359 views
        0 likes
        Last Post defa0009  
        Started by thedude, 11-14-2021, 08:44 AM
        5 responses
        532 views
        0 likes
        Last Post jmschmidt357  
        Working...
        X