Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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, 10: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-23-2017, 12:30 AM. Reason: clearifiying

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        179 views
        0 likes
        Last Post jeronymite  
        Started by ghoul, Today, 06:02 PM
        0 responses
        8 views
        0 likes
        Last Post ghoul
        by ghoul
         
        Started by Barry Milan, Yesterday, 10:35 PM
        6 responses
        19 views
        0 likes
        Last Post Barry Milan  
        Started by DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        13 views
        0 likes
        Last Post DanielSanMartin  
        Started by DJ888, 04-16-2024, 06:09 PM
        4 responses
        13 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Working...
        X