How to keep variable unchanged

Trying to get boolean variable stay ON after condition was reached and not changed when condition do not exists anymore.
Trying StaticVarSet but it didnt work for me:

temp = StaticVarGet("mystaticarray" );
temp = C>10;
StaticVarSet("mystaticarray", temp );
Short = tradeCondition and temp

temp = Hold(C>10, BarCount);
Short = temp;

AFL Function Reference - HOLD

Hold

  • hold the alert signal
SYNTAX Hold( EXPRESSION, periods )
RETURNS ARRAY
FUNCTION Holds a "true" result of EXPRESSION for the specified number of periods . This true result is held true over the number of periods specified even if a "false" result is generated.
EXAMPLE hold( cross(rsi(14),70),5 )

6 Likes