Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Previous Heikin Ashi still calculating

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

    Previous Heikin Ashi still calculating

    Can some one help me on this? My Previous Heikin Ashi still calculating in current bar. The below simple order executed multiple times. I also set execute on bar close.


    else if (State == State.Configure)
    {

    AddHeikenAshi("ES 06-20", BarsPeriodType.Minute, 1, MarketDataType.Last);

    }

    if ((Closes[1][1] > Opens[1][1]))
    {

    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    Print(" ll Long entry Opens[1][1] " +Opens[1][1] +"CLOSE "+ Closes[1][1]);

    }

    if ((Closes[1][1] < Opens[1][1]))
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    #2
    Hello Akee5,

    Thanks for your post.

    When you add a data series to your code, both the added data series and the chart bars will call the OnBarUpdate(). This means that unless you have segmented your code with the BarsInProgress that each call to the OnBarUpdate() will trigger an order (if the entry conditions remain true).

    Please review the section on Multi time frame/series coding to understand how you need to code in this type environment: https://ninjatrader.com/support/help...nstruments.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I have bar in progress in place , my point is HA series for current bar Closes[1][0] gets calculated when bar in progress , why previous bar Closes[1][1] value also still get calculated, I debugged in VS, added a watch on this series and found it.

      if (BarsInProgress != 0)
      return;

      Comment


        #4
        Hello Akee5,

        Thanks for your reply.

        Correct, that change will prevent the added data series from triggering another order.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          The problem is, this code is there from start and I am getting multiple order entry. This simple 10 line code I attached, please give it to some tech guy to debug and fix the bug.
          Attached Files

          Comment


            #6
            Hello Akee5,

            Thanks for your reply.

            In order to understand what you are doing please advise what the chart instrument is and what the chart bars are (type and size).

            Are you testing on Live data or in the playback connection or in the Strategy analyzer.

            Please post a screenshot that shows what you are seeing on the chart.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I was doing ES 06-20, using Playback for 17th April, Attached the screen shorts for bar type and chart. Trade is on one minutes bar
              Last edited by Akee5; 04-20-2020, 04:13 PM.

              Comment


                #8
                Hello Akee5,

                Thanks for your reply.

                I tested your strategy and do not see what you are showing in your chart. Only one entry per bar.

                Your chart indicates a stop loss which is not contained in the strategy you posted.

                Can you provide a reduced code sample strategy that replicates the issue of multiple entries per bar when using Calculate.OnBarClose?
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Here is the code and screen shot, task was to buy on previous green and sell on previous red, it gives these unexpected result marked in arrow in attached, I debugged number of times and found it is recalculating the previous values, kindly check what I am doing wrong or the system itself is wrong.
                  Attached Files

                  Comment


                    #10
                    Hello Akee5,

                    Thanks for your reply.

                    Your strategy is the same as previously posted but without the 1 tick stop loss. From your post#7 I understand you are applying the strategy to 1 minute bars of the ES 06-20. The strategy adds 1 minute heiken-ashi bars. The strategy will place a market order long when the previous Heiken ashi bar close > Open and short when the previous Close < Open.

                    I modified your strategy to add a debugging aid of drawing dots on the chart when the entry conditions are true. Green below the bar for long and Red above the bar for short, In the attached chart i am showing the 1 minute ES 06-20 and in a second panel I am showing ES 06-20 1 minute Heiken ashi bars. On the 1 minute bars you will see the strategy entries and exits and the red and green dots indicating short and long conditions based on the Heiken-Ashi bars.

                    Just to be clear, when you apply an entry method and there is an existing position in the opposite direction, the entry method will first issue a market order called "Close Position" and it will then (in this case) place another market order to leave you in the intended direction.

                    From what I see the strategy is trading exactly as you have programmed it.

                    Click image for larger version

Name:	Akee5-1.PNG
Views:	362
Size:	88.9 KB
ID:	1098670
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_PaulH View Post
                      Hello Akee5,

                      Thanks for your reply.

                      Your strategy is the same as previously posted but without the 1 tick stop loss. From your post#7 I understand you are applying the strategy to 1 minute bars of the ES 06-20. The strategy adds 1 minute heiken-ashi bars. The strategy will place a market order long when the previous Heiken ashi bar close > Open and short when the previous Close < Open.

                      I modified your strategy to add a debugging aid of drawing dots on the chart when the entry conditions are true. Green below the bar for long and Red above the bar for short, In the attached chart i am showing the 1 minute ES 06-20 and in a second panel I am showing ES 06-20 1 minute Heiken ashi bars. On the 1 minute bars you will see the strategy entries and exits and the red and green dots indicating short and long conditions based on the Heiken-Ashi bars.

                      Just to be clear, when you apply an entry method and there is an existing position in the opposite direction, the entry method will first issue a market order called "Close Position" and it will then (in this case) place another market order to leave you in the intended direction.

                      From what I see the strategy is trading exactly as you have programmed it.

                      Click image for larger version

Name:	Akee5-1.PNG
Views:	362
Size:	88.9 KB
ID:	1098670
                      Hi, I'm new to NT and trying to figure out how the addons work, could you tell me where I can download this heiken ashi add on the one at the bottom of your picture pls?

                      Comment


                        #12
                        Hello scorpion11,

                        Thanks for your post and welcome to the Ninjatrader forums!

                        The Heiken-ashi is available in your Platform as a bar type. When you create a chart, click the drop down arrow to expose a list of bar types. Heiken-ashi can be selected there and then further specified as needed. Reference: https://ninjatrader.com/support/help...riesParameters



                        Paul H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by maybeimnotrader, Yesterday, 05:46 PM
                        4 responses
                        23 views
                        0 likes
                        Last Post maybeimnotrader  
                        Started by frankthearm, Today, 09:08 AM
                        6 responses
                        24 views
                        0 likes
                        Last Post frankthearm  
                        Started by adeelshahzad, Today, 03:54 AM
                        5 responses
                        33 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by stafe, 04-15-2024, 08:34 PM
                        7 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by merzo, 06-25-2023, 02:19 AM
                        10 responses
                        823 views
                        1 like
                        Last Post NinjaTrader_ChristopherJ  
                        Working...
                        X