Hi, can anybody help me with my costum indicator?
I'm new here, new in MQL4. I've been searching it on this forum and googling it since 2 weeks ago, but still no luck with my experiment.
// I'm expecting the highest high and lowest low from last candle to 00.00 on current time frame int ShiftTo = iBarShift(NULL,0,0); int ShiftFrom = Counted_Bars - 1; // why this ?By 00:00 I assume you mean the last midnight ? so why is coiunted_bars - 1 midnight ?
int Counted_Bars = IndicatorCounted(); // datetime Now = Time[0] - Time[0] % 86400; int ShiftTo = iBarShift(NULL,0,0); int ShiftFrom = Counted_Bars - 1; double HH = High [iHighest(NULL,0,MODE_HIGH,ShiftFrom,ShiftTo)]; double LL = Low [iLowest (NULL,0,MODE_LOW,ShiftFrom,ShiftTo)]; for ( int i = Counted_Bars; i>-1; i--){ if (Close[i+1] < Open[i+1])
- The first time the indicator runs Counted_Bars is zero and your loop runs just bar zero. After that it's Bars - 1, so your loop recalculates all bars, every tick. Do it like all the others in the codebase.
int Counted_Bars = IndicatorCounted(); if(Counted_Bars < LOOKBACK) Counted_Bars = LOOKBACK; for ( int i = Bars - 1 - Counted_Bars; i>=0; i--)
- iBarShift with time=0 gets the index of the earliest bar on the chart. ShiftTo = Bars - 1.
- ShiftFrom is -1 the first time and Bars -2 after that. Bogus
- RTFM What is the 4th argument to iHighest it's not a index. It's a count. What is the 5th argument? It's the newest bar index. If you like to think in indexes (like C/C++ programmers) do it like
int iGetHighest(int iEnd, int iBeg=0, int p=0){ // Excluding iEnd. return( iHighest(NULL,p, MODE_HIGH, iEnd - iBeg, iBeg) ); } int iGetLowest( int iEnd, int iBeg=0, int p=0){ return( iLowest(NULL,p, MODE_LOW, iEnd - iBeg, iBeg) ); } : double HH = iGetHighest( i+LOOKBACK, i);
- All that code should be inside the loop because they should be changing each time
- Why are you looking at the C[i+1] < O[i+1]? Your loop is calculating bar i so you should be looking a C[i] < O[i]
By 00:00 I assume you mean the last midnight ? so why is coiunted_bars - 1 midnight ?
Sorry, I am not fluent in English. I hope you understand what I mean
I expect to get a total of candles ranging from market opening up to the last candle formed for the current time frame.
For example: in current time frame h1
- The first time the indicator runs Counted_Bars is zero and your loop runs just bar zero. After that it's Bars - 1, so your loop recalculates all bars, every tick. Do it like all the others in the codebase.
- iBarShift with time=0 gets the index of the earliest bar on the chart. ShiftTo = Bars - 1.
- ShiftFrom is -1 the first time and Bars -2 after that. Bogus
- RTFM What is the 4th argument to iHighest it's not a index. It's a count. What is the 5th argument? It's the newest bar index. If you like to think in indexes (like C/C++ programmers) do it like
- All that code should be inside the loop because they should be changing each time
- Why are you looking at the C[i+1] < O[i+1]? Your loop is calculating bar i so you should be looking a C[i] < O[i]
As I said earlier, I'm new in MQL4. I only collect references that I got from this forum and tried to combine them in order to fit with what I expected.
If only there MQL4 reference books in Indonesian, perhaps the code I wrote is not like this. Unfortunately there is no book like it here. My last hope is on this forum. hoping someone would help solve my problem
- 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, can anybody help me with my costum indicator?
I'm new here, new in MQL4. I've been searching it on this forum and googling it since 2 weeks ago, but still no luck with my experiment.
Help me, please ...
Thanks in advance