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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    35 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    12 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    18 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X