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

Help with Renko + Heikin Ashi Strategy

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

    Help with Renko + Heikin Ashi Strategy

    Hello,

    I'm trying to design a simple strategy for Crude Oil Futures using a combination of Renko 6 and Heikin Ashi Candles but when I backtest it I just can manage to understand why it's not performing the actions appropriately.

    The strategy is very simple: If the preceding candle opens and closes above the EMA10, and the current candle opens above but closes below the EMA10 and Stochastics(7,14,3) D value at the previous candle is >=70, then enter short limit at EMA10 of the previous candle and put a stop loss order at the high of previous candle +1 tick. For longs, do the opposite (D value <=30).

    The code I use for these conditions is the following:
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Open[1]>EMA(10)[1] && Close[1]>EMA(10)[1]
    && Open[0] * TickSize > EMA(10)[0]
    && Close[0] < EMA(10)[0]
    && Stochastics(7, 14, 3).D[1] >= 70)

    {
    EnterShortLimit(DefaultQuantity, EMA(10)[1], "");
    EnterLongStop(DefaultQuantity, High[1] + 1 * TickSize, "");
    }

    // Condition set 2
    if (Open [1]<EMA(10)[1] && Close[1]<EMA(10)[1]
    && Open[0] < EMA(10)[0]
    && Close[0] > EMA(10)[0]
    && Stochastics(7, 14, 3).D[1] <= 30)
    {

    EnterLongLimit(DefaultQuantity, EMA(10)[1], "");
    ExitShortStop(Low[1] + 1 * TickSize, "", "");
    }
    }

    For the backtesting:
    - I use Market Replay speed 500x
    - Fill type = liberal
    - Slippage= 1
    - Entries per direction = 1

    On the following image you can see the entries that the strategy has missed but shouldn't:

    I would appreciate if you could help me with this, Thanks in advance.

    #2
    Hi Kirgat,
    I have always been interested in Both Renko and Heiken-Ashi Bars. The little experimenting I have done however leads me to assume that these bars are basically virtual bars where they can get re-written based on future ticks vs Real time bars that only show exactly what has transpired to that point thus my assumption had always been that these bars were more for Human visual aid than strategy programming altho I admit I could be totally wrong about that. The first thing I would suggest is that you set your strategy to operate on the close of the bars and place some code to print the High ,Low and Ema of the last close So you can see where your strategy should of triggered it may illustrate the issue.
    also Compare the printed Highs and Lows to the bars on your chart. Further, I was disappointed to find that They did not include the Heiken-Ashi with Renko selection in NT8 as I did want to experiment further. Please post any info you find.

    Jerry

    Comment


      #3
      Hello kirgat, and thank you for your question. While full debugging is beyond the scope of the support we may provide, I did notice the following in your code sample :

      Condition set 1 :
      Code:
      Open[0] * TickSize
      Please review the code near there and ensure it matches your goals, as no other code in your strategy scales the opening price by the tick size.
      Jessica P.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by kirgat View Post
        Hello,

        I'm trying to design a simple strategy for Crude Oil Futures using a combination of Renko 6 and Heikin Ashi Candles but when I backtest it I just can manage to understand why it's not performing the actions appropriately.

        The strategy is very simple: If the preceding candle opens and closes above the EMA10, and the current candle opens above but closes below the EMA10 and Stochastics(7,14,3) D value at the previous candle is >=70, then enter short limit at EMA10 of the previous candle and put a stop loss order at the high of previous candle +1 tick. For longs, do the opposite (D value <=30).

        The code I use for these conditions is the following:
        protected override void OnBarUpdate()
        {
        // Condition set 1
        if (Open[1]>EMA(10)[1] && Close[1]>EMA(10)[1]
        && Open[0] * TickSize > EMA(10)[0]
        && Close[0] < EMA(10)[0]
        && Stochastics(7, 14, 3).D[1] >= 70)

        {
        EnterShortLimit(DefaultQuantity, EMA(10)[1], "");
        EnterLongStop(DefaultQuantity, High[1] + 1 * TickSize, "");
        }

        // Condition set 2
        if (Open [1]<EMA(10)[1] && Close[1]<EMA(10)[1]
        && Open[0] < EMA(10)[0]
        && Close[0] > EMA(10)[0]
        && Stochastics(7, 14, 3).D[1] <= 30)
        {

        EnterLongLimit(DefaultQuantity, EMA(10)[1], "");
        ExitShortStop(Low[1] + 1 * TickSize, "", "");
        }
        }

        For the backtesting:
        - I use Market Replay speed 500x
        - Fill type = liberal
        - Slippage= 1
        - Entries per direction = 1

        On the following image you can see the entries that the strategy has missed but shouldn't:

        I would appreciate if you could help me with this, Thanks in advance.
        Open[0] is the opening price of the bar behind the Heiken-Ashi bar, not the Heiken-Ashi print. Is that what you intended, or are you trying to use the Heiken-Ashi open?

        In other words, your code makes no reference to Heiken-Ashi, so how does your code relate to that which you describe as your intended strategy?

        Comment


          #5
          Sure cleared up why I was seeing what I was seeing anytime I played with these.

          Comment


            #6
            Originally posted by koganam View Post
            Open[0] is the opening price of the bar behind the Heiken-Ashi bar, not the Heiken-Ashi print. Is that what you intended, or are you trying to use the Heiken-Ashi open?

            In other words, your code makes no reference to Heiken-Ashi, so how does your code relate to that which you describe as your intended strategy?
            Thanks for your answers.
            Koganam, I'm sorry but I'm not getting your point. My intention is to check if the current bar opens above the EMA and also closes below the EMA. Am I not doing it right?

            Comment


              #7
              If I understand him correctly, he is indicating that the Heinken-Ashi Candles are calculated from the underlying data which makes sense. You are accessing the underlying data and Not the Heinken-Ashi Calculated Candles. If you want your Strategy calculations to match up with the visual display from the bars you must Access the Calculated Heinken-Ashi Candles.

              Comment


                #8
                Originally posted by JerryWar View Post
                If I understand him correctly, he is indicating that the Heinken-Ashi Candles are calculated from the underlying data which makes sense. You are accessing the underlying data and Not the Heinken-Ashi Calculated Candles. If you want your Strategy calculations to match up with the visual display from the bars you must Access the Calculated Heinken-Ashi Candles.
                Your understanding is perfect.
                Last edited by koganam; 02-14-2017, 03:04 PM.

                Comment


                  #9
                  What is the syntax to access these bars assuming their is a BarsArray built for them.

                  Is there something Like HeikenAshiBarsArray[0].GetHigh[0] etc

                  Comment


                    #10
                    If we can still help kirgat, please provide an up-to-date version of the script, and please let us know how the things we have discussed have changed the behavior. We look forward to assisting further if we may.
                    Jessica P.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by JerryWar View Post
                      What is the syntax to access these bars assuming their is a BarsArray built for them.

                      Is there something Like HeikenAshiBarsArray[0].GetHigh[0] etc
                      In NT7, Heiken-Ashi is just another indicator. You access its public properties in exactly the same manner as one does all indicators.
                      Code:
                      HeikenAshi().HAOpen[int barsAgo]
                      HeikenAshi(IDataSeries input)[int barsAgo]
                      and so on.

                      ref: http://ninjatrader.com/support/helpG...eiken_ashi.htm

                      Comment


                        #12
                        No wonder I could not find it. I looked in the NT8 Help guide which wasn't much help.
                        I know the Renko input is not available in NT8 but I didn't think they would gut the documentation unless I am missing it. I tried search and Alphabetical and up with virtually nada in NT8

                        Thanks

                        Comment


                          #13
                          Originally posted by JerryWar View Post
                          No wonder I could not find it. I looked in the NT8 Help guide which wasn't much help.
                          I know the Renko input is not available in NT8 but I didn't think they would gut the documentation unless I am missing it. I tried search and Alphabetical and up with virtually nada in NT8

                          Thanks
                          Hm. In NT8, Heiken Ashi is a bar type, so if that is the bar type selected. then I would expect Open[0] to actually be the Heiken Ashi open, as that is the bar type. Is that not the case?

                          The query was posted in the NT7 forum, which is why I answered as I did.

                          Comment


                            #14
                            No , You got it right. I was interested in the topic, found them in NT8 and then stumbled trying to access it because I could not find the doc, As you indicated it is now a bar type. Probably why the changeover did not contain the renko inputs as well.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by BarzTrading, Today, 07:25 AM
                            2 responses
                            21 views
                            1 like
                            Last Post BarzTrading  
                            Started by devatechnologies, 04-14-2024, 02:58 PM
                            3 responses
                            20 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Started by tkaboris, Today, 08:01 AM
                            0 responses
                            4 views
                            0 likes
                            Last Post tkaboris  
                            Started by EB Worx, 04-04-2023, 02:34 AM
                            7 responses
                            163 views
                            0 likes
                            Last Post VFI26
                            by VFI26
                             
                            Started by Mizzouman1, Today, 07:35 AM
                            1 response
                            10 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Working...
                            X