I have a strange problem. The stop loss function does not work for me if i want to use a level from the chart. Example:
sl=dlow(1)
set stop loss sl
It simply does not work.
If i instead use a stop in points it works without problems. Example:
sl=100
set stop ploss sl
Can anybody help? Where is my mistake?
Hi,
Your sl variable in set stop ploss sl should be a distance in points not a level, if you stay it’s equal to dlow(1), you’re not giving it the distance (entryprice-dlow(1)) between your entry and dlow(1), you’re making the distance itself equal to dlow(1), which is likely to be too huge an amount in points to ever be trigered
Actually i do not. The second example with ploss (giving the distance to the stoploss in points) i have no problem. It is the first example where i want to give the stoploss as a level and not a distance that does not work.
Have you seen that in the first example i wrote “set stop loss” and not “set stop ploss”?
Or i ask different. How do i set a stop loss at a level and not a distance?
You can’t put a stoploss at a level. ploss is actually in points, while loss is in décimal format. For a 10 pips stoploss for EURUSD, you should do it like this:
set stop loss 0.0010
// or
set stop ploss 10
You’re right to notice I didn’t see the first was just loss rather than ploss, true I was only looking at the sl=dlow(1) vs the sl=100…
However, it doesn’t change the answer, because unless I’m mistaken both loss and ploss require a distance with their syntax, not a level… so set stop loss dlow(1) would still consider dlow(1) as a distance and even if it’s not with ploss it would need “entryprice-dlow(1)” rather than dlow(1)
Also Nicolas might correct me but I think I remember reading him once saying that ploss might disappear in a future PRT version and only loss would remain (to be confirmed by him, that’s just a vague memory I’m having here), which might explain why the documentation with “ploss” in the url now points to “loss” rather than “ploss”:
https://www.prorealcode.com/documentation/ploss/
I am not aware of another keyword with “set stop” that would set up a stop loss directly on a level without calculating the distance.
The only way to work directly with a level and not a distance would be to use a pending stop order, but need to be aware that these type of orders are valid only during one candle, so the code needs to be written in a such a way it would reset it again at each candle it’s needed
https://www.prorealcode.com/documentation/stop-pending/