Trend Trading.Follow thirty symbols which include forex,commodity,stock index,bond,encrypted currency.MT5 version here.
the EA open position when break period(global_break_period) attach.the close stop set at price add or minus atr(global_atr_period)*global_loss_close.the immediate stop set at price add or minus atr(global_atr_period)*global_loss_ime.
also see the EA to calculate minimum cash need for run trend trading.
The output log of EA:
1. Dir:1 ImeStopPrice:123.45678 CloseStopPrice:123.45678 RefProfit:100.2
1 mean buy,-1 mean sell. ImeStopPrice:immediate stop price. CloseStopPrice:close stop price. RefProfit:reference profit
2. Warning:should has position,but no real position.
the log means global_init_before > 0,see previous global_init_before bars,and open position at some bar,so should has position theory,but no real position.
3. Warning:Position should open at time:2019-1-1,please adjust manually.
the log means the symbol has real position.we assume the real position open at time A,the current time is D,B C is the time between A and D,the position should close at time B because of stop,then open position at time C(break happen again),so the real position open time is not same as the time C,the EA'll output this log.
4. Has position.
5. No position.
6. !Error:should no position,but has real position,please close position manually.
the log means the symbol has real position.we assume the real position open at time A,the current time is D,but the position should close because of stop,and no break again until current time D.so the EA'll output this log.
global_break_period = 105
global_atr_period = 14
global_loss_close = 3.0
global_loss_ime = 4.0
global_risk = 0.015
global_init_before = 0
if global_init_before > 0,mean see the previous global_init_before bar,simulate the trend on these bars(check break to open position,update stop),to keep the trend as before.if the symbol has position before,the EA'll ignore this parameter and simulate begin the open time of position.