//+------------------------------------------------------------------+ //| Turtle.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright "" #property link "" #define single_market 4 int magic = 123; double tickets[single_market]; double notional_account = 10000; int init () { notional_account = AccountBalance(); for (int i=0;i=1.2) { exponent = MathFloor((percent-100)/20.0); notional_account = MathPow(1.2,exponent)*notional_account; } return(notional_account); } double pips (string symbol, double amount) { if (StringFind(symbol,"JPY")!=-1) { return(amount/0.01); } else { return(amount/0.0001); } } double hh(int bars,int j=0) { double high = 0; for (int i=j+1;i<=bars;i++) { if (iHigh(Symbol(),PERIOD_D1,i)>high) { high = iHigh(Symbol(),PERIOD_D1,i); } } return(high); } double ll(int bars,int j=0) { double low = 0; for (int i=j+1;i<=bars;i++) { if (iLow(Symbol(),PERIOD_D1,i)high) { double N = iATR(Symbol(),PERIOD_D1,20,i); for (int j=i;j>=0;j--) { if (iLow(Symbol(),PERIOD_D1,j)high) { won = true; break; } if (iLow(Symbol(),PERIOD_D1,j)<(high-2*N)) { won = false; break; } } break; } else if (iLow(Symbol(),PERIOD_D1,i)=0;j--) { if (iHigh(Symbol(),PERIOD_D1,j)>hh(10,j) && iHigh(Symbol(),PERIOD_D1,j)(low+2*N)) { won = false; break; } } break; } } */ if (iHigh(Symbol(),PERIOD_D1,0)>hh(20) && won==false) { return("buy"); } else if (iLow(Symbol(),PERIOD_D1,0)hh(55)) { return("buy"); } else if (iLow(Symbol(),PERIOD_D1,0)0) { type = first_breakout(); system = "20"; if (type=="") { type = second_breakout(); system = "55"; } } } else if (type=="buy" && reset()==false) { int top_ticket =tickets[single_market-1]; int top_ticket_index =single_market-1; for (i=1;iOrderOpenPrice()+0.5*Nval) { tickets[top_ticket_index+1] = OrderSend(Symbol(),OP_BUY,unit_size,Ask,3,normalize(Ask-2*Nval),0,"",magic); for (i=0;ihh(10) && system=="20") || (iHigh(Symbol(),PERIOD_D1,0)>hh(20) && system=="55")) { for (i=0;i