I am new to coding and expert advisors.
I was following along with a YouTube video just to learn, this EA is supposed to open a position every time there is an SMA cross for a quick scalp.
I noticed many times there are many times the SMAs cross but no position is opened.
Any ideas why?
Check your Journal and Expert tab. There might be some errors to give you clues as to reason. But 1 guess could be that your prices need to be normalised, or that your tp and sl might not be far enuf away from open price, ie you are using bid price for both open and close prices, but you need to use ask price for opening buy trades, and to close buy trades, you use bid. To open sell trades, you use bid, and to close sell trades, ask price.
int MAdef1 = iMA (_Symbol,_Period,9,0,MODE_SMA,PRICE_CLOSE); int MAdef2 = iMA (_Symbol,_Period,14,0,MODE_SMA,PRICE_CLOSE);
These lines go into OnInit and remove the int at beginning, instead put
int MAdef1, MAdef2;
on new line below CTrade
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 am new to coding and expert advisors.
I was following along with a YouTube video just to learn, this EA is supposed to open a position every time there is an SMA cross for a quick scalp.
I noticed many times there are many times the SMAs cross but no position is opened.
Any ideas why?