Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What is the preferred way to access doubles from different class

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

    What is the preferred way to access doubles from different class

    Hi i have my doubles in onbarupdate that i access in my script, however when i get to trail in OnMarketData, it doesnt see those doubles. What is the preffered way to access those doubles from onMarketData?
    Thank you

    #2
    Hello tkaboris,

    OnBarUpdate and OnMarketData are within the same class, so in that case you would use a class level variable.

    private double myDouble;

    protected override void OnBarUpdate()
    {
    myDouble = 100;
    }

    Comment


      #3
      But if I do this way there are many iterations for calculating double value, I don’t need that. How can I keep it to iteration just once?

      Comment


        #4
        Hello tkaboris,

        That would be the correct way to share a variable between two methods. If you want to set the value once you would need your logic to set the value once. You can also set that from OnStateChange if that is supposed to just be a default value or set infrequently. C# has what is known as class level variables, you can research this topic in external resources if you wanted to learn more about how C# variables can be used.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        76 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        146 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        79 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        50 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        54 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X