Hello everyone,
i got this code from here: https://www.prorealcode.com/blog/learning/breakeven-code-automated-trading-strategy/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
defparam cumulateorders = false
startBreakeven = 30 //how much pips/points in gain to activate the breakeven function?
PointsToKeep = 5 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
c1 = RSI [ 14 ] crosses over 50
if c1 then
BUY 1 LOT AT MARKET
SET STOP PLOSS 50
endif
//reset the breakevenLevel when no trade are on market
IF NOT ONMARKET THEN
breakevenLevel= 0
ENDIF
// --- BUY SIDE ---
//test if the price have moved favourably of "startBreakeven" points already
IF LONGONMARKET AND close - tradeprice (1 )>= startBreakeven* pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice (1 )+ PointsToKeep* pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel> 0 THEN
SELL AT breakevenLevel STOP
ENDIF
// --- end of BUY SIDE ---
Here is my question:
Is it possible to to get the break even function started when no condition, for example “crossing RSI”, is met?
I want to open a position with an manually put pending limit- or stop-order. After the pending order turns into a open position
the break even function should start.
Would it work if i use this conditon?
c1 = LONGONMARKET
if c1 then
BUY 0 LOT AT MARKET
SET STOP PLOSS 0
endif
Thanks