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

IntraBar Condition

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

    IntraBar Condition

    I need to make a condition for when the following is met.
    A candlestick should have a lower low than the previous one and then have a higher high than the previous one.

    I've tried the following code but it doesn't draw the signals for me correctly. Could you give me some ideas?

    bool signal = false;
    if (Low[0]<Low[1])
    {signal = true;}

    if (signal==true && High[0]>High[1])
    {Draw.ArrowDown(this, @"Signal " + CurrentBar, false, 0, High[0]+2, Brushes.Blue);}

    I need the signal to be drawn when the price goes down from low1 and then exceeds high1. The current candlestick may have made a higher high than high1 before dropping below low1.

    Thanks!


    #2
    Hello manueldecastro,

    Thanks for your post.

    The condition you shared would correct to detect if the current Low price is less than the previous Low price.

    That would also be correct logic for checking if the current High price is greater than the previous High price.

    If the script has the Calculate mode set to Calculate.OnBarClose, the OnBarUpdate() logic will only process at the close of a bar.

    To have logic calculate intrabar, you could set the Calculate mode to Calculate.OnPriceChange or Calculate.OnEachTick.

    Calculate.OnPriceChange would have OnBarUpdate() logic process for each change in price. Calculate.OnEachTick would have OnBarUpdate() logic calculate for each incoming tick.

    See this help guide page for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm

    To understand how your logic is behaving, debugging prints need to be added to the script. Add prints one line above the conditions that print out all the values being used in the condition along with the Time of the bar. Prints will appear in a New > NinjaScript Output window.

    See this NinjaTrader Support article for information about using Print() to understand the behavior of a script: https://support.ninjatrader.com/s/ar...nd-TraceOrders
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_BrandonH View Post
      Hello manueldecastro,

      Thanks for your post.

      The condition you shared would correct to detect if the current Low price is less than the previous Low price.

      That would also be correct logic for checking if the current High price is greater than the previous High price.

      If the script has the Calculate mode set to Calculate.OnBarClose, the OnBarUpdate() logic will only process at the close of a bar.

      To have logic calculate intrabar, you could set the Calculate mode to Calculate.OnPriceChange or Calculate.OnEachTick.

      Calculate.OnPriceChange would have OnBarUpdate() logic process for each change in price. Calculate.OnEachTick would have OnBarUpdate() logic calculate for each incoming tick.

      See this help guide page for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm

      To understand how your logic is behaving, debugging prints need to be added to the script. Add prints one line above the conditions that print out all the values being used in the condition along with the Time of the bar. Prints will appear in a New > NinjaScript Output window.

      See this NinjaTrader Support article for information about using Print() to understand the behavior of a script: https://support.ninjatrader.com/s/ar...nd-TraceOrders
      Hi Brandon,
      Im working OneachTick.

      Comment


        #4
        Hello manueldecastro,

        Thanks for your notes.

        Have you added debugging prints to the script to understand exactly how your logic is evaluating?

        To understand why the script is behaving as it is, such as drawing objects or not drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        In the script add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar.

        Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

        See this NinjaTrader Support article for information about using Print() to understand the behavior of a script: https://support.ninjatrader.com/s/ar...nd-TraceOrders
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Matt Skinner, Today, 01:55 AM
        6 responses
        27 views
        0 likes
        Last Post Matt Skinner  
        Started by webus, Today, 06:17 AM
        7 responses
        17 views
        0 likes
        Last Post webus
        by webus
         
        Started by kalli44100, 06-17-2024, 08:57 AM
        13 responses
        39 views
        0 likes
        Last Post kalli44100  
        Started by WHICKED, 06-27-2023, 12:07 PM
        73 responses
        820 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by PaulMohn, 04-30-2024, 01:45 PM
        6 responses
        27 views
        0 likes
        Last Post PaulMohn  
        Working...
        X