Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Heiken Ashi Code

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

    Heiken Ashi Code

    Hi,

    I'm trying to write a strat which incorporates Heiken Ashi bars, Bolinger Bands and the DoubleMA (custom indicator). Please see attached pic for examples involving (1) the mid line and (2) an outer band (I've done the opposite for longs below). My code is as follows:

    if ((entryOrder1 == null && FirstTickOfBar && (Open[1] + High[1] + Low[1] + Close[1] / 4) < Bollinger(2, 20).Upper[1]
    && High[2] >= Bollinger(2, 20).Upper[2] && (Open[1] + High[1] + Low[1] + Close[1] / 4) < (Open[2] + Close[2] / 2))
    ||
    ((entryOrder1 == null && FirstTickOfBar && DoubleMA(5, NinjaTrader.Indicator.DoubleMA_internal.DMAType.HM A, 32, NinjaTrader.Indicator.DoubleMA_internal.DMAType.VM A).Signal[1] == -1
    && DoubleMA(5, NinjaTrader.Indicator.DoubleMA_internal.DMAType.HM A, 32, NinjaTrader.Indicator.DoubleMA_internal.DMAType.VM A).Signal[2] == -1
    && High[2] >= Bollinger(2, 20).Middle[2] && (Open[1] + High[1] + Low[1] + Close[1] / 4) < Bollinger(2, 20).Middle[1]
    && (Open[2] + High[2] + Low[2] + Close[2] / 4) > (Open[3] + Close[3] / 2)
    && (Open[1] + High[1] + Low[1] + Close[1] / 4) < (Open[2] + Close[2] / 2))))

    {
    entryOrder1 = EnterShortLimit(0, true, DefaultQuantity, Open[0], "");
    }

    Since Heiken Ashi bars cannot be coded through the wizard, I've done the math myself. However, while it looks right to me, it tends to go long on just about every bar, despite it's position or relation to the prior two candles. Do I have something wrong?

    Thanks,
    Dave
    Attached Files
    Last edited by dsraider; 02-19-2010, 07:01 AM.

    #2
    Dave, please add a visual check to your conditions (ie an arrow, dot) to determine when they evaluate to 'true' from your current way of coding those, this way it's easy to see if they hit home the way you expect them to.

    Comment


      #3
      Bertrand!

      I take it you are back home now and jet-lagged.

      By changing:

      (Open[1] + High[1] + Low[1] + Close[1] / 4)

      to:

      ((Open[1] + High[1] + Low[1] + Close[1]) / 4)

      it now shorts. However, I think my math for the open may be wrong. Does HAOpen[0] = (Open[1] + Close[1]) / 2)) or does it use high and low? It's hard to tell from looking at the indicator code.

      Thanks,
      Dave

      Comment


        #4
        Great you got it solved Dave, back to Europe is not as hard as into the US, at least for me...

        I believe the HA would use Open and Close to arrive at it's open value, so your math seems correct.

        Comment


          #5
          Yeah, my math is fine. The problem is that each Heiken bar is dependent on the one before all the way down the line. So, while my actual candle is red, I'm getting a green Heiken candle. Since I want to follow the Heiken bars, can I call the RHeiken indicator I found here?

          Comment


            #6
            Yes, you would need a history or dataseries of those bars to compare properly, not familiar with the custom one you mentioned, but I believe there's a disucssion around of using a modded one for strategies.

            Comment


              #7
              Wouldn't be this one, would it?

              Comment


                #8
                True, there's a link posted in there with the zip - http://www.ninjatrader-support2.com/...2&d=1232051214

                Comment


                  #9
                  Yep. Already grabbed it. Will report back.

                  Thanks.

                  Comment


                    #10
                    Worked like a charm. Thanks!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    672 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    379 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    111 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    577 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    582 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X