How can I capture an indicators max/min values ?
- lucklogic
- Trader
- Posts: 85
- Joined: Mon Jan 23, 2012 6:26 pm
- Location: On The Hoe in Plymouth, UK
How can I capture an indicators max/min values ?
Hi,
Suppose that I want to use WPR indicator whose output values that varies between 0 and 100 but I want to capture that max value and the min value within a predefined lookback of 300 blocks Eg max values achieved = -5 min value achieved = - 87
Now how could I do that ???
Suppose that I want to use WPR indicator whose output values that varies between 0 and 100 but I want to capture that max value and the min value within a predefined lookback of 300 blocks Eg max values achieved = -5 min value achieved = - 87
Now how could I do that ???
- NeoTrader
- Trader
- Posts: 436
- Joined: Wed Apr 04, 2012 2:52 pm
- Location: small Village at Lake Chiemsee, Bavaria, Germany
Re: How can I capture an indicators max/min values ?
This is only something that i think might work...didn't tested it but you should grasp the concept.lucklogic wrote:Hi,
Suppose that I want to use WPR indicator whose output values that varies between 0 and 100 but I want to capture that max value and the min value within a predefined lookback of 300 blocks Eg max values achieved = -5 min value achieved = - 87
Now how could I do that ???
Code: Select all
double MyMax, MyMin;
int LookBack = 100;
double WprArray[];
for ( i=0; i<=LookBack; i++) {
WprArray[i] = Call to your WPR Indicator shift = i;
MyMax = MathMax(MyMax, WprArray[i]);
MyMin = MathMin(MyMin, WprArray[i]);
}
happy trading,
NeoTrader
-
- lucklogic
- Trader
- Posts: 85
- Joined: Mon Jan 23, 2012 6:26 pm
- Location: On The Hoe in Plymouth, UK
Re: How can I capture an indicators max/min values ?
NeoTrader wrote:This is only something that i think might work...didn't tested it but you should grasp the concept.lucklogic wrote:Hi,
Suppose that I want to use WPR indicator whose output values that varies between 0 and 100 but I want to capture that max value and the min value within a predefined lookback of 300 blocks Eg max values achieved = -5 min value achieved = - 87
Now how could I do that ???
hope this helps,Code: Select all
double MyMax, MyMin; int LookBack = 100; double WprArray[]; for ( i=0; i<=LookBack; i++) { WprArray[i] = Call to your WPR Indicator shift = i; MyMax = MathMax(MyMax, WprArray[i]); MyMin = MathMin(MyMin, WprArray[i]); }
happy trading,
NeoTrader
-
Thank you that is most helpful. I will have a play. Also might utilise function ;
int ArrayMinimum( double array[], int count=WHOLE_ARRAY, int start=0)
Searches for the element with minimum value. The function returns position of this minimum element in the array.
- NeoTrader
- Trader
- Posts: 436
- Joined: Wed Apr 04, 2012 2:52 pm
- Location: small Village at Lake Chiemsee, Bavaria, Germany
Re: How can I capture an indicators max/min values ?
hi lucklogic,
The same is also possible with ArrayMaximum for the Max Value.
happy weekend,
NeoTrader
-
Sure, this would be also possible...you can also try to use your Lockback value as count and the shift value of the bar as start ...lucklogic wrote:Thank you that is most helpful. I will have a play. Also might utilise function ;
int ArrayMinimum( double array[], int count=WHOLE_ARRAY, int start=0)
Searches for the element with minimum value. The function returns position of this minimum element in the array.
The same is also possible with ArrayMaximum for the Max Value.
happy weekend,
NeoTrader
-
- lucklogic
- Trader
- Posts: 85
- Joined: Mon Jan 23, 2012 6:26 pm
- Location: On The Hoe in Plymouth, UK
Re: How can I capture an indicators max/min values ?
Code: Select all
double MyMax, MyMin;
int LookBack = 100;
double WprArray[100];
for ( i=0; i<=LookBack; i++) {
WprArray[i] = Call to your WPR Indicator shift = i;
MyMax = MathMax(MyMax, WprArray[i]);
MyMin = MathMin(MyMin, WprArray[i]);
}
Thanks again
- NeoTrader
- Trader
- Posts: 436
- Joined: Wed Apr 04, 2012 2:52 pm
- Location: small Village at Lake Chiemsee, Bavaria, Germany
Re: How can I capture an indicators max/min values ?
hi lucklogic,

Maybe you also need to set the Array as a timeSeries via ArraySetAsSeries(WprArray, true);
happy weekend,
NeoTrader
-
It would be a cleaner solution to use ArrayResize(WprArray, LookBack)... this way the array will resize automatically to the value of your LookBack...in case you are going to change this value in your testing...or make it available es external Parameterlucklogic wrote:In order to work I just need to declare the dimensions of the array eg [100] rather than as a blank []
Maybe you also need to set the Array as a timeSeries via ArraySetAsSeries(WprArray, true);
happy weekend,
NeoTrader
-
- gaheitman
- Trader
- Posts: 655
- Joined: Tue Nov 15, 2011 10:55 pm
- Location: Richmond, VA, US
Re: How can I capture an indicators max/min values ?
It's not clear (to me, at least) why we are using an array in the first place. The code posted does not actually reference the array in a useful manner, it is only looking at the value we just put in it. We could just use a simple double to hold the result of the call to GetWPR(i).NeoTrader wrote:hi lucklogic,It would be a cleaner solution to use ArrayResize(WprArray, LookBack)... this way the array will resize automatically to the value of your LookBack...in case you are going to change this value in your testing...or make it available es external Parameterlucklogic wrote:In order to work I just need to declare the dimensions of the array eg [100] rather than as a blank []
Maybe you also need to set the Array as a timeSeries via ArraySetAsSeries(WprArray, true);
happy weekend,
NeoTrader
-
In order to determine the best path forward, we need to know in what context you need this information. Are you using it in an EA, an indicator or a script? I would code them all differently.
George
- lucklogic
- Trader
- Posts: 85
- Joined: Mon Jan 23, 2012 6:26 pm
- Location: On The Hoe in Plymouth, UK
Re: How can I capture an indicators max/min values ?
gaheitman wrote:It's not clear (to me, at least) why we are using an array in the first place. The code posted does not actually reference the array in a useful manner, it is only looking at the value we just put in it. We could just use a simple double to hold the result of the call to GetWPR(i).NeoTrader wrote:hi lucklogic,It would be a cleaner solution to use ArrayResize(WprArray, LookBack)... this way the array will resize automatically to the value of your LookBack...in case you are going to change this value in your testing...or make it available es external Parameterlucklogic wrote:In order to work I just need to declare the dimensions of the array eg [100] rather than as a blank []
Maybe you also need to set the Array as a timeSeries via ArraySetAsSeries(WprArray, true);
happy weekend,
NeoTrader
-
In order to determine the best path forward, we need to know in what context you need this information. Are you using it in an EA, an indicator or a script? I would code them all differently.
George
Yes I see that you are (of course) correct. Both methods work, array or double and I'm happy that I can now capture the max/min.
I want to use the info in an EA
- gaheitman
- Trader
- Posts: 655
- Joined: Tue Nov 15, 2011 10:55 pm
- Location: Richmond, VA, US
Re: How can I capture an indicators max/min values ?
I don't know how CPU intensive the WPR calculation is but if you keep track of it in an array, you might want to use it as a circular buffer so you only update the new value (look at the CentralBankInterventionModule() code in some of the EAs Steve has done).lucklogic wrote:gaheitman wrote:It's not clear (to me, at least) why we are using an array in the first place. The code posted does not actually reference the array in a useful manner, it is only looking at the value we just put in it. We could just use a simple double to hold the result of the call to GetWPR(i).NeoTrader wrote:hi lucklogic,
It would be a cleaner solution to use ArrayResize(WprArray, LookBack)... this way the array will resize automatically to the value of your LookBack...in case you are going to change this value in your testing...or make it available es external Parameter
Maybe you also need to set the Array as a timeSeries via ArraySetAsSeries(WprArray, true);
happy weekend,
NeoTrader
-
In order to determine the best path forward, we need to know in what context you need this information. Are you using it in an EA, an indicator or a script? I would code them all differently.
George
Yes I see that you are (of course) correct. Both methods work, array or double and I'm happy that I can now capture the max/min.
I want to use the info in an EA
George
- lucklogic
- Trader
- Posts: 85
- Joined: Mon Jan 23, 2012 6:26 pm
- Location: On The Hoe in Plymouth, UK
Re: How can I capture an indicators max/min values ?
I don't know how CPU intensive the WPR calculation is but if you keep track of it in an array, you might want to use it as a circular buffer so you only update the new value (look at the CentralBankInterventionModule() code in some of the EAs Steve has done).
George
Thanks for that advise and some of the relevant portion of the module, I have included above, unfortunately its above my pay grade to understand what's happening
George
Code: Select all
void StoreQuote()
{
// fill the current tick value into the table
TickTable[tc] = Bid;
if (is_filled == 0) // table not full yet
{
fill_check_counter += 1;
if (fill_check_counter == TableSize) is_filled = 1;
}//if (is_filled == 0)
else
{
TickDiff = MathAbs(TickTable[(tc + 1) % TableSize] - TickTable[tc]) * PipMultiplier;
}//else
// increment the counter
tc += 1;
tc = tc % TableSize;// keeps tc within TableSize
}//End void StoreQuote()