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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    80 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X