this is my first attempt at a working EA hopefully this is the last issue before it is fully functional, if anyone could help with this it'd be much appreciated
You have to select an order before using OrderTicket()
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
void OnTick()
{
int res;
double MA = iCustom(NULL,0,rsimatest,rsimatest_RSI,0);
//open sell
if(MA<50 && OrdersTotal() <1)
{
res = OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,"",BIGMACMATT,0,Red);
return;
}
//open buy
if(MA>50 && OrdersTotal() <1)
{
res= OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,"",BIGMACMATT,0,Blue);
return;
}
//close buy
if(OrdersTotal()>0 && MA>50)
{
if (!OrderClose(OrderTicket(),OrderLots(),Ask,3,Blue)){
Print("OrderModify error ",GetLastError());}
return;
}
//close sell
if(OrdersTotal()>0 && MA<50)
{
if (!OrderClose(OrderTicket(),OrderLots(),Bid,3,Red)){
Print("OrderModify error ",GetLastError());}
return;
}
return;
}