How to program code that returns a date for any given trough

'Can anyone please advice how to program code that returns a date for any given trough

_SECTION_BEGIN("ElliottWave");


P1 = ParamField( "ZIG Price field" );
change1 = Param("% change1",4.5,0.25,25,0.25); 

Color1 =(ParamColor("Elliott Wave",coloryellow));
Plot( zz=TEMA(Zig(P1, change1),1), _DEFAULT_NAME(), Color1, styleLine) ;


PercentCHG = 8;
p1 =trough (C,PercentCHG ,1);
p2 =trough (C,PercentCHG ,2);

TroughDate =  LastValue(ValueWhen(DateNum() ==  Trough(C,8,1), Datenum() )); 
printf("TroughDate   "+ WriteVal(TroughDate,4,2));;printf ("\n");

//TroughDate always returns a zero value. Have tried various alternatives without success.
//Please suggest how I might return a trough date 

 
_SECTION_END();

Typed on smartphone so not checked for fat finger mistakes but you get the idea...

TroughDate = Ref(DateNum(), -TroughBars(C,8,1));

BTW, don't spam the forum with multiple same threads. It is not all allowed.

1 Like