Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Heiken Ashi strategy not working

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

    Heiken Ashi strategy not working

    Downloaded HeikenAhi_Smoothed from


    attempted a simple short ATM Strategy:
    {
    Add(HeikenAshi_Smoothed());
    SetProfitTarget("", CalculationMode.Ticks, 20);
    SetStopLoss("", CalculationMode.Ticks, 20, false);

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (HeikenAshi_Smoothed().HAOpen[0] > HeikenAshi_Smoothed().HAClose[0]
    && HeikenAshi_Smoothed().HAOpen[1] < HeikenAshi_Smoothed().HAClose[1])
    {
    EnterShort(DefaultQuantity, "");
    }
    }

    It didn't produce any trades...

    I then tried to import RHeikenAshi.zip


    but I got an error:
    “Import Failed. The Ninjascript Archive file may contain duplicate method names that already exist on your PC or there is a required file missing on either your PC or in the input archive.”

    Now I'm stuck. Any guidance is much appreciated.

    #2
    Hello benww604,

    Thank you for your post.

    Please try adding a Print() to the condition:
    Code:
    if (HeikenAshi_Smoothed().HAOpen[0] > HeikenAshi_Smoothed().HAClose[0]
    && HeikenAshi_Smoothed().HAOpen[1] < HeikenAshi_Smoothed().HAClose[1])
    {
    EnterShort(DefaultQuantity, "");
    Print("HA EnterShort");
    }
    The check the Output window under Tools > Output and run your strategy.

    For the file you are attempting to import it was built for a previous version of NinjaTrader and is not compatible with NinjaTrader 7.

    Comment


      #3
      Hi Patrick,

      Thanks for the instructions. Did as instructed. Output window showed this error:
      **NT** Error on calling 'OnBarUpdate' method for strategy 'testHA1/f09c4e0c524643faa7022da274c3e7c2': The indicator 'HeikenAshi_Smoothed' is intended for visualization and can only be used on a chart.

      I only backtested this, & didn't run this on live SIM. I don't know if that matters.

      Is there a working NT7 version indicator able to create a strategy from? I got the impression RHeikenAshi.zip worked for NT7

      Comment


        #4
        You can find a HeikenAshiSmoothed for NinjaTrader 7 at the following link: http://www.ninjatrader.com/support/f...d=4&linkid=358

        Comment


          #5
          Thank you Patrick. This was the indicator that I imported and backtested but no trades executed. My current code:
          {
          Add(HeikenAshi_Smoothed());
          SetProfitTarget("", CalculationMode.Ticks, 20);
          SetStopLoss("", CalculationMode.Ticks, 20, false);

          CalculateOnBarClose = true;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          // Condition set 1
          if (HeikenAshi_Smoothed().HAOpen[0] > HeikenAshi_Smoothed().HAClose[0]
          && HeikenAshi_Smoothed().HAOpen[1] < HeikenAshi_Smoothed().HAClose[1])
          {
          EnterShort(DefaultQuantity, "");
          Print("HA EnterShort");
          }
          }

          Unfortunately this doesn't fix it. On the output log I get the error:
          **NT** Error on calling 'OnBarUpdate' method for strategy 'testHA1/f09c4e0c524643faa7022da274c3e7c2': The indicator 'HeikenAshi_Smoothed' is intended for visualization and can only be used on a chart.

          Sorry, I'm still confused. I am using the current indicator as mentioned.

          Comment


            #6
            Originally posted by benww604 View Post
            Thank you Patrick. This was the indicator that I imported and backtested but no trades executed. My current code:
            {
            Add(HeikenAshi_Smoothed());
            SetProfitTarget("", CalculationMode.Ticks, 20);
            SetStopLoss("", CalculationMode.Ticks, 20, false);

            CalculateOnBarClose = true;
            }

            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
            // Condition set 1
            if (HeikenAshi_Smoothed().HAOpen[0] > HeikenAshi_Smoothed().HAClose[0]
            && HeikenAshi_Smoothed().HAOpen[1] < HeikenAshi_Smoothed().HAClose[1])
            {
            EnterShort(DefaultQuantity, "");
            Print("HA EnterShort");
            }
            }

            Unfortunately this doesn't fix it. On the output log I get the error:
            **NT** Error on calling 'OnBarUpdate' method for strategy 'testHA1/f09c4e0c524643faa7022da274c3e7c2': The indicator 'HeikenAshi_Smoothed' is intended for visualization and can only be used on a chart.

            Sorry, I'm still confused. I am using the current indicator as mentioned.
            I wrote that indicator as one of my early efforts. At the time of writing, it was intended to be a visual indicator for manual trading only, so I deliberately restricted it as such. Despite that, I actually do have the DataSeries that you want to access, exposed, just in case this ever came up. Surprising that this is the first time that it has, eh? After almost 3 years have passed since the last update?

            As are all shared indicators in the forum, the code is open, so you should be able to edit it and recompile it for your purposes. Just remove this line:
            Code:
            ChartOnly			= true;

            Comment


              #7
              Nice, lol. I guess I'm a little late to the party. I edited the indicator & removed the line as instructed. I only found that line once.
              ChartOnly = true;

              recompiled it, but still no trades executed. Am I missing a step still?

              Maybe it wasn't meant to be... lol

              But I really do appreciate the help.

              Comment


                #8
                Originally posted by benww604 View Post
                Nice, lol. I guess I'm a little late to the party. I edited the indicator & removed the line as instructed. I only found that line once.
                ChartOnly = true;

                recompiled it, but still no trades executed. Am I missing a step still?

                Maybe it wasn't meant to be... lol

                But I really do appreciate the help.
                You would have an "index" problem report in your log. Search this forum using the text of the log error, and you should be able to find a solution.

                In your particular case, you probably need:
                Code:
                if (CurrentBar <1) return;
                as the first statement in your OnBarUpdate() handler.

                Comment


                  #9
                  Hello,
                  I'm having problems with the Heiken Ashi as well:
                  HeikenAshi().BarColor = Color.Lime results in errors. How do I simply reference the bar color to say enter a long or short order?
                  Thanks, Yemi

                  Comment


                    #10
                    Hello aaadetos,

                    Thank you for your post.

                    You would not reference the color of the bar but rather if it is up or down. Up would be lime by default so we would use the code below:
                    Code:
                    			if(HeikenAshi(Input).HAClose[0] > HeikenAshi(Input).HAOpen[0])
                    			{
                    				Print("Up");
                    			}

                    Comment


                      #11
                      Thanks Patrick

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      656 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      371 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
                      574 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      579 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X