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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        47 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        15 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        21 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X