작업 종료됨
![](https://c.mql5.com/i/avatar/avatar_na2.png)
![](https://c.mql5.com/i/avatar/avatar_na2.png)
명시
Void OnTick()
{
// Calculate ema20 for last 3 closed candles
double ema20 = iMA(NULL,0,20,0,1,PRICE_CLOSE,1);
double ema20_1 = iMA(NULL,0,20,0,1,PRICE_CLOSE,2);
double ema20_2 = iMA(NULL,0,20,0,1,PRICE_CLOSE,3);
//sell short order
if((ema20>ema20_1) && (ema20_1>ema20_2))
if(OrdersTotal()==0)
OrderSend(NULL,OP_SELL,0.01,Bid,3,Ask+50*points, NULL, NULL, 0,0,Red) <:p><:p>
//close short
if(OrdersTotal()==1) && (OrderType()==OR_SELL)
if ema20 < ema20_1 && ema20_1 < ema20_2
OrderSend(NULL,OP_BUY,0.01,Ask,100, NULL, NULL, NULL, 0,0,Green)
//buy long order
if((ema20<ema20_1) && (ema20_1<ema20_2))
if(OrdersTotal()==0)
OrderSend(NULL,OP_BUY,0.01,Ask,3,Bid-50*points, NULL, NULL, 0 ,0,Green) <:p><:p>
//close long
if(OrdersTotal()==1 && (OrderType()==OR_BUY)
if ema20 > ema20[1] && ema20[1] > ema20[2]
OrderSend(NULL,OP_SELL,0.01,Bid,10, NULL, NULL, NULL, 0,0,Red)
}
All this was meant to do is :
Sell to open .01 position when last ema20 > ema20[1] and ema20[1]>ema20[2] with a 50 pip stop-loss
Buy to cover when last ema20 < ema20[1] and ema20[1]< ema20[2]
Buy to open .01 position when last ema20 < ema20[1] and ema20[1]<ema20[2] with a 50 pip stop-loss
Sell to open when last ema20 > ema20[1] and ema20[1]> ema20[2]
Yes, this is a nonsense program – just a learning exercise so I can change in the future.