Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Working both with OnBarUpdate and OnRender leads to different values.

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

    Working both with OnBarUpdate and OnRender leads to different values.

    Hello,

    I am confuse. I try to use values returned from my calculation in OBU to OR.

    I created a list in Public Class

    List<double> listCan = new List<double>() {};

    I added my variable candle in OBU :

    listCan.Add(candle);


    Than i use in OR a:

    foreach(var item in listCan)
    {
    Print("CAN"+item);
    }

    How come the values in Print in OR are totally different from those Print in OBU. If i just Print(candle) the result is different from CAN in OR?

    TY

    #2
    Hello frankduc, thanks for your post.

    If you need to access a list in a non-data-driven event you should use TriggerCustomEvent to synchronize the indexes, see the "Using TiggerCustomEvent to update a previously set custom Series<T> value" sample on this page:
    ttps://ninjatrader.com/support/help...ustomevent.htm

    This applies to the internal lists that NinjaTrader manages throughout the lifetime of the script like Series<T> objects. Consider using these instead of custom lists. As far as some custom list goes, you would need to systematically place Print statements throughout the script that would explain the miss-match, I'm not sure what would cause a difference in the case presented.

    Best regards.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    72 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    152 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X