https://book.mql4.com//
Hi Guys, I want to get the lower bar price value for the period from any time the function is called to the previous 3 /for example/ higher TF bars. What I have missed in the code? This function is in cycle, and gets the lowerTF bar number in iValue.
Appreciated. Thank you in advance.
At this point . . .
double OrderArray[]; // zero elements size for(i=0;i<NumberBarsHighTF;i++) { OrderArray[i]=iLow(NULL,HighTF,i); }
. . . . your array has a size of zero elements.
double OrderArray[]; for(i=0;i<NumberBarsHighTF;i++) OrderArray[i]=iLow(NULL,HighTF,i); int element_count=ArrayResize(OrderArray,NumberBarsHighTF);
- The array has no elements.
- Assigning values to a empty array does nothing.
- Resizing the array is fine but you never put any values in it.
- LowTF, time, andTimeArray[] are unused
What you're asking for is simple compare to what you're doing. You pass extra parameters you're not using. You're using a for loop for no good reason ... iBarShift() of the Highest_TF should be enough. You're using the array before giving it any size. You name an array OrderArray but nothing involving orders. You should probably read the book and get the basics.
https://book.mql4.com//
How I can use iBarShift() ? I would like to get the lower value for the last "NumberBarsHighTF" bars. For example NumberBarsHighTF=3 .
How to use iBarShift().
void start(){ LowestPrice(3,PERIOD_D1); } double LowestPrice(int NumberOfBars, int TimeFrame){ int LowestBari=iLowest(Symbol(),TimeFrame,MODE_LOW,NumberOfBars,0); double ValueOf_LowestBari=iLow(Symbol(),TimeFrame,LowestBari); return(ValueOf_LowestBari); }Not tested.
ubzen:
What you're asking for is simple compare to what you're doing. You pass extra parameters you're not using. You're using a for loop for no good reason ... iBarShift() of the Highest_TF should be enough. You're using the array before giving it any size. You name an array OrderArray but nothing involving orders. You should probably read the book and get the basics.
https://book.mql4.com//
How I can use iBarShift() ? I would like to get the lower value for the last "NumberBarsHighTF" bars. For example NumberBarsHighTF=3 .
Hi,
In order to use the function in cycle in indicator and in case I want to get the result for bars number 1, 17, 35, I added parameter i .
double LowestValue=LowestPrice(3,60,i);
and using function:
double LowestPrice(int NumberOfBars, int TimeFrame, int shift){ int LowestBari=iLowest(Symbol(),TimeFrame,MODE_LOW,NumberOfBars,shift); double ValueOf_LowestBari=iLow(Symbol(),TimeFrame,LowestBari); return(ValueOf_LowestBari); }
I get correct result only for the first bar, for the others bars the result values continue to get lower. Please advise for further updates.
Thank you.
just to correct myself - for the first bar the value is close but not as expected and for the others the deviation is becoming bigger.
Hi,
In order to use the function in cycle in indicator and in case I want to get the result for bars number 1, 17, 35, I added parameter i
and using function:
I get correct result only for the first bar, for the others bars the result values continue to get lower. Please advise for further updates.
Thank you.
double LowestValue=LowestPrice(3,60,i);Where does i come from? It better be a PERIOD_H1 chart index and not the current chart index. Apples and Oranges
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Guys, I want to get the lower bar price value for the period from any time the function is called to the previous 3 /for example/ higher TF bars. What I have missed in the code? This function is in cycle, and gets the lowerTF bar number in iValue.
Appreciated. Thank you in advance.