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

Renko strategy exit bar calculation bug?

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

    Renko strategy exit bar calculation bug?

    Hello everyone.

    So I've been building a ton of strategies on the Renko chart type this last month.
    I've recently see anomalies on backtesting and have decided to inquire about it.

    Long story short, the trade calculation on certain trades are 1 brick out:

    Strategy: Enter trade with 1 brick up or down and exit 1 brick in negative direction.

    As you can see below:
    White bar: Trade entry
    Black bar: Trade exit
    Green dot: Exactly where the trade got exited


    Now look at this example, and it's all over my 2 year backtest.


    Code is triggering at the right place, hence the black bar and the dot but the line is being drawn incorrectly and thus 1 brick(20 pips in this case) too much.

    This resulting in my losses being 20 pips less and some winners also pips more.

    Thanks,
    Phillip

    #2
    I found some more, and 1 really strange 1.

    Comment


      #3
      Hello dreampunchboy,

      Are you asking why an order is placed at the opening of the bar after the submission bar has fully closed?

      This because the trigger bar fully closed and the order was placed after it was fully closed. Thus it is placed just as the

      Please see the following forum post that describes this.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thanks for the quick reply.

        No that is not all what I'm asking. I'm 100% aware that OnBarUpdate() is the next bar.
        Maybe I can illustrate the problem like this:



        Here is my code on that bar:


        Code:
        ExitLong();
        Draw.Dot(this, ElementName("gooddot"), false, 0, Close[0], Brushes.Green);
        BarBrush = Brushes.Black;
        As you can see the dot, the black bar and the exit is on the same bar.
        But the green bar is still going on and only closing on the next bar. (20 pips further)
        This is only occurring 20% of the time.

        Where it should have ended (and does 80% of the time)


        My condition for exiting is very simple:

        Code:
        if (Open[0] > Close[0])

        Comment


          #5
          Hello dreampunchboy,

          I'm not quite understanding.

          You mention "As you can see the dot, the black bar and the exit is on the same bar."

          I'm not able to see this in the screenshots you have provided.

          In the screenshots you have provided the exit is on the bar after the black bar.

          Can you further detail your meaning by this?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            So what I mean by that is related to the code.
            The ExitLong(); is on the close of the Black/Red bar but as you can see it's closing on the Open[0] or High[0] and not the Close[0] of that bar.

            It's almost like the bar is in reverse.

            Comment


              #7
              Hello dreampunchboy,

              I'm expecting a market order placed after a bar has closed to fill at the open of the next bar.

              Is this not what is happening?

              From the screenshots you have provided, this is what it looks like is happening which would be expected.

              Can you further detail why are you expecting a market order to fill at the close of the black bar? Do you have intra-bar granularity added?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by dreampunchboy View Post
                So what I mean by that is related to the code.
                The ExitLong(); is on the close of the Black/Red bar but as you can see it's closing on the Open[0] or High[0] and not the Close[0] of that bar.

                It's almost like the bar is in reverse.

                If you run this strategy in market replay or live, is the problem still there?
                RJay
                NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                Comment


                  #9
                  La barra roja solo aparece cuando el precio en un pasado estaba en el rango, por lo tanto para que el sistema haga lo que quieras tendria que retroceder el tiempo, lo que debes hacer es asignar un control con barras mas pequeñas.

                  The red bar only appears when the price in the past was in the range, so for the system to do what you want it would have to go back in time, what you should do is assign a control with smaller bars.
                  THE system only works when a new bar appears, that is, when the price has already deviated from the size of the Renko bar.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NRITV, Today, 01:15 PM
                  2 responses
                  8 views
                  0 likes
                  Last Post NRITV
                  by NRITV
                   
                  Started by frankthearm, Today, 09:08 AM
                  7 responses
                  31 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by maybeimnotrader, Yesterday, 05:46 PM
                  5 responses
                  26 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by quantismo, Yesterday, 05:13 PM
                  2 responses
                  19 views
                  0 likes
                  Last Post quantismo  
                  Started by adeelshahzad, Today, 03:54 AM
                  5 responses
                  33 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Working...
                  X