Stoploss doesn’t work on Backtest

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

Viewing 15 posts - 16 through 30 (of 31 total)
  • #167336

    I think the error is in the lines 12 -15, where it doesn’t use the low of the setup candle, the one just closed as stoploss.

    #167337

    The setup candle IS the one just closed, when the strategy places an order.

    The order will be entered as soon as the new candle opens.

    LOW is the low of the closed candle (the candle prior to the one where PeroBackTest plots an arrow).

    LOW[1] is the candle prior to the closed candle (two candles prior to the plotted arrow).

     

     

    #167339

    Hi Roberto, yes, that is clear. But besides that….. the coding doesn’t put a Stop Loss at the LOW when I code LOW and also not at LOW[1] when I code LOW[1].

    So it doesn’t register the first Stop. See the attachent image.

     

    #167342

    I made a couple of changes, and it works now (I tested it on EurUsd, h1):

    GRAPHONPRICE will plot a black line on your chart to show where the Stop Loss is.

     

    #167346

    The Stoploss line is really good. Thank you for that. That is really helpfull. But there are still problems which weren’t there befor.

    The Stoploss at the Buy Entry at the Low works fine now. Also the moving from the Stoploss to neutral work. But now Stoploss based on the Higher Lows do’n’t work anymore. they did befor in the coding  04/16/2021 at 3:24 PM as you posted. But in that coding the Stoploss at the Buy Entry at the Low didn’t work. I attached an image with 2 trades with wrong exits.

    – The one on the left has the Buy on 8th October 2020. The Stoploss based on the Higher low is ignored and the Exit becomes neutral.
    – The one on the right has the Buy on te 19th of October where the Stoploss  moved to the third Higher Low. But he the trade didn’t exit when the wick crossed the Stoploss and it exits the second time it crosses the Stoploss.

    I can’t put a finger on what is going on here. You can take out the lines which are of no use. I have a copy of it all.

    #167347

    For soem reaosn the image doesn’t upload. It’s smaller then 2MB.

    #167368

    Try removing lines 39 and 49, then lines 11-13.

     

    #167406

    That doesn’t work either.
    Let me try something else and I come back to it.

    #167526

    Hi Roberto,

    I have just tested a simple  Buy Entry and Stoploss scenario to test what works and what doesn’t. The first BUY scenario is to Buy when ema7 crosses over sma50. It is only a Buy scenario to keep it simple.
    I only use 2 Steps to define my Stoploss2 Stoploss.
    Step 1: Stoploss at low after BUY
    Step 2: When OnMarket  and D crosses under 50 then move stoploss to the lowest low within the stochastic cyclelow (D<50) after the cycle has finished, so after D crosses over 50 again.

    The Problem is in the first Stoploss. It executes it after the close of the bar and on the close of the last bar instead of the Low defined in Step 1. (see image left trade)
    When the trade is able to develope into Step 2 and the Stoploss is moved at the Lowes Low of the Stoch cycle it does execute immediatelywhen price crosses below the new Stoploss, So that works. ( see image trade on the right)

    I don’t know where I make the mistake.

     

    #167557

    I see, the previous low can be higher so it is immediately hit.

    You have two alternative solutions:

    • you don’t take a trade when the previous low is higher than the current price (CLOSE)
    • you set a SL in a different way

     

    #167561

    “you don’t take a trade when the previous low is higher than the current price (CLOSE)” ——- In both trades this is not happening. So that cannot be the problem. You see that ENTRY is above the previous LOW.

    you set a SL in a different way” —————— That will cost me money. The strategy isn’t the problem. The coding doens’t work the way it is coded.

     

    #167565

    Why is the first one (left) wrong?

    It enters a long trade and the StopLoss, at the low of the previous trade, is hit immediately,

    What instrument, TF, date and time is  your pic, so I can replicate those trades?

     

    #167583

    I have included a new image with Time and even better commends. The white text balloons belong to  the left trade and the peach text balloons belong to the trade on the right.

    – EURUSED 1 hour chart
    The left trade has BUY ENTRY 31st of March 2012, 20:00
    The right BUY ENTRY 1st of April 2021, 10:00

    Thank you for having a look.

    #167584

    The image didn’t upload….I don’t know why that happens

    #167589

    Just to be clear. The Stoploss as coded in line 18 and 19 is wrong executed. When the trade developes further and the Stoploss is moved to the Higher Low as coded in lines 23 – 30 the execution works fine.

Viewing 15 posts - 16 through 30 (of 31 total)

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