Can anyone help me check my code?? Sell ordersend is not work but buy ordersend is work and no error is occur.

 
int start()
{
double FastMA,LastFastMA, LastSlowMA,SlowMA;
int X;
FastMA=iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,0);
LastFastMA=iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,1);
SlowMA=iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0);
LastSlowMA=iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1);

if((LastFastMA < LastSlowMA)&&(FastMA > SlowMA))
{
if(OrdersTotal()==0)
X=OrderSend(NULL,OP_BUY,0.10,Ask,0,Ask-300*Point,Bid+150*Point);
}

else if((LastFastMA > LastSlowMA)&&(FastMA < SlowMA))
{
if(OrdersTotal()==0)
X=OrderSend(NULL,OP_SELL,0.10,Bid,0,Bid-300*Point,Ask+150*Point);
}

return 0;
}
 
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  3. Be careful with NULL.

    1. On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
    2. Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
    3. Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    4. MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
    5. Cloud Protector Bug? - MQL4 programming forum 2020.07.25
 
Sksoon:

Please edit your post and use the code button (Alt+S) when pasting code.

EDIT your original post, please do not just post the code correctly in a new post.


Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

 
William Roeder:
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  3. Be careful with NULL.

    1. On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
    2. Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
    3. Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    4. MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
    5. Cloud Protector Bug? - MQL4 programming forum 2020.07.25

Thank you.

 
Keith Watford:

Please edit your post and use the code button (Alt+S) when pasting code.

EDIT your original post, please do not just post the code correctly in a new post.


Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 

Alright. Thank you

 
Sksoon: Alright. Thank you

You couldn't bother to edit your original post, even tho you were asked twice — people will remember.

 
I know the fault, but the code is not posted right
Reason: