• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Identifying Heiken Ashi Wicks

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

    Identifying Heiken Ashi Wicks

    Hi folx!


    I'm trying to figure out how I can identify that a 1 previous Heiken Ashi bar has a Wick and whether it's a Red or Green Candle.


    I suppose if Open[1] is less than Close[1] then it's a Green Candle, however how can I tell whether there is a Wick at the bottom of this Green Candle or not?


    Code:
    I thought to use:
    if (Low[1] < Open[1])
    {
    WeAreWicky = true;
    }
    However the challenge I'm having is in Heiken Ashi when the next bar opens, it opens a few ticks in the Green as it is by design. So therefore which is considered the Open? Is it where price really opened? Or is it the bottom of that candle?


    And by the same thinking, if Open is really where price opened, then would the extra Green space below the Open be the Low?


    If that's the case then how can I identify any wicks since it would be the new low and I would have no idea where the actual body starts? Would I have to create my script oneachtick and record the first Low then see if during the growth of the candle there was a lower low?


    Whoa Lower Lows within a Candle. I need sleep. But I swear I'm making sense and there is a simpler answer.


    Thanks!

    #2
    Hello Bluebeep,

    Thanks for your post.

    Green candle identified by Close[0] > Open[0]
    if Green candle, wick on top = High[0] - Close[0] > 0
    if Green candle, wick on bottom = Open[0] - Low[0] > 0

    Red Candle identified by Close[0] < Open[0]
    if Red candle, wick on top = High[0] - Open[0] > 0
    if Red candle, wick on bottom = Close[0] - Low[0] > 0

    Doji candle identified by Close[0] = Open[0]
    wick on top = High[0] - Close[0] >0
    wick on bottom = Close[0] - Low[0] >0

    To visualize the "real" data and relationship to what is displayed by the Heiken-ashi bars, you can overlay another bar type. I created an example that will show you the real price values on top of the Heiken-ashi bars by using a duplicate data series but shown as OHLC bars.
    Attached Files
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Saved me again. Thank you!

      Comment


        #4
        Uh oh. I made it mad.

        How would it work if I have OnEachTick set? What I would be looking for is the values for the previous bar and Close[1] generates an error saying something along the lines of:

        Error calling OnBarUpdate on bar 0. You are accessing an index with a value that is invalid since it's out of range. Accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

        I'm using a 5 min Heiken Ashi chart and it makes sense that the first tick won't have any previous bar to look back to. But how do I handle it? Is there something I should be initializing?

        Thanks!

        Comment


          #5
          Hello Bluebeep,

          Thanks for your reply.

          Based on the information provided I suspect that you are getting the error on the very first bar of data loaded because if you are trying to access 1 bar ago [1], that bar does not exist yet for the ninjascript. When a script is run it will start at the very first historical bar on the chart. What you must do is to delay processing your code until at least, in this case, 2 bars are loaded. As the first line in OnbarUpdate() please add:

          if (CurrentBar < 2) return; // wait to process until enough bars for the barsago.

          If your coding is looking further back, such as [2] bars ago or more, then adjust the value in the above statement to cover all cases. Here is a link to the helpguide section of CurrentBar: https://ninjatrader.com/support/help...currentbar.htm
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Thanks! That did it!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Aporshnev, Today, 11:11 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Started by bc90803, Today, 11:24 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Heath  
            Started by hincal, Today, 10:07 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_RyanS  
            Started by MIKEALV1975, Yesterday, 07:30 AM
            4 responses
            18 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by shawn9876, Today, 09:07 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Working...
            X