Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Catching a High of a bool-condition

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

    Catching a High of a bool-condition

    Hi,

    having following condition that describes the bar i need :

    (CrossAbove(EMA(12), EMA(26), 20))

    Now i try to get + conserve th High of the price-bar at the moment this bool-condition is true to use it later to compare it to other Highs.

    How can i do this ?
    Thank you!

    #2
    How about creating a variable in the variables section:

    private double myHigh;

    then in OnBarUpdate()

    if (CrossAbove(EMA(12), EMA(26), 20))
    myHigh = High[0];

    then you can compare myHigh later.
    RayNinjaTrader Customer Service

    Comment


      #3
      thank you !

      whats the differents between
      a private double myHigh; in the variable section and

      a double blabla ; in the OnBarUpdate() section ?

      Comment


        #4
        Hi brain77,

        If you declare your variable in the Variables section, it will be available anywhere in your code, whereas the one in the OnBarUpdate() will only be locally available. So if you need to store a quick temporal calcuation, it is very convenient...

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        56 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        143 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        160 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        96 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        276 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X