general idea
bool MA7GreaterMA21; bool MA7SmallerMA21; if(MA7 > MA21) MA7GreaterMA21 = true; if (MA7 < MA21 && MA7GreaterMA21) { MA7GreaterMA21 = false; ticket = OrderSend(....); }
axbc: i want when MA7 < MA21 ==> sell and it is only a order until MA7 > MA21
void CloseAllOrders(int op){ ... void OpenAnOrder(int op){ ... : if(MA7 > MA21) CloseAllOrders(OP_SELL); else if(CountTrades() == 0) OpenAnOrder(OP_SELL);
int CountTrades() { int count=0; int trade; for(trade=OrdersTotal()-1;trade>=0;trade--) { if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)) { if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) { if(OrderType()==OP_SELL || OrderType()==OP_BUY) count++; } else //This else does not refer to OrderSelect // it refers to if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) Print("Error selecting orders in CountTrades() function : "+GetLastError()); } } return(count); // There is no closing } after return
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
i wirte function BUY SELL with MA7 and MA 21.
if MA7 < MA21 ==> sell
it worked but when have close ordered. ma7 < ma21 it is continue order
i want when MA7 < MA21 ==> sell and it is only a order until MA7 > MA21
who can help me. thanks