![Stochastic Oscillator - Oscillators - MetaTrader 5 Help Stochastic Oscillator - Oscillators - MetaTrader 5 Help](https://c.mql5.com/36/50/stochastic-oscillator-oscillators.png)
- www.metatrader5.com
- Universal MA Cross EA
- Coding help
- Can someone help convert my custom indicator
Please insert the code correctly: when editing a message, press the button and paste your code into the pop-up window
#property version "1.00" #include <Trade\Trade.mqh> CTrade trade; #define Ask SymbolInfoDouble(Symbol(),SYMBOL_ASK) #define Bid SymbolInfoDouble(Symbol(),SYMBOL_BID) void OnTick() { //INDICATORS double EMA14 = iMA(NULL,PERIOD_M1,14,0,MODE_EMA,PRICE_CLOSE); // EXPOTNTIAL MOVING AVERAGE PERIOD 14 double SMV1 = iMA(NULL,PERIOD_M1,1,0,MODE_SMA,PRICE_CLOSE); //SIMPLE MOVING AVERAGE 1 double SMV3 = iMA(NULL,PERIOD_M1,3,0,MODE_SMA,PRICE_CLOSE); //SIMPLE MOVING AVERAGE 3 double SMV8 = iMA(NULL,PERIOD_M1,8,0,MODE_SMA,PRICE_CLOSE); //SIMPLE MOVING AVERAGE 8 //stochastic setting// double Stocha = iStochastic(NULL,PERIOD_M1,1,1,1,MODE_EMA,STO_CLOSECLOSE); //stochastich period 1 //_________________________________________________________________________// if (PositionsTotal() <= 2) while (Ask > EMA14) && (SMV1 && SMV3 && SMV8 == Stocha)) { trade.Buy(0.20,NULL,Ask,0,Ask+100 * _Point,NULL); } }
Please insert the code correctly: when editing a message, press the button and paste your code into the pop-up window
You have made a gross mistake. In MQL5, you need to create an indicator handle (this is done once in OnInit), and the data is received using CopyBuffer.
![How to start with MQL5 How to start with MQL5](https://c.mql5.com/36/50/how-to-start-with-mql5__10.jpg)
- 2020.03.05
- www.mql5.com
double EMA14 = iMA(NULL,PERIOD_M1,14,0,MODE_EMA,PRICE_CLOSE); // EXPOTNTIAL MOVING AVERAGE PERIOD 14
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)
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)
![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