#property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict input int TakeProfit=50; input int Stoploss=25; input int FastMA=5; input int FastMAShift=0; input int FastMAmethod=0; input int FastMAAppliedTo=0; input int SlowMA=21; input int SlowMAShift=0; input int SlowMAmethod=0; input int SlowMAAppliedTo=0; input double LotSize=0.01; input int MagicNumber = 1234; double Pips; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int init() { //------------- double ticksize= MarketInfo(Symbol(),MODE_TICKSIZE); if(ticksize == 0.00001 || Point == 0.001) Pips = ticksize*10; else Pips = ticksize ; //------------- return (0); } int deint() { //---------- //---------- return(0); } //+----------------------------------------------------------------+ //| Expert start function | //+----------------------------------------------------------------+ int Start() { // double PreviousFast= iMA(NULL,0,FastMA,FastMAShift,FastMAmethod,FastMAAppliedTo,2); double CurrentFast= iMA(NULL,0,FastMA,FastMAShift,FastMAmethod,FastMAAppliedTo,1); double PreviousSlow= iMA(NULL,0,SlowMA,SlowMAShift,SlowMAmethod,SlowMAAppliedTo,2); double CurrentSlow = iMA(NULL,0,SlowMA,SlowMAShift,SlowMAmethod,SlowMAAppliedTo,1); if(PreviousFast<PreviousSlow && CurrentFast>CurrentSlow) if(OrdersTotal()==0) OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,Ask-(Stoploss*Pips),Ask+(TakeProfit*Pips),NULL,MagicNumber,0,Green); if(PreviousFast>PreviousSlow && CurrentFast<CurrentSlow) if(OrdersTotal()==0) OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+(Stoploss*Pips),Bid-(TakeProfit*Pips),NULL,MagicNumber,0,Red); //--- return(0); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+
Variables are case sensitive and cannot have spaces. If you declare a variable starting with a capital letter, it has to be written with the same capital letter when you access it.
After an if() condition, do not put a ";"
if(you-condition-matches) { do-something-here; do-more-here; }
Something like that is correct.
It's | if(condition) aStatement // or ignoring white space. if(condition) aStatementThe semicolon is part of aStatement not part of the if. |
and braces is a statement | if(condition) { aStatement1; ... }
No semicolon after the closing brace. |
But you wrote | if(condition) /* DO NOTHING */; |
Same as | if(condition) {/* DO NOTHING */} |
Thanks very much After compling like on the top i get two warnings and when i apply this on chart and test it doesnot open any trade what could be reason.
'Ajay New Moving Average EA.mq4' Ajay New Moving Average EA.mq4 1 1
return value of 'OrderSend' should be checked Ajay New Moving Average EA.mq4 57 6
return value of 'OrderSend' should be checked Ajay New Moving Average EA.mq4 60 7
0 error(s), 2 warning(s) 1 3
Sir,
I tried my best and updated the code some wht but i am getting two errors which i am failing to understand and the same two warnings which are not opening any trade.
I have a deep heart request pls help me come out of this trouble.
Your code:
void CheckForMaTrade(); { double PreviousFast= iMA(NULL,0,FastMA,FastMAShift,FastMAmethod,FastMAAppliedTo,2); double CurrentFast= iMA(NULL,0,FastMA,FastMAShift,FastMAmethod,FastMAAppliedTo,1); double PreviousSlow= iMA(NULL,0,SlowMA,SlowMAShift,SlowMAmethod,SlowMAAppliedTo,2); double CurrentSlow = iMA(NULL,0,SlowMA,SlowMAShift,SlowMAmethod,SlowMAAppliedTo,1); if(PreviousFast<PreviousSlow && CurrentFast>CurrentSlow)OrderEntry(0); if(PreviousFast>PreviousSlow && CurrentFast<CurrentSlow)OrderEntry(1); }
Correction (removal of semicolon on first line)
void CheckForMaTrade() { double PreviousFast= iMA(NULL,0,FastMA,FastMAShift,FastMAmethod,FastMAAppliedTo,2); double CurrentFast= iMA(NULL,0,FastMA,FastMAShift,FastMAmethod,FastMAAppliedTo,1); double PreviousSlow= iMA(NULL,0,SlowMA,SlowMAShift,SlowMAmethod,SlowMAAppliedTo,2); double CurrentSlow = iMA(NULL,0,SlowMA,SlowMAShift,SlowMAmethod,SlowMAAppliedTo,1); if(PreviousFast<PreviousSlow && CurrentFast>CurrentSlow)OrderEntry(0); if(PreviousFast>PreviousSlow && CurrentFast<CurrentSlow)OrderEntry(1); }
You might want to look here about the other warnings
I am sorry i tried to to do that after reading every thing but i could not suceed in writing and compling,
i request if you could do this for me.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I request if some one help me in compiling and making error free for attached code,
This is my first time to open the programe file and write code from seen video's.
Ajay