I have the following two problems. My system works with changes in the MA indicator. So the trigger order is made by using the Moving Average indicator. When the candle is moving across the Moving Average indicator, there will be an order. My problem is, how can I change the setting that quickly placed a new order, see code below. And in addition, I would also like to see this MA indicator pictured in my system. Does anyone know how?
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
if(TrailingStop_)dtrailing();
if(Tp_in_Money && TP_in_money<=money()) closeall();
//----
double MA_1O =iMA(Symbol(),0,Period_1,0,MODE_SMA,PRICE_OPEN ,1);
double MA_1C =iMA(Symbol(),0,Period_1,0,MODE_SMA,PRICE_CLOSE ,1);
double MA_2O =iMA(Symbol(),0,Period_2,0,MODE_SMA,PRICE_OPEN ,2);
double MA_2C =iMA(Symbol(),0,Period_2,0,MODE_SMA,PRICE_CLOSE ,2);
int signal;
if(MA_2O >MA_2C && MA_1O < MA_1C) signal=1;// open buy
if(MA_2O <MA_2C && MA_1O > MA_1C) signal=2;// open sell
if(Hour_trade()==1)
{
if(SL==0)slb=0;else slb=Ask-SL*pt;
if(SL==0)sls=0;else sls=Bid+SL*pt;
if(TP==0)tpb=0;else tpb=Ask+TP*pt;
if(TP==0)tps=0;else tps=Bid-TP*pt;
if(totalorder(0)<Max_order && Trade_buy && signal==1 && wt!=Time[0])
{
ticketb=OrderSend(Symbol(),OP_BUY,NR(Lots),Ask,3,slb,tpb,Name_EA,Magic,0,Blue);
if(ticketb>0) wt=Time[0];
}
if(totalorder(1)<Max_order && Trade_sell && signal==2 && wk!=Time[0])
{
tickets=OrderSend(Symbol(),OP_SELL,NR(Lots),Bid,3,sls,tps,Name_EA,Magic,0,Red);
if(tickets>0) wk=Time[0];
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
if(TrailingStop_)dtrailing();
if(Tp_in_Money && TP_in_money<=money()) closeall();
//----
double MA_1O =iMA(Symbol(),0,Period_1,0,MODE_SMA,PRICE_OPEN ,1);
double MA_1C =iMA(Symbol(),0,Period_1,0,MODE_SMA,PRICE_CLOSE ,1);
double MA_2O =iMA(Symbol(),0,Period_2,0,MODE_SMA,PRICE_OPEN ,2);
double MA_2C =iMA(Symbol(),0,Period_2,0,MODE_SMA,PRICE_CLOSE ,2);
int signal;
if(MA_2O >MA_2C && MA_1O < MA_1C) signal=1;// open buy
if(MA_2O <MA_2C && MA_1O > MA_1C) signal=2;// open sell
if(Hour_trade()==1)
{
if(SL==0)slb=0;else slb=Ask-SL*pt;
if(SL==0)sls=0;else sls=Bid+SL*pt;
if(TP==0)tpb=0;else tpb=Ask+TP*pt;
if(TP==0)tps=0;else tps=Bid-TP*pt;
if(totalorder(0)<Max_order && Trade_buy && signal==1 && wt!=Time[0])
{
ticketb=OrderSend(Symbol(),OP_BUY,NR(Lots),Ask,3,slb,tpb,Name_EA,Magic,0,Blue);
if(ticketb>0) wt=Time[0];
}
if(totalorder(1)<Max_order && Trade_sell && signal==2 && wk!=Time[0])
{
tickets=OrderSend(Symbol(),OP_SELL,NR(Lots),Bid,3,sls,tps,Name_EA,Magic,0,Red);
if(tickets>0) wk=Time[0];
}
}
//----
return(0);
}
Enter Signature