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

Strategy problem with renko bars

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

    Strategy problem with renko bars

    Hello,

    This vwap strategy works very well in ut minute, hours or volume...

    But the vwap strategy doesn't work very well with renko bars,

    - with renko, this Is a never ending strategy... It is still running after targets without new trade's signal.
    - the strategy takes more entry than i program...

    It will be great if the strategy :

    - could take profit or take loss. With no more entry than i expect.
    - then stop until new trade's signal

    Thank for your help !

    Stef
    Attached Files

    #2
    Hello,

    Thank you for the post.

    I would like to ask, are you asking for help in correcting a logic error in your script or are you asking if someone could make these changes for you on an existing script?

    I would be happy to assist in your learning if this is an item you are trying to correct yourself, otherwise if you would like someone else to modify this for you please let me know and I will notify the correct parties.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Strategy problem with renko bars

      Hello !

      Thank you for your answer !

      I would like to understand the problem. Your help is more than welcome !


      Thanks

      Stef

      Comment


        #4
        Hello ghost121,

        Thank you for the update. Please try setting the EntriesPerDirection variable equal to 1 in your Initialize() method. This limits the number of entries that can be opened at a given time.

        Please see our help guide document here for more information: http://ninjatrader.com/support/helpG...esperdirection

        You will like also want to set the EntryHandling variable to AllEntries. Please see here for more information on EntryHandling: http://ninjatrader.com/support/helpG...esperdirection

        Please let me know if this does not resolve the issue or if I may be of further assistance.
        Michael M.NinjaTrader Quality Assurance

        Comment


          #5
          Hello !

          Thank you for your answer !

          I tried this settings, but nothing change : the strategy doesn't work perfectly with renko bars


          (problem with stop loss and profit target ?)

          Thank for your help !
          Last edited by ghost121; 09-07-2015, 03:38 AM.

          Comment


            #6
            Hello ghost121,

            I have attached a screenshot of the results I got while testing the codes you provided. Could you please verify if my screenshot displays the issue or not? If not, could you please let me know the settings to use to replicate the issue?

            Thank you in advance.
            Attached Files
            Michael M.NinjaTrader Quality Assurance

            Comment


              #7
              Hello !

              Yes, that is exactly the issue I told you about.

              I need only one trade where the color changes.
              There must be 1 trade only by color change.


              Thank you !

              Comment


                #8
                Hello ghost121,

                Thank you for clarifying. Here is what is causing the problem:
                Code:
                if( (vwap.vwapSeriesBullish[0] == true && vwap.vwapSeriesBullish[1] == false) || (vwap.vwapSeriesBearish[0] == true && vwap.vwapSeriesBearish[1] == false) )
                {
                    bSuspendTrading = false;
                }
                bSuspendTrading is getting set back to false too often when the vwap indicator is calculating on the medianRenko bars. I would recommend that you make sure you understand the different possible combinations that generate the plot color on the chart and adjust your logic accordingly. You likely need to check more than just what is above.

                Here is the relevant section from the anaCurrentDayVWAP43 indicator:
                Code:
                if (sessionBar == 1 && gap0)
                {
                    PlotColors[0][-Displacement] = Color.Transparent;
                    vwapBullishSeries.Set(false);
                    vwapBearishSeries.Set(false);					
                }
                else if (Sessionvwap[0] > Sessionvwap[1])
                {
                    PlotColors[0][-Displacement] = UpColor;
                    vwapBullishSeries.Set(true);
                    vwapBearishSeries.Set(false);					
                }
                else if (Sessionvwap[0] < Sessionvwap[1])
                {
                    PlotColors[0][-Displacement] = DownColor;
                    vwapBearishSeries.Set(true);
                    vwapBullishSeries.Set(false);
                }
                else if(sessionBar == 2 && gap0)
                {
                    PlotColors[0][-Displacement] = UpColor;
                    vwapBullishSeries.Set(true);
                    vwapBearishSeries.Set(false);
                }
                else
                {
                    PlotColors[0][-Displacement] = PlotColors[0][1 - Displacement];
                    vwapBullishSeries.Set(false);
                    vwapBearishSeries.Set(false);					
                }				
                
                if(sessionBar == 1 && gap1)
                {
                	for (int i = 1; i <= 6; i++)
                		PlotColors[i][-Displacement] = Color.Transparent;
                }
                To help you figure this out I would recommend adding in some print statements to the anaCurrentDayVWAP43 indicator during these parts in the code so you can determine what it is happening differently when that indicator is applied to the medianRenko chart instead of a time or volume based chart.

                Please let me know if you require further assistance in adjusting your logic.
                Michael M.NinjaTrader Quality Assurance

                Comment


                  #9
                  Hello !

                  Thank you for your answer !

                  I use print statments here :

                  Code:
                  				else
                                  {
                                     Print("  PlotColors[0][-Displacement] = PlotColors[0][1 - Displacement]");
                                      vwapBullishSeries.Set(false);
                                      vwapBearishSeries.Set(false);					
                                  }
                  and I find this :


                  I'm on the right track. ?
                  How can I solve this problem ?

                  Thank you !
                  Attached Files
                  Last edited by ghost121; 09-11-2015, 07:02 AM.

                  Comment


                    #10
                    Hello ghost121,

                    I believe that you are looking right at the issue. You can change your strategy's entry conditions/the conditions that reset the bSuspendTrading value to account for this extra situation in the indicator. I recommend testing different conditions until it behaves how you expect with Renko bars, and then retest against time and volume bars (although these should be unaffected).

                    Please let me know if I may be of further assistance.
                    Michael M.NinjaTrader Quality Assurance

                    Comment


                      #11
                      Hello !

                      I tried this in the indicator :

                      else
                      {
                      Print(" PlotColors[0][-Displacement] = PlotColors[0][1 - Displacement]");
                      vwapBullishSeries.Set(false);
                      vwapBearishSeries.Set(true);
                      }

                      if(sessionBar == 1 && gap1)
                      {
                      for (int i = 1; i <= 6; i++)
                      PlotColors[i][-Displacement] = Color.Transparent;
                      }

                      And this in the strategy :


                      bool entry = false;
                      if( !bSuspendTrading
                      && vwap.vwapSeriesBullish[0] == true )
                      {
                      // There's a problem with stop losses in conjunction with reversals and I don't
                      // know what to do about it. Maybe this or something like it:
                      // If we're within a few ticks of the stop loss, give the stop loss a chance to
                      // get it; in other words, don't go long until the next bar.
                      //int buffer = (int)(Position.GetProfitLoss( Close[0], PerformanceUnit.Points )/TickSize);
                      //DrawText( "buf"+CurrentBar, (buffer+StopLoss).ToString(), 0, High[0]+3*TickSize, Color.Black);
                      //if( Math.Abs( buffer - StopLoss ) > 3 )
                      {
                      EnterLong();
                      entry = true;
                      }
                      }
                      else if( !bSuspendTrading
                      && vwap.vwapSeriesBearish[0] == true
                      && vwap.vwapSeriesBullish[1]== false)
                      {
                      // Same issue as above with the longs...
                      {
                      EnterShort();
                      entry = true;
                      }
                      }

                      The entry short is ok now




                      But I couldn't a solution about the long entry



                      Thank you !

                      Comment


                        #12
                        Hello ghost121,

                        Thanks for your reply.

                        What you may want to do is to add a DrawDot where you have your entry conditions to show on the chart when the entry conditions are true:

                        DrawDot ("tag1"+CurrentBar, true, 0, Low[0] - 3 *Ticksize, Color.Green); // for the long entry
                        DrawDot ("tag2"+CurrentBar, true, 0, High[0] + 3 *Ticksize, Color.Red); // for the short entry

                        This will help visualize on the chart where you expected an entry, even if you did not get one.
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          The anaCurrentDayVWAPV43 calculates the volume weighted average from the bar open, bar high, bar low, bar close and the volume of the bar. This works well for

                          - minute bars
                          - second bars
                          - tick bars
                          - volume bars
                          - range bars
                          - BetterRenko bars

                          However, all bar types that show fake data (in particular a false bar open, a false bar high or a false bar low) should not be used to calculate VWAP and standard deviation bands. Both NinjaTrader Renko bars and Median Renko bars belong to the category of fake bars. Median Renko bars are performing even worse than Renko bars.

                          Those bars are neither suitable for calculating the VWAP and SD bands, nor should they ever be used to perform a backtest as all backtests that are based on these bars and rely on market orders are definitely false.

                          Below I have attached two charts which show VWAP and SD bands calculated from Renko bars (slightly false) and calculated via another accurate indicator (100% correct). If you compare them to the chart, where the anaCurrentDayVWAPV43 was applied to MedianRenko bars, you will notice a significant difference. Or otherwise put, the VWAP + SD bands calculated from MedianRenko bars is completely false. This is simply a result of the garbage in -> garbage out problem.

                          Originally posted by ghost121 View Post
                          Hello,

                          This vwap strategy works very well in ut minute, hours or volume...

                          But the vwap strategy doesn't work very well with renko bars,

                          - with renko, this Is a never ending strategy... It is still running after targets without new trade's signal.
                          - the strategy takes more entry than i program...

                          It will be great if the strategy :

                          - could take profit or take loss. With no more entry than i expect.
                          - then stop until new trade's signal

                          Thank for your help !

                          Stef
                          Attached Files

                          Comment


                            #14
                            Originally posted by NinjaTrader_MichaelM View Post
                            Hello ghost121,

                            I have attached a screenshot of the results I got while testing the codes you provided. Could you please verify if my screenshot displays the issue or not? If not, could you please let me know the settings to use to replicate the issue?

                            Thank you in advance.
                            On this chart, the VWAP is shown as 1944.87. The correct value would have been 1951.13, see chart below. Again, the problem is fake input data from MedianRenko bars. The VWAP can only be calculated from bars where the bar open, represents the first tick of the bar period, bar high and low represent high and low of the period and bar close represents the last tick of the period.

                            Fancy bar types like Heikin-Ashi bars (lucky enough this was not a bar type for NinjaTrader 7) or all the different types of Renko bars (only exception is BetterRenko), come with fake open, fake high and fake low values.

                            Chart attached to document the problem.
                            Attached Files

                            Comment


                              #15
                              Hello !

                              I find an issue for the long and the short but not In the same strategy .


                              With this :


                              if( (twap.TWAPSeriesBullish[0] == true && twap.TWAPSeriesBullish[1] == false) )
                              // || (twap.TWAPSeriesBearish[0] == true && twap.TWAPSeriesBearish[1] == false)



                              I have not managed to do so yet, but I have not given up hope !

                              Stef

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Started by alifarahani, Today, 09:40 AM
                              6 responses
                              41 views
                              0 likes
                              Last Post alifarahani  
                              Working...
                              X