• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

store value

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

    store value

    Hello,

    I have a problem and couldnt find an answer in the forum or do not understand correctly. I simply want to store the high and low of a bar to a double when a condition is true. I have done in my script, but the problem is that when the condition is true with the next bars, the high and the low in my double is changing with every bar. But I need to have stored always the high and low of the first bar when condition was true, and not changing the double with from the next bars.

    Thank you
    Tony
    Last edited by tonynt; 01-20-2017, 09:34 AM. Reason: typing error

    #2
    Hello Tony,

    Use a bool that is initialized as false.

    Require the bool to be false to set the double variable values.

    When the values are set set, set the bool to true.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Could you give an example of storing the high price?

      Thanks.

      Comment


        #4
        brucelevy,

        here it is how I do:

        in region Variables:

        double myhighprice = 0;
        double mylow = 0;

        in region OnBarUpdate

        if(your conditions)
        {...
        myhighprice = High[0];
        mylow = Low[0];
        ...
        }

        Best
        Tony
        .
        Last edited by tonynt; 02-22-2017, 11:30 PM. Reason: clearifiying

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by markus3500, Today, 03:29 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_EricB  
        Started by bohenriksen, Today, 04:00 AM
        1 response
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by brett0, Today, 12:33 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Melissa  
        Started by lordvader34, Today, 11:12 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by tausifkhan, Today, 05:18 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Working...
        X