How to use other price types (Median/Typical/etc) in developing a custom indicator

 

Hello, OnCalculate only produce open/high/low/close. How can I use use other prices types? Like original MT4 indicators.

I nead a clue, or reference to an existing indicator in codebase which I can get idea from it

Thanks


int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
        MyBuffer=SimpleMAOnBuffer(
Here I want to apply Median/Typical/etc instead of close[]);
   
  }
 
You will need to calculate these values yourself.

Median is (High+Low)/2
Typical is (High+Low+Close)/3
Weighted is either (High+Low+Close+Close)/4
Or (O+H+L+C)/4.

Weighted is ambiguous in documentation, you can find both in documentation and it is not clear which one is used (to me).



To be able to use applied to, you will need to use the alternative OnCalculate signature.



 

Dominik Egert:

To be able to use applied to, you will need to use the alternative OnCalculate signature.



Thank you. Yes, this is the solution! but only in MQL5. I need it in MQL4

 
Farzad Sadeghishahrestanak :

Thank you. Yes, this is the solution! but only in MQL5. I need it in MQL4

You write on the MQL5 forum. You write in one of the main sections of MQL5 - naturally, you get answers for MQL5.

All questions about the old terminal are discussed ONLY in ONE, SPECIAL section of the forum: MQL4 and MetaTrader 4

I will transfer your topic to this section.

 
Farzad SadeghishahrestanakHow can I use use other prices types? Like original MT4 indicators.I nead a clue, or reference to an existing indicator in codebase which I can get idea from it
  1. There are many examples in the codebase.
  2. They all have
    1. An input specifying which price to use
    2. Code to either calculate the price explicitly, or call iMA of period 1, passing the input.