Hi Steve,
ParamToggle is used to record user's choice externally.
Example 1:
Ch = ParamToggle( "Choose MA Period", "20|50", 0 );
PerMa = IIf( Ch, 50, 20 );
/*
//You could alternately use if..else since 'Ch' is not an Array
if( Ch ) PerMa = 50;
else PerMa = 20;
*/
Plot( MA( C, PerMA ), "Simple MA", colorWhite );

Example 2:
Ch = ParamToggle( "Choose EMA Type", "MA|EMA", 1 );
PerMA = Param( "MA Period", 20, 1, 100, 1 );
switch( Ch ) {
case 0:
myMA = MA( C, PerMA );
break;
case 1:
myMA = EMA( C, PerMA );
break;
}
Plot( myMA, "myMA", colorWhite );
Title = WriteIf( Ch, "EMA", "MA" ) + "(C, " + PerMA + ") " + NumToStr( myMA, 1.2 );

Example 3:
Ch = ParamToggle( "Plot MA?", "No|Yes", 1 );
PerMA = Param( "MA Period", 20, 1, 100, 1 );
myMA = MA( C, PerMA );
styleDrawMA = IIf( Ch, styleThick, styleNoDraw );
Plot( C, "Price", colorDefault, styleBar | styleThick );
Plot( myMA, "myMA", colorDefault, styleDrawMA );
Title =
StrFormat( "{{DATE}}\nO %1.2f H %1.2f L %1.2f C %1.2f", O, H, L, C ) +
WriteIf( Ch, "\nMA( C, " + PerMA + ") " + NumToStr( myMA, 1.2 ), "" );

And if you happen to Toggle the conditions before running your Analysis, you can use the Parameters tab from the Analysis Window.

In your case since you want to Toggle Conditions dynamically (i.e. internally), then use the State of StaticVars. Something like this:
State = Nz( StaticVarGet( "VariableName" + Name() ), 0 ); //Name() is used to make the varname Unique. Sometimes Name() + Interval() OR simply a GetChartID()
//Condition that makes the State as True
Condition = /*Your Condition*/;
//IF (or IIF) Condition is Met or Holds True
//setting StaticVar as True
if( Condition ) {
//StaticVarSet has a Persist argument too, use wisely as per your requirements
StaticVarSet( "VariableName" + Name(), 1 ); //State is Set to True
}
if( State ) { //If State is True
/*
Do Something
*/
//State is reset to False such that until
//the "Condition" is Met again, it won't "Do Something".
//In other words, "if( State )" won't get executed until the "Condition" holds True again
StaticVarSet( "VariableName" + Name(), 0 );
}
A simple example of Toggling the State of a StaticVar that comes to mind is in this KB. Do play with the MoveinProgress. ![]()
If you grasp the power of StaticVars in AFL, you will be able to create Wonders.