Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarClose problem

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

    OnBarClose problem

    Hello,

    I stuck with this problem: I cannot make to work OnBarClose indicators correctly with per tick strategy.

    I have real time strategy with CalculateOnBarClose set to false. However I use indicators that produce safe values only at the end of the bar. So I have FirstTick condition and feed these aquired values to Indicators via DataSeries array like shown below:

    protected override void OnBarUpdate()
    {
    if (FirstTickOfBar) {
    indicatorData.Set(Input[1]);
    getValue = MyIndicator( indicatorData, someMax, someMin );
    }
    // etc.
    }

    Also I have added these indicators to Initialize() constructor of my strategy like this:

    indicatorData = new DataSeries(this);
    if (drawValues) {
    Add(MyIndicator( indicatorData, someMax, someMin ));
    }

    indicatorData is private DataSeries indicatorData;

    To my amazement this plot is completely out of sync with data (zero values) for about 240 bars and there is no logic that controls when to start plot values or smth. If I remove indicatorData array from parameters to my Indicator - I get real time plot, that changes values on real time. And while it is fun to watch live plot, it triggers setups that are no longer valid after next bar. My solution to feed OnBarClose input values in array seemed like elegant solution but it doesn't seem to work. Am I missing something?

    Thank you very much,
    -A.

    #2
    Hello A,

    It seems like you are working along this sample here:


    Are there any error messages noted in log tab of the control center?

    It may work best to work from a simplified example and then add complexity only when you've verified everything works the way you expect. The link above offers one sample implementation you can work from.
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    67 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    36 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    60 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X