Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Heiken Ashi

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

    Heiken Ashi

    Hi

    i am looking at using the heiken ashi indicator but my programming is missing the mark a bit...

    basically id like to execute an order if the last bar was green

    i tried this but it didnt work

    if (HeikenAshiCustom().HAOpen[0] < HeikenAshiCustom().HAClose[0])
    {

    do something

    }

    maybe you can use a bar colour property but i tried to just do open greater than but didnt execute the "do something"


    any help would be greatly appreciated

    Thanks in advance
    Arun

    #2
    Logic wise that looks fine but I am not familiar with indicator you reference. You would need to check to make sure there are values returned by this indicator.
    RayNinjaTrader Customer Service

    Comment


      #3
      yeah i thought so but i dont really understand the indicator that well myself its the Hieken ashi modified one available from the sharing indicators page. It looks very useful but im not sure how to return the colour of the last superimposed bar

      If anyone out there is familiar I would appreciate any help

      i could probably write some functions but im not sure what to access

      Thanks
      Arun
      Attached Files

      Comment


        #4
        Just throwing out ideas, you could store the color of the last bar in a variable and just call that variable to get its color in the future.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          yeah that sounds like a simple solution (its been a few years since i did my programming course so im a "little" rusty haha) would i have to create initialize and set the variable in the indicator script?

          ill have a go this morning

          thanks for the suggestion

          Arun

          Comment


            #6
            You would make it just like you make any other variable. You can look through other indicators to get an idea of how they make variables and just mimic them.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              thanks for the advice im a little rusty


              Arun

              Comment


                #8
                ive created a variable called lastBarColor in the variables of the indicator and initialised it to empty, thats fine if i do a simple if condition as below in my strategy

                if (myHeikenAshi().lastBarColor == Color.Empty)
                EnterLong();


                this works and the longs are entered

                i have narrowed to problem down to my indicator, basically when i try to set the lastBarColor = barColor as below it is not stored and i can not recall the color, i have created the variable as public for ease of access

                Color barColor = (Values[3][0] > Values[0][0] ? BarColorUp : BarColorDown);
                lastBarColor = barColor; // <------here is the assignment
                DrawLine(CurrentBar.ToString(),
                0, Values[1][0], 0, Values[2][0], ShadowColor, DashStyle.Solid, ShadowWidth);
                DrawLine(CurrentBar.ToString() +
                "OC", 0, Values[0][0], 0, Values[3][0], barColor, DashStyle.Solid, ShadowWidth * 3);


                any ideas would be welcome im a bit stuck

                Thanks
                Arun
                Last edited by arilano; 04-15-2008, 04:33 PM.

                Comment


                  #9
                  Please see this reference sample instead of declaring as public: http://www.ninjatrader-support.com/v...ead.php?t=4991

                  You most likely need to use the Update() method as described in that sample.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    yep thats exactly what I need

                    thanks for pointing me in the right direction


                    Much appreciated

                    Arun

                    Comment


                      #11
                      h-ok ive set the variables to protected and am using the get set functions, i have included Update(); calls in the functions but still the bullindicator bool is not being set and i hence my strat is not executing anything because the bools are not changing

                      barColor = (Values[3][0] > Values[0][0] ? BarColorUp : BarColorDown);
                      DrawLine(CurrentBar.ToString(),
                      0, Values[1][0], 0, Values[2][0], ShadowColor, DashStyle.Solid, ShadowWidth);
                      DrawLine(CurrentBar.ToString() +
                      "OC", 0, Values[0][0], 0, Values[3][0], barColor, DashStyle.Solid, ShadowWidth * 3);


                      if (barColor == Color.Lime)
                      {
                      bullIndication.Set(
                      true);
                      bearIndication.Set(
                      false);
                      }

                      elseif( barColor == Color.Red)
                      {
                      bullIndication.Set(
                      false);
                      bearIndication.Set(
                      true);

                      }...


                      and for the update part ive got

                      public BoolSeries BearIndication
                      {
                      get { Update(); return bearIndication; } // Allows our public BearIndication BoolSeries to access and expose our interal bearIndication BoolSeries
                      }


                      Im still not getting the value i need, all i want is the bar colour of the last candle

                      apologies if this is outside the scope of support but im at a dead end

                      Thanks
                      Arun

                      Comment


                        #12
                        Could you please post the strategy and the indicator files instead of snippets? It is hard to determine their relationship from snippets. Thanks.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi

                          I've had an idea as im only interested in the formula for working out the new real bodies i should be able to do this in a strategy without using the indicator at all, and I will keep this on a back burner or as an exercise to improve my coding.

                          will be back if if stuck!

                          Thanks for the help

                          Arun

                          Comment


                            #14
                            Hia Arilano,

                            have you been able to sort out this?

                            I am trying to do the same without any result

                            Cheers

                            Comment


                              #15
                              Originally posted by arilano View Post
                              i tried this but it didnt work

                              if (HeikenAshiCustom().HAOpen[0] < HeikenAshiCustom().HAClose[0])
                              {
                              do something
                              }
                              In your OnBarUpdate(), you need to look at the previous bar, not the current bar.

                              if (HeikenAshiCustom().HAOpen[1] < HeikenAshiCustom().HAClose[1])
                              {
                              do something
                              }

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              558 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              324 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              545 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              547 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X