Hello, is it possible to combine a breakeven stop with an RSI value? If the price is above / below the purchase price and the RSI12 closes above / below 70/30, the stop should be drawn to breakeven. In %. Could someone code that, please?
There you go:
IF Not OnMarket THEN
ExitrPrice = 0
ENDIF
MyRSI = Rsi[12](close)
IF (LongOnMarket AND close > PositionPrice AND MyRSI > 70) OR (ShortOnMarket AND close < PositionPrice AND MyRSI < 30) THEN
ExitPrice = PositionPrice
ENDIF
IF ExitPrice THEN
SELL AT ExitPrice STOP
EXITSHORT AT ExitPrice STOP
ENDIF
I can’t understand what you mean by “in %“. Breakeven is the entry price.
Ah, my mistake. Then I said, for example: Breakeven + 5 * Pipsize
But in percent?
Ok, there you go:
PointsToKeep = 5 * PipSize //save 5 pips beyond breakeven
IF Not OnMarket THEN
ExitPrice = 0
ENDIF
MyRSI = Rsi[12](close)
IF LongOnMarket AND close > PositionPrice AND MyRSI > 70 THEN
ExitPrice = PositionPrice + PointsToKeep
ELSIF ShortOnMarket AND close < PositionPrice AND MyRSI < 30 THEN
ExitPrice = PositionPrice - PointsToKeep
ENDIF
IF ExitPrice THEN
SELL AT ExitPrice STOP
EXITSHORT AT ExitPrice STOP
ENDIF
If you want to use a %, you can replace the first line with the following:
MyFormula = PositionPrice //or Range, or abs(close - PositionPrice), etc...
PointsToKeep = MyFormula / 100 * 0.05 //0.05%
you can use any formula of your choice in line 1.
Thanks Roberto, you are the best.