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

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.
    https://ninjatrader.com/support/foru...96#post1113896

    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.
    https://ninjatrader.com/support/help...nt_day_ohl.htm
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Havencapital, Today, 11:27 PM
    0 responses
    1 view
    0 likes
    Last Post Havencapital  
    Started by AdeptistJune, Today, 10:00 PM
    0 responses
    2 views
    0 likes
    Last Post AdeptistJune  
    Started by Genesis2021, Today, 04:13 PM
    1 response
    26 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by tonystarks, Today, 05:00 PM
    2 responses
    10 views
    0 likes
    Last Post tonystarks  
    Started by aleksov_dimitar, Today, 04:10 PM
    0 responses
    10 views
    0 likes
    Last Post aleksov_dimitar  
    Working...
    X