-
int movingaverageDefinition1 = iMA (_Symbol, PERIOD_H4, 10, 0, MODE_EMA, PRICE_CLOSE);
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020.03.08)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020.07.05)
How to call indicators in MQL5 - MQL5 Articles (2010) -
trade.Sell(0.01,NULL,Bid,0, (Bid-150 * _Point),NULL);
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).
-
Hi all,
This is my first attempt in a very long time at writing an EA. In summary my EA should execute a Buy/Sell if the 1- and 20 EMA has crossed in the previous 10 candles and at the point when the price crosses the 200 EMA. I've done my best so far but when back testing does not pick anything up. I'm sure I've done something stupid as I look at charts and can seethis trend happening a few times when adding indicators manually. Can anyone help please?
You have a global error - you create several indicator handles at each tick.
Remember: according to the MQL5 style, the indicator handle must be created ONCE and must be done in OnInit.
Example:
Creating an iMA indicator handle, getting indicator values

- 2020.03.05
- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
This is my first attempt in a very long time at writing an EA. In summary my EA should execute a Buy/Sell if the 1- and 20 EMA has crossed in the previous 10 candles and at the point when the price crosses the 200 EMA. I've done my best so far but when back testing does not pick anything up. I'm sure I've done something stupid as I look at charts and can seethis trend happening a few times when adding indicators manually. Can anyone help please?