stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

How can I capture an indicators max/min values ?
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=800
Page 1 of 1
Author:  lucklogic [ Fri Sep 07, 2012 1:11 pm ]
Post subject:  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 ???
Author:  NeoTrader [ Fri Sep 07, 2012 4:36 pm ]
Post subject:  Re: How can I capture an indicators max/min values ?

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 ???
This is only something that i think might work...didn't tested it but you should grasp the concept.

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]);
}
hope this helps,

happy trading,

NeoTrader

-
Author:  lucklogic [ Sat Sep 08, 2012 10:47 am ]
Post subject:  Re: How can I capture an indicators max/min values ?

NeoTrader wrote:
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 ???
This is only something that i think might work...didn't tested it but you should grasp the concept.

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]);
}
hope this helps,

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.
Author:  NeoTrader [ Sat Sep 08, 2012 12:16 pm ]
Post subject:  Re: How can I capture an indicators max/min values ?

hi lucklogic,
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.
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 ...
The same is also possible with ArrayMaximum for the Max Value.

happy weekend,

NeoTrader

-
Author:  lucklogic [ Sat Sep 08, 2012 3:03 pm ]
Post subject:  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]);
}
In order to work I just need to declare the dimensions of the array eg [100] rather than as a blank []

Thanks again :D :ugeek:
Author:  NeoTrader [ Sat Sep 08, 2012 3:39 pm ]
Post subject:  Re: How can I capture an indicators max/min values ?

hi lucklogic,
lucklogic wrote:In order to work I just need to declare the dimensions of the array eg [100] rather than as a blank []
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

-
Author:  gaheitman [ Sat Sep 08, 2012 4:38 pm ]
Post subject:  Re: How can I capture an indicators max/min values ?

NeoTrader wrote:hi lucklogic,
lucklogic wrote:In order to work I just need to declare the dimensions of the array eg [100] rather than as a blank []
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

-
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).

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
Author:  lucklogic [ Sat Sep 08, 2012 5:16 pm ]
Post subject:  Re: How can I capture an indicators max/min values ?

gaheitman wrote:
NeoTrader wrote:hi lucklogic,
lucklogic wrote:In order to work I just need to declare the dimensions of the array eg [100] rather than as a blank []
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

-
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).

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
Author:  gaheitman [ Sat Sep 08, 2012 5:39 pm ]
Post subject:  Re: How can I capture an indicators max/min values ?

lucklogic wrote:
gaheitman wrote:
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

-
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).

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
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
Author:  lucklogic [ Sun Sep 09, 2012 9:00 am ]
Post subject:  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

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()
  
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
All times are UTC Page 1 of 1