Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Am I doing this correctly?

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

    Am I doing this correctly?

    Hi-

    I'm trying to create a Heiken Ashi series out of my base time frame, and use the "HAOpen" portion of that series as input into another indicator.

    Here's the code I'm using - is this the correct usage?

    Code:
    private HeikenAshi myHeikenAshi;
    
    if (useHeikenAshi)
    {
               myHeikenAshi = HeikenAshi(BarsArray[z]);
               momentumIndicators.Add(CRGMomentum(myHeikenAshi.HAOpen));
               Print (Time[0] + ": " + "Added HeikenAshi successfully.");
    }
    PS I've declared myHeikenAshi previously

    #2
    Hi cgeorgan,

    It should work the same as accessing any other indicator value. You can declare an HA variable as well.

    double myDouble = SMA(HeikenAshi(BarsArray[0]).HAOpen, 14)[0];
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Hi cgeorgan,

      It should work the same as accessing any other indicator value. You can declare an HA variable as well.

      double myDouble = SMA(HeikenAshi(BarsArray[0]).HAOpen, 14)[0];
      Hmm, that doesn't seem to be correct. I tried this:
      Code:
                      myCRGMomentum1 = CRGMomentum(HeikenAshi().HAOpen);
                      myCRGMomentum2 = CRGMomentum();
                      
                      Add(myCRGMomentum1);
                      Add(myCRGMomentum2);
      And what came out was this on the chart - indicating myMomentum1 didn't run correctly.

      PS This was done in Initialize()
      Attached Files

      Comment


        #4
        I suggest simplifying and debugging your code. Check log tab of control center for any error messages.

        For an example: I've attached a sample script with a multiseries heikenashi (declared as variable as well) passed into an SMA.
        Attached Files
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_RyanM View Post
          I suggest simplifying and debugging your code. Check log tab of control center for any error messages.

          For an example: I've attached a sample script with a multiseries heikenashi (declared as variable as well) passed into an SMA.
          Ryan -

          I'm not even sure what you mean by this. I provided 4 (four) lines of code, two of which work perfectly fine, the other two to demonstrate what I'm trying to do.

          Throw a man a bone here. I need 1 line of syntax to insert HeikenAshi().HAOpen as the primary data series in an indicator, rather than the base data series .Close.

          Comment


            #6
            I've given the one line of code for this and created an example script for you with some more advanced features.

            If you need to start at a simpler level, use the strategy wizard to construct an SMA of Heiken ashi open. You can create this in a point and click environment and view the resulting syntax.

            If you're looking for professional level coding services, any of our NinjaScript consultants should be able to assist, and work with your existing code:
            Attached Files
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_RyanM View Post
              I've given the one line of code for this and created an example script for you with some more advanced features.

              If you need to start at a simpler level, use the strategy wizard to construct an SMA of Heiken ashi open. You can create this in a point and click environment and view the resulting syntax.

              If you're looking for professional level coding services, any of our NinjaScript consultants should be able to assist, and work with your existing code:
              http://www.ninjatrader.com/partners#...pt-Consultants
              You don't suppose that the fact that I'm attempting to add this in the Initialize() function has anything to do with it?

              Comment


                #8
                If you are still having issues with this, I suggest simplifying and working from the provided example. I created this specifically for you based on your English description of your coding goals.

                Use the strategy wizard if you need help with syntax. There is also a help guide articles for using the condition builder to compare multi plot indicators and using indicators as input in other indicators.


                How to compare plot values of multi-plot indicators
                How to use indicator inputs in other indicators
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_RyanM View Post
                  If you are still having issues with this, I suggest simplifying and working from the provided example. I created this specifically for you based on your English description of your coding goals.

                  Use the strategy wizard if you need help with syntax. There is also a help guide articles for using the condition builder to compare multi plot indicators and using indicators as input in other indicators.


                  How to compare plot values of multi-plot indicators
                  How to use indicator inputs in other indicators
                  This is getting out of control. I feel like I'm speaking with an automated call center in India.

                  Here's what you should have explained:

                  THIS WORKS
                  Code:
                  MyIndicator FOO1 = MyIndicator(HeikenAshi().HAOpen);
                  Add(FOO1);

                  THIS WORKS:

                  Code:
                  MyIndicator FOO1 = MyIndicator(HeikenAshi());
                  Add(FOO1);
                  If you use option #1 IN BACKTEST MODE, the indicator doesn't show up correctly (Insert explanation here). The indicator attempts to start out early in the bars, and progressively goes to zero.

                  If you use option #1 IN REAL TIME, the indicator shows up correctly.

                  If you use option #2 IN BACKTEST MODE, you implicitly get the HeikenAshi().HAOpen value. More importantly, it shows the historical values of MyIndicator.

                  So, to sum up, you could have simply said, "It actually looks like you're doing everything correctly. The reason you aren't seeing any values in your picture is that because, when using METHOD #1, NT will not display the historical values for your indicator while backtesting (insert explanation here). If it's important for you to be able to see historical values of your indicator, you should use METHOD # 2 (insert explanation here).

                  Anyways, thanks for the "help" this time, Ryan. I blew 3 hours of my afternoon working on helping you help me.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  647 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  367 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  108 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  570 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  573 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X