Stoploss doesn’t work on Backtest

Forums ProRealTime English forum ProBuilder support Stoploss doesn’t work on Backtest

Viewing 15 posts - 1 through 15 (of 31 total)
  • #167064

    Hi

    I am using PRT version V11.1-1.8.0_202

    I am backtesting a LONG strategy where I enter and BUY at a certain candle pattern. I SELL at another candle pattern and I put a Stoploss at the low. When I look at the backtest order list I see that it only exits when it shows the SELL candle pattern and it doesn’t exit at the Stop Loss.
    I have set it on the low and I also tried low1], but it doesn’t work.

    I have included the coding.

    Thanks, Marc

     

    #167066

    You cannot use a price to set a STOP LOSS, but a difference in price (even expressed in pips with pLOSS). You can deal with it with:

    but you should write that at line 6, because at line 16 it would change every candle.

    If you prefer using a price, you need to use a pending STOP order (this one at line 16 because it needs to be placed each candle), but must have been previously set at line 6;

     

     

    #167071

    Thanks Roberto

    #167208

    Hi Roberto,

    One more thing. I speak here only for a LONG entry.

    I have set my Stoploss like in the coding, and I want to move my Stop to the entry price (so neutral), when the Stochastic D>80 and when D[1]>D.
    But the way I coded this doesn’t work

     

    #167213

    In line 3 replace (D) with (K), it cannot be an average of itself.

    I also suggest to use GRAPH and GRAPHONPRICE make it easier to debug your code:

     

    #167223

    Oh, yes of course, to long behind the screens. I wrote it wrong and overlooked it all the time.

    Grazie

    #167229

    Hi Roberto,
    Thanks for your help in the first place. I really appreciate that.
    I added another move of my stoploss. It is still only for Long entry. I will add the short version later.
    LONG:
    Step 1: stoploss first at low,
    Step 2: then move stoploss to neutral when D>80 and D[1]>D,
    Step 3: then move stoploss to the lowest low within the stochastic cyclelow (D<50) after the cyle has finished, so after D crosses over 50 again.
    Step 1n and Step 2 work fine, But Step 3 doesn’t work. I programmed Step 3 originally as an indicator to show the lowest low within th cyclelow, But it shows me that lowest low even when the cycle is still going. Now for the backtest it has to use the low after the cycle has finished. And I tried different things, but that didn’t work out.

    I don’t know what GRAPH and GRAPHONPRICE actually do. I googled it and it is to mathematical for me as explained there.

     

    #167239

    GRAPH and GRAPHONRICE are istructions to debug your code. You will find a lot of information searching this forum and online documentation.

    As to your code, I’ll check it as soon as possible.

     

     

     

     

    #167276

    Try this one:

    I commented out your line 55, then added lines 34-44 and line 15.

    I did not remove any of your lines, in case you need them.

     

    #167277

    And is there a way in the coding that it only shows 1 decimal of the calculation when I use
    DRAWTEXT (“#calculation#”, barindex, low-0.003, Dialog, standard, 12)

    Or do I need to add something in that calculation?

    #167278

    Thanks a lot Roberto,
    Let me check tomorrow. I have worked behind the screens the whole day and I want to take the time to see what happens.
    Grazie mille.

    #167287

    Decimal places cannot be limited. You can round them, but you will still see the rightmost 0’s.

    Run this in ProBackTest and you will see the output in the variable window:

     

    #167324

    Hi Roberto, I checked you coding. It almost works. The stoploss of the first step, so the one at the BUY doesn’t work. For BUY It should put the stop on the low of the candle befor the entry candle (because there is not yet a low at the entry candle).I can’t put a finger on where it puts the stop.
    The step 2 and step 3 work. Great the moving of the SL with the Lower highs work.

    I checked it on the EURUSD 1 hour chart and at the 5th April 2021 at 2:00 you see what I mean> It is a great Profit, but it should have been stopped out by the SL of the low of the candle of  1:00.

    #167333

    You said “For BUY It should put the stop on the low of the candle befor the entry candle (because there is not yet a low at the entry candle)“. YES, there is a low, it’s the low of the setup candle, the one just closed. But if you want to use the previous low, then replace line 14 with:

    Lines 34 – 44 should be changed like this (so that it is calculated only AFTER entering a trade):

     

    #167335

    I understand the confusion. But I mean the one you described………….the low of the setup candle, the one just closed.

Viewing 15 posts - 1 through 15 (of 31 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login