Sample Indicator
Indicators
Sample Indicator
asimon
07-25-2006, 4:52 PM
public
class
iStub
{
int
tickcount;
int
periods;
//
// declare basic indicators here
//
public
iStub(
int
pPeriods)
{
periods = pPeriods;
tickcount = 0;
// instantiate any basic indicators here
}
public
void
ReceiveTick(
double
Val)
{
tickcount++;
if
(tickcount == (3*periods))
{
tickcount = (2*periods);
// avoid overflow (large->0) when indicator is primed
}
// perform indicator calculations here or send ticks to other indicators
}
public
double
Value()
{
double
v=0;
// compute indicator value here (note that this function might get called multiple times
// so do not set flags or do time specific behavior
if
(isPrimed())
{
// perform computation of output value
v = 1;
}
return
v;
}
// returns true when indicator has seen enough values to compute a result
// it will never return true if initialization parameters are incorrect
// this will cause indicator to silently fail and not give results
// on optimization runs where parameter combination is invalid.
public
bool
isPrimed()
{
bool
v =
false
;
// change this to the appropriate criteria
if
((tickcount >= periods) && (periods>0))
{
v =
true
;
}
return
v;
}
}
Forex Lab .NET | 4X Lab .NET © Copyright 2005-2006 ASCSE LLC |
Disclaimer