Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy with renko..problem in backtest

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

    Strategy with renko..problem in backtest

    (I USE IN CHART UNIRENKO As TYPE OF CANDLE)

    hi, i want to write a simpleTs with Renko...

    Code:
    		if (CrossAbove(Close,Open,1))
    			    EnterLong();
    				  else if (CrossBelow(Close,Open,1)) EnterShort();
    See pics



    The strategy enters the second red candle.

    The problem :

    if i backt it in the strategy ....it Sign long to Open next candle renko...But it's a Unirenko and the open is in the middle of previus candle....

    I want to set the correct strategy at the end of the candle of signal(the first candle red)..
    In this way the price in the strategy is correct..

    How i do it? thank you

    #2
    Remember that backtesting is always CalulateOnBarClose = true, and your signals will fill at the open of the next bar.

    I am not sure exactly how to achieve what you are looking for with this custom unirenko bar type, but I do know there is quite a bit of discussion around similar problems since renko bars use 'virtual' prices for open, high low, close, which ends up with discrepancies in your backtest results.

    If you have not yet, I'd recommend you read through some of these other discussions to see if information here will help you achieve your goal, or may help explain why you are seeing the results you are seeing:

    MatthewNinjaTrader Product Management

    Comment


      #3
      If i code this (with candle Unirenko) i get it

      Code:
       if (CrossAbove(Close,Open,1))
           
             EnterLong();
           
            else if (CrossBelow(Close,Open,1)) EnterShort();
      https://gyazo.com/5fd8b2de706506a0adf31ea261b53e96

      but the problem is that start in the middle of next candle (beacuse is a virtual candle)

      i want to get it :



      Now i try to code strategy with Unirenko and to make more true test I have given my strategy this way

      i code this :


      if (CrossAbove(Close,Open,1))
      EnterLongStopLimit(Close[0]+1,Close[0]);
      else if (CrossBelow(Close,Open,1))
      EnterShortStopLimit(Close[0]-1,Close[0]);
      (Syntax
      EnterShortStopLimit(double limitPrice, double stopPrice)

      In this way, I will not start from the next virtual open candle but from previous close..

      But when i see result ....i'see problem..i see screen empty

      where is the mistake?
      Last edited by esignal; 02-15-2016, 05:07 AM.

      Comment


        #4
        Excuse me Mattew....i read your link about backtesting but i don't underestand some things

        you say :

        Originally posted by NinjaTrader_Matthew View Post
        Remember that backtesting is always CalulateOnBarClose = true, and your signals will fill at the open of the next bar.
        but i see other :



        i know that are virtual candles but the backtest should follow the value of the candle,
        then the signal should start at the close of the candle at 9201

        Comment


          #5
          Originally posted by esignal View Post
          Excuse me Mattew....i read your link about backtesting but i don't underestand some things

          you say :



          but i see other :



          i know that are virtual candles but the backtest should follow the value of the candle,
          then the signal should start at the close of the candle at 9201
          You coded a reversal. Price reversal enters a new order at the same price as the previous trade's exit. In Backtest, that is identically true, even if in realtime it may not always be true.

          Comment


            #6
            Excuse me..i don't understand...

            i modify code in :

            if (CrossAbove(Close,Open,1))

            EnterLong();

            else if (CrossBelow(Close,Open,1)) ExitLong();
            Ok..now it not reversal but the result is the same



            The signal not long al price of close candle but the open next candle....

            Comment


              #7
              Originally posted by esignal View Post
              Excuse me..i don't understand...

              i modify code in :

              Ok..now it not reversal but the result is the same



              The signal not long al price of close candle but the open next candle....
              Not the same thing. Your first picture was code to reverse. I responded to that. This is a different matter, and it is because NT opens on the open of the next bar, which makes sense because the entry condition is not complete until the previous bar actually closes; at which time, the new Open will also have been triggered. A nuance, but an important one to understand.

              If you want to enter at a specific price, then state so. A market order, which is what you have used, will enter at where it will. You have no control over that price. A market order translates to: "give me my entry at whatever price the market is trading". That means that you have given up control of the entry price. You cannot then complain if it is not where you want it to be.

              However, it goes a little deeper than that because you are using a synthetic bar, with a fake open that is below the previous Close. That means that even a limit order will also fill at the fake Open of the bar. For backtest purposes, you can use the slippage with a limit order, to force the entry to a specific price that matches the Close of the previous bar. Use a slippage value of half the range of the bar.
              Last edited by koganam; 02-16-2016, 06:08 PM.

              Comment


                #8
                For backtest purposes, you can use the slippage with a limit order, to force the entry to a specific price that matches the Close of the previous bar. Use a slippage value of half the range of the bar.
                How can i do it?

                i try it

                Code:
                
                if (CrossAbove(Close,Open,1))
                EnterLongStopLimit(Close[0]+1,Close[0]); 
                else if (CrossBelow(Close,Open,1)) 
                EnterShortStopLimit(Close[0]-1,Close[0]);
                but is not correct....it show a empty screen


                thanks

                Comment


                  #9
                  Originally posted by esignal View Post
                  How can i do it?

                  i try it

                  Code:
                  
                  if (CrossAbove(Close,Open,1))
                  EnterLongStopLimit(Close[0]+1,Close[0]); 
                  else if (CrossBelow(Close,Open,1)) 
                  EnterShortStopLimit(Close[0]-1,Close[0]);
                  but is not correct....it show a empty screen


                  thanks
                  What is the error in your log, if any?

                  What instrument are you on? An offset of "1" point can be relatively pretty large, relative to the base base.

                  You specify slippage as in the picture below. Come to think of it, using EnterLongStop() may be able to do it without needing to handle slippage, but slippage is something of which you should be aware anyway.
                  Attached Files

                  Comment


                    #10
                    [QUOTE=koganam;448817]What is the error in your log, if any?

                    Comment


                      #11
                      [QUOTE=esignal;448961]
                      Originally posted by koganam View Post
                      What is the error in your log, if any?

                      https://gyazo.com/bcacb7fd595246c628f25236c27777d8
                      Not sure to what you are linking. That is a gyazo error page.

                      Comment


                        #12
                        [IMG]



                        [/IMG]


                        it say: A SellShort order placed at 12/02/2016 09:24 has been ignored sinche the stop price is greather than ...
                        Attached Files
                        Last edited by esignal; 02-18-2016, 02:44 AM.

                        Comment


                          #13
                          Originally posted by esignal View Post
                          [IMG]



                          [/IMG]


                          it say: A SellShort order placed at 12/02/2016 09:24 has been ignored sinche the stop price is greather than ...
                          That is evidently a historical order, coming immediately after the strategy is started. The real issue is simply one of where your orders will be placed.

                          Are you saying that when you use StopLimit entry orders, no trades are shown at all?

                          Comment


                            #14
                            i not see trades in the chart



                            Chart is empty

                            My setting Strategies :

                            Last edited by esignal; 02-18-2016, 09:58 AM.

                            Comment


                              #15
                              Originally posted by esignal View Post
                              That is not on any kind of Renko bars. Given that you have shown 15m bars, let me whip up a quick and dirty strategy to see what the problem would seem to be.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by traderqz, Today, 09:44 AM
                              2 responses
                              4 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by stafe, 04-15-2024, 08:34 PM
                              8 responses
                              40 views
                              0 likes
                              Last Post stafe
                              by stafe
                               
                              Started by rocketman7, Today, 09:41 AM
                              2 responses
                              5 views
                              0 likes
                              Last Post rocketman7  
                              Started by rocketman7, Today, 02:12 AM
                              7 responses
                              31 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by guillembm, Yesterday, 11:25 AM
                              3 responses
                              16 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X