Download MetaTrader 5
To add comments, please log in or register
Publish your application in Cobe Base. Millions of traders will see it!
pedma
24
pedma 2015.02.05 06:06 

Hi,

We can get highest / lowest value of last Depth bar using (similar to MT4 Zigzag indicator) : 

double theHighest = high[iHighest(NULL,0,MODE_HIGH,Depth,i)];
double theLowest  = low[iLowest(NULL,0,MODE_LOW,Depth,i)];


But how can we get the highest/lowest of the CLOSE price of each bar in the last Depth bars ?  Which one from the code below is the right one ?

double theHighest = close[iHighest(NULL,0,MODE_CLOSE,Depth,i)];
double theLowest  = close[iLowest(NULL,0,MODE_CLOSE,Depth,i)];

** OR **

double theHighest = high[iHighest(NULL,0,MODE_CLOSE,Depth,i)];
double theLowest  = low[iLowest(NULL,0,MODE_CLOSE,Depth,i)];


Thank you in advance.

Carl Schreiber
5952
Carl Schreiber 2015.02.05 08:03  

the first two lines:

double theHighest = close[iHighest(NULL,0,MODE_CLOSE,Depth,i)]; // <= close of the bar found
double theLowest  = close[iLowest(NULL,0,MODE_CLOSE,Depth,i)];


But instead of waiting for 2 hours or more why don't you write a simple script to check it out yourself?

That would take 5 min to get the result instead of 2 hours?

Keith Watford
Moderator
7952
Keith Watford 2015.02.05 11:04  

As Gooly says, but bear in mind that by using close, it is unclear from the documentation whether the default is set as series or not

So you should include

ArraySetAsSeries(close,true);

 Before your code. Otherwise just use Open instead of open

pedma
24
pedma 2015.02.05 14:52  
gooly:

the first two lines:


But instead of waiting for 2 hours or more why don't you write a simple script to check it out yourself?

That would take 5 min to get the result instead of 2 hours?

Thanks gooly. But it is not clear about "2 hours" , could you please explain more ?

Actually i am trying to create my own Zigzag indicator (modifying the default ZigZag indicator of MT4), which will get the CLOSE price of the bar (instead of High and Low of the bar).

Thanks

pedma
24
pedma 2015.02.05 14:59  
GumRai:

As Gooly says, but bear in mind that by using close, it is unclear from the documentation whether the default is set as series or not

So you should include

 Before your code. Otherwise just use Open instead of open

Thanks GumRai. Do you mean using : time,open,high,low,close,tick_volume,volume,spread  (found at OnCalculate function)  need to set them as Series first,

while using  "Close" or "iClose" , we do not need to set them as series?

Keith Watford
Moderator
7952
Keith Watford 2015.02.05 20:05  
pedma:

Thanks GumRai. Do you mean using : time,open,high,low,close,tick_volume,volume,spread  (found at OnCalculate function)  need to set them as Series first,

while using  "Close" or "iClose" , we do not need to set them as series?

Close (with the capital letter) etc are series arrays

but

from the documentation for OnCalculate 

"To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with." 

pedma
24
pedma 2015.02.05 23:23  
GumRai:

Close (with the capital letter) etc are series arrays

but

from the documentation for OnCalculate 

"To determine the indexing direction of time[], open[],high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order notto depend on default values, you should unconditionally call the ArraySetAsSeries() function forthose arrays, which are expected to work with." 

Thanks a lot GumRai ...
Gabriel Viali
201
Gabriel Viali 2015.02.06 03:38  

Taking advantage of this topic, I had a doubt earlier..

If I wish to spot some divergence with bollinger bands.. can it be done using this code?

 

double theHighest = Close[iHighest(NULL,0,MODE_CLOSE,Depth,i)]; //count the close for the past Depth bars
double theHighestPast = Close[iHighest(NULL,0,MODE_CLOSE,Depth,i+Depth)]; //count the close for the past Depth bars before theHighest

double BB = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,"how to specify that this is to count the last 'Depth' bars");
double BBPast = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,"how to specify that this is to count the 'Depth' previous than the last Depth bars");

if(theHighestPast>BBpast /* if closed out of the bands at some point between this time*/ && theHighest<=BB && theHighest>theHighestPast /*the last highest was higher than the previous and didnt close out of the bollinger bands*/)

 I've checked to use the iBarShift() function, but not shure how it would fit in this..

/
To add comments, please log in or register