how to code a ea with ma on stochastic indicator

 
Good Morning Please I would like to know what code to type for putting a MA on Stochastic indicator. I want a MA that will be in the second indicator windows with the stochastic indicator. And when the MA will crossover and close below the sell zone or the buy zone of the stochastic indicator it will be either a sell or buy. I don't know how to code it. I need help please. Here a screenshot of what I want to code
Stochastic Oscillator - Oscillators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
The Stochastic Oscillator Technical Indicator compares where a security’s price closed relative to its price range over a given time period. The...
Files:
exapmle.PNG  6 kb
 
Assamoua Samuel Esse what code to type for putting a MA
iMAOnArray Migrating from MQL4 to MQL5 - MQL5 Articles № 17
 
I don't understand please may you explain to me ?
 

You want a stochastic indicator which alerts at those areas, so you need something just like this:

https://www.mql5.com/en/code/15850


Then you need to use iCustom to made the custom indicator work in an EA, but it's not that straightforward how to do this, so I recommend watching this to know how to make this kind of EA
https://www.youtube.com/watch?v=CYpFHJbcXv4

iStochKomposterAlert
iStochKomposterAlert
  • www.mql5.com
Semaphore arrow signal indicator based on the classic Stochastic oscillator leaving the overbought and oversold areas, which features alerts, sending emails and push-notifications to mobile devices.
 
Conor Mcnamara #:

You want a stochastic indicator which alerts at those areas, so you need something just like this:

https://www.mql5.com/en/code/15850


Then you need to use iCustom to made the custom indicator work in an EA, but it's not that straightforward how to do this, so I recommend watching this to know how to make this kind of EA
https://www.youtube.com/watch?v=CYpFHJbcXv4

Ok thank you but it is not what I want. I don't know if I explained correctly but what I am searching for is to apply a moving average on the stochastic indicator in the same windows firstly. Secondly instead of use the Kperiod and the Dperiod of the stochastic crossover on the 80/20 lines to give signal as the classic use of stochastic indicator, I will use the moving average crossover the 80/20 line of this stochastic. William Roeder told me to use iMAonarray to calculate the MA based on the stochastic data which is specify to MQL4. I am using MQL5 and I don't know how to do that.
 
Assamoua Samuel Esse #:
Ok thank you but it is not what I want. I don't know if I explained correctly but what I am searching for is to apply a moving average on the stochastic indicator in the same windows firstly. Secondly instead of use the Kperiod and the Dperiod of the stochastic crossover on the 80/20 lines to give signal as the classic use of stochastic indicator, I will use the moving average crossover the 80/20 line of this stochastic. William Roeder told me to use iMAonarray to calculate the MA based on the stochastic data which is specify to MQL4. I am using MQL5 and I don't know how to do that.

in iStochastic there is already a MA smoothing parameter. Is that what you want with the MA? or why do you want to apply an MA to it?

If you want nothing more than a MA with the 20 and 80 levels, then that's not stochastic anymore, and l could make that with iMA
 
Conor Mcnamara #:

in iStochastic there is already a MA smoothing parameter. Is that what you want with the MA? or why do you want to apply an MA to it?

If you want nothing more than a MA with the 20 and 80 levels, then that's not stochastic anymore, and l could make that with iMA
Ok thank you so it's just a MA with the 20 and 80 levels
 
Assamoua Samuel Esse #:
Ok thank you so it's just a MA with the 20 and 80 levels

I tried to think creatively about that, but the reality of a MA is that it keeps moving up and down wherever the market goes. It's not an oscillator, there's no such thing as a level on an MA. I think you're simply looking for something like an RSI?

I'm trying to make an MA right now that creates levels based on a percentage from the max and min MA level found over a period of bars

 

Maybe you don't need to code at all:


 
Ivan Titov #:

Maybe you don't need to code at all:


Haha, visually that seems like a fine approach, but I guess he wants it for use in an EA and this won't provide the signals of when the ma crosses the horizontal level. The stochastic values are way different.

MA is a trend indicator afterall and not an oscillator. I coded something last night which assigns fleeting and dynamic levels to an MA, and puts the price of the levels into 2 extra buffers, which makes it possible to be used in an EA. I'll publish the code for free soon


 
Conor Mcnamara #:
he wants it for use in an EA and this won't provide the signals of when the ma crosses the horizontal level

Just get the indicator value using ChartIndicatorGet() and CopyBuffer() and then compare it with your level in the EA.

Conor Mcnamara #:
MA is a trend indicator afterall and not an oscillator.

Until you put it in the oscillator window as above.

Reason: