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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    597 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    555 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X