Download MetaTrader 5

finding highest/lowest values inside for loop

To add comments, please log in or register
unmaskedluke
75
unmaskedluke  

hello, this is my 1st question here in mql forum. im new to coding and sorry if my english is bad

as the title says, heres the code

for(int i=0; i<50; i++) {  
    currentHigh=iHigh(Symbol(),0,i);
    previousHigh=iHigh(Symbol(),0,i+1);
    breakoutTop=NormalizeDouble(((currentHigh-previousHigh)/ticksize),0);
}

basically this is to calculate the difference between current bar high and previous bar high or in other word to determine a breakout (daily candle). 

and this process repeat for a specified number of bar as u can see i set it on 50 bar and below

the breakoutTop variable return the result of calculation 

my question is, how to find the highest/lowest values from all the calculation performed ? i read about array or dynamic array but i can't seems to get it. someone pls help?

Nguyenmai
7
Nguyenmai  
<Removed as just a quote of the previous post>
Taras Slobodyanik
17786
Taras Slobodyanik  
int i=0; 
int count=50;
      
double Maximum=NormalizeDouble(iHigh(_Symbol,_Period,iHighest(_Symbol,_Period,MODE_HIGH,count,i)),_Digits);
double Minimum=NormalizeDouble(iLow(_Symbol,_Period,iLowest(_Symbol,_Period,MODE_LOW,count,i)),_Digits);
unmaskedluke
75
unmaskedluke  

let me explain this visually. 

highest/lowest values of the difference between prices. not highest & lowest of candle
whroeder1
15917
whroeder1  
unmaskedluke:v highest/lowest values of the difference between prices. not highest & lowest of candle
  1. So, loop, get the difference of that candle, compare it to the maximum you've already seen, remember the new max and which bar.
  2. We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem.
To add comments, please log in or register