Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
I am trying to find out how to calculate the highest high and lowest low values for an indicator over a period in MQL4.
For example:
Using amibroker (similar sor metastock) the formula would be as below to calculate the highest high of the 30 day moving average over the last 10 periods.
Highest high = HHV(MA(Close,30),10 )
I have tried using ArrayMaximum() but this returns the position and not the value of the highest value.
Also Highest() does not work with indicators.
I know how to make a code to draw a trendline between 2 points. (object_create and object_move). But I need to know howto obtain the value of the high an low. Then I will use the data to fill the draw points.
I´d make some experimets with the zigzag indicator and the mod from coderguru but without succes.
int Highest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)
Returns the shift of the maximum value over a specific number of periods depending on type.
Do not forget that this function return the index of the bar, not a value, so look at the sample :
Sample:
double val;
// calculating the highest value in the range from 5 element to 25 element
// indicator charts symbol and indicator charts time frame
val=High[Highest(NULL,0,MODE_HIGH,20,4)];
I think the formula:
val=High[Highest(NULL,0,MODE_HIGH,20,4)];
Will return the highest high of the high price for that period but can not be used to return the highest high for an indicator like the moving average of the price.
This is because the series array identifier used is MODE_HIGH.
I know how to make a code to draw a trendline between 2 points. (object_create and object_move). But I need to know howto obtain the value of the high an low. Then I will use the data to fill the draw points.
I´d make some experimets with the zigzag indicator and the mod from coderguru but without succes.
Ok I have found a way to calculate the highest high or lowest low for an indicator over a specified period.
If you wanted to find the highest high or lowest low for an indicator like the simple moving average you have to declare an array and fill a "for" loop with the calculated values for each bar of the period you are testing.
Then you have to use ArrayMaximum and ArrayMinimum to find the position of the high or low in the array and then find the value of that position using iHigh() and iLow().
//calculate the highest high of the moving average
int malookback=5; //4+1 - the number of bars to calc the value of the ma
int madailyPERIOD = 30; //moving average period
double madaily[5];//declare an array
double dhhv,dllv;
for(int i = 0; i < malookback; i++)
{
madaily[i]=iMA(NULL,PERIOD_D1,madailyPERIOD,0,MODE_SMA,PRICE _CLOSE,i);
dhhv=iHigh("EURUSD", PERIOD_D1,(ArrayMaximum(madaily,4, 1))) ;