Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Value of highest bar between two conditions

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

    Value of highest bar between two conditions

    Hello,

    I am working on a simple strategy which will place an order when price breaks a previous low, or high.

    Considering the example for when price breaks a previous low, I want to be able to set my stop loss to the price of the highest bar between the previous low and the current bar which breaks below the value of the previous low. The trade will exit when price closes above the value of the stop loss.

    I have looked at the Ninjascript guidance for HighestBar() but I'm unsure how I can apply it.to a range. How do I constrain the HighestBar() search to the bar of the previous low and the current bar which breaks below the value of the previous low? Is there a way I can do this in time i.e set the time of the bar which makes the previous low into a user variable and set the time of the current bar which breaks the previous low into a second user variable then run the HighestBar() search between those time points?

    Thanks in advance for your help.

    Neil

    #2
    Hello burtoninlondon,

    You are correct, HighestBar() cannot be used for a range, so a custom method is needed.

    Below is a link to an example.


    As far as determining the bar that makes a new low or high, you can trigger when the current bars value for the CurrentDayOHL() indicator is not equal to the previous bar (1 bar ago) and then save that CurrentBar number to an int variable.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    53 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X