Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Open High Low and Close

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

    Using Open High Low and Close

    Hi,

    Working on a strategy that is using 5min time frame, but want to make the exits more rapidly on 1min time frame. Sometimes you can see a nice wick on a candlestick that has crossed the exit point, but the close is nowhere near it. Wondering if i use OR (||) to say if any of the values cross the line exit which one will be hit when more than one do?

    So if a low and a close are below the Boll middle (exit point) will it be the low as that happened first, or would it be which comes first in the codev (would it make a difference if all wgere or options in the single if statement), or is there some other priority order as in OHLC

    Thanks

    #2
    Hello Aussiemike,

    If you would like your order filled with intrabar granularity then you will have two options.

    1. If your Strategy is running with real-time data (either from live-data or Market Replay data) you may set Calculate on Bar Close (COBC) to false in the Strategy Parameters so that with each incoming tick your Strategy will run the OnBarUpdate() method.

    2. When backtesting/historically processing your Strategy based only on the historical data which is only the Open, High, Low and Close of a bar and not every tick that created the bar. There fore COBC is always going to be true. To work around this you may add another time frame inside your strategy for intrabar granularity. You may view the following thread that has more information and a reference sample on this.

    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by



    If you want both conditions to be true before your code is processed you may want to use the ( && ) AND logical operator.

    NinjaScript will be processed in the order that it is coded. Think of it like a book, it will start from the top left and work its way to the right then move down to the next line and work its way to the right again.

    Happy to be of further assistance.
    Last edited by NinjaTrader_JC; 12-26-2012, 04:02 PM.
    JCNinjaTrader Customer Service

    Comment


      #3
      Hi JC,

      I already have more granular data. I'm using 1min as i dont have tick going back further than the 120days. Just started this, and just started data collection.

      So i use 1min to exit say a 5 or 15min strategy with bollinger bands. But even in 1min the candle can do a lot. It can whip down below your exit, and nver come back. Turns the whole trade upside down, and gives false results.

      So i've coded in all the levels OHL and C to say if one or the other is >= then exit. So if all of them were a match which one would be hit...? The numerical order as in the 98 is hit before 99, or is high hit before low etc?

      Cheers

      So what happens here...?

      if ((Close[0] <= Bollinger(BarsArray[0],2,14).Middle[0])
      || (Open[
      0] <= Bollinger(BarsArray[0],2,14).Middle[0])
      || (Low[
      0] <= Bollinger(BarsArray[0],2,14).Middle[0])


      Comment


        #4
        Originally posted by Aussiemike View Post
        Hi JC,

        I already have more granular data. I'm using 1min as i dont have tick going back further than the 120days. Just started this, and just started data collection.

        So i use 1min to exit say a 5 or 15min strategy with bollinger bands. But even in 1min the candle can do a lot. It can whip down below your exit, and nver come back. Turns the whole trade upside down, and gives false results.

        So i've coded in all the levels OHL and C to say if one or the other is >= then exit. So if all of them were a match which one would be hit...? The numerical order as in the 98 is hit before 99, or is high hit before low etc?

        Cheers

        So what happens here...?

        if ((Close[0] <= Bollinger(BarsArray[0],2,14).Middle[0])
        || (Open[
        0] <= Bollinger(BarsArray[0],2,14).Middle[0])
        || (Low[
        0] <= Bollinger(BarsArray[0],2,14).Middle[0])


        You have used logical OR. They will be processed in the order written, and execute the following conditional block on the first value that is true.

        Comment


          #5
          Thanks.

          If i wrote them as 3 seperate if statements would they again process in the writen order or would that then do a specific sequence?

          I think for the most accurate i might need to cinsider looking at which is the closest.

          Cheers

          Comment


            #6
            Originally posted by Aussiemike View Post
            Thanks.

            If i wrote them as 3 seperate if statements would they again process in the writen order or would that then do a specific sequence?

            I think for the most accurate i might need to cinsider looking at which is the closest.

            Cheers
            I will presume you mean using an if ... else if ... else construct. That will also be handled in the order written.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            573 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            576 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X