Help create following:
TrailStart = 0.1% //0.1 Start trailing when 0,1% in profit
Trailing distance = 0.04% //0.04 % distance from candleclose
Hi Roberto.
I have searched and couldn’t find what I was searching for.
Found how to start trail when 0.1% in profit, but cannot find how to keep the 0.04% distance from highest closed candle.
For long
0.04% distance from highest closed candle.
For short
0.04% distance from lowest closed candle.
Highest compared to what?
Highest closed candle after trailing was started.
Long: Start trailing when 0,1% in profit. Efter this sl moves (trails) with 0,04 % distance to highest price/bar/candle
Short: Start trailing when 0,1% in profit. Efter this sl moves (trails) with 0,04 % distance to lowest price/bar/candle
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = ExponentialAverage[50](high)
c1 = (low CROSSES OVER indicator1)
Timeframe(4h)
filter=RSI[14](close)
timeframe(default)
IF c1 AND filter<70 THEN
BUY 1 CONTRACT AT MARKET
SET STOP %LOSS 0.05
ENDIF
//Help with trail
//TrailStart = 0.1% //0.1 Start trailing when 0,1% in profit
//Trailing distance = 0.04% //0.04 stoploss resets and is placed 0,04 % distance to highest price/bar/candle
//Long: Start trailing when 0,1% in profit. Efter this sl moves (trails) with 0,04 % distance to highest price/bar/candle
//Short: Start trailing when 0,1% in profit. Efter this sl moves (trails) with 0,04 % distance to lowest price/bar/candle
maybe it is easier to explain with picture
What are the rules why both the green and red rectangle are drawn there?
Which is the highest candle you want to refer to?
0.04% needs to be calculated from which point? up to… ?
Do u think this is possible to code Roberto 🙂
There you go:
IF Not OnMarket THEN
MyStop = 0
Entry = 0
ENDIF
IF close crosses over average[100,0](close) AND Not OnMarket THEN
BUY 1 CONTRACT AT MARKET
SET STOP %LOSS 1.0
Entry = close
ENDIF
TP = 1.0 / 100 //1.0%
TrailStart = 0.6 / 100 //0.6%
Trailingdistance = 0.2 / 100 //0.2%
IF OnMarket AND Not OnMarket[1] THEN
Entry = TradePrice
ENDIF
IF OnMarket THEN
IF MyStop = 0 THEN
IF close >= (Entry + (Entry * TrailStart)) THEN
MyStop = Entry + (Entry * Trailingdistance)
ENDIF
ELSE
IF close >= (MyStop + (Entry * TP)) THEN
MyStop = MyStop + (Entry * TP)
ENDIF
ENDIF
IF MyStop > 0 THEN
SELL AT MyStop STOP
ENDIF
ENDIF
graphonprice Entry
graphonprice Entry + (Entry * TP) coloured(0,0,255,255)
graphonprice MyStop coloured(255,0,0,255)
I tested it on DAX, 15min.
I changed percentages a little bit to ber able to test it better.