Reset Param when symbol changes

Hello- I have lurked for years and utilized this forum in the bg, I am posting as I cannot find an answer.

I am trying to have different param values depending on the Index ETF I day trade as I have a service that provided key daily value lines, however SPX and SPY values are so very different I can't get it to cooperate. I saw some code by fxshrat (who is AWESOME at this !!) thinking this may be the solution , unsure...
their code first... then mine..

thanks in advance..

E17

if ( Status( "action" ) == actionIndicator ) { // if in chart pane
    pval = Param( pname, def, start, end, change);
    StaticVarSet(pname + uniqueID, pval );
VolTrigger = Param("Vol Trigger",400,400,500,1);
AbsGEX = Param("AbsGEX",VolTrigger+1,VolTrigger,500,1);
CallWall = Param("CallWall",VolTrigger+10,VolTrigger,500,1);
PutWall = Param("PutWall",VolTrigger-10,VolTrigger,500,1);
    
    
} else // call chart pane value (if analysis)
    pval = StaticVarGet( pname + uniqueID );




CurrentSymbol = Name();

//printf(currentsymbol);

if( CurrentSymbol == "SPY")
{

VolTrigger = Param("Vol Trigger",400,400,500,1);
AbsGEX = Param("AbsGEX",VolTrigger+1,VolTrigger,500,1);
CallWall = Param("CallWall",VolTrigger+10,VolTrigger,500,1);
PutWall = Param("PutWall",VolTrigger-10,VolTrigger,500,1);

Plot(VolTrigger,"Vol Trigger",colorBlack,styleLine,VolTrigger,Null,1,Null,3);
Plot(AbsGEX,"Abs GEX",colorBlack,styleDashed,AbsGEX,Null,1,Null,4);
Plot(CallWall,"CallWall",colorCUSTOM16,styleThick|styleLine,CallWall,Null,1,Null,4);
Plot(PutWall,"PutWall",colorDarkGreen,styleThick|styleLine,PutWall,Null,1,Null,4);


}

else if (CurrentSymbol == "QQQ")
{
VolTrigger = Param("Vol Trigger",300,300,500,1);
AbsGEX = Param("AbsGEX",VolTrigger+1,VolTrigger,500,1);
CallWall = Param("CallWall",VolTrigger+10,VolTrigger,500,1);
PutWall = Param("PutWall",VolTrigger-10,VolTrigger,500,1);

Plot(VolTrigger,"Vol Trigger",colorBlack,styleLine,VolTrigger,Null,1,Null,3);
Plot(AbsGEX,"Abs GEX",colorBlack,styleDashed,AbsGEX,Null,1,Null,4);
Plot(CallWall,"CallWall",colorCUSTOM16,styleThick|styleLine,CallWall,Null,1,Null,4);
Plot(PutWall,"PutWall",colorDarkGreen,styleThick|styleLine,PutWall,Null,1,Null,4);

}
else if (CurrentSymbol == "SPX.XO")
{
VolTrigger = Param("Vol Trigger",4200,4200,5000,1);
AbsGEX = Param("AbsGEX",VolTrigger+1,VolTrigger,5000,1);
CallWall = Param("CallWall",VolTrigger+10,VolTrigger,5000,1);
PutWall = Param("PutWall",VolTrigger-10,VolTrigger,5000,1);

Plot(VolTrigger,"Vol Trigger",colorBlack,styleLine,VolTrigger,Null,1,Null,3);
Plot(AbsGEX,"Abs GEX",colorBlack,styleDashed,AbsGEX,Null,1,Null,4);
Plot(CallWall,"CallWall",colorCUSTOM16,styleThick|styleLine,CallWall,Null,1,Null,4);
Plot(PutWall,"PutWall",colorDarkGreen,styleThick|styleLine,PutWall,Null,1,Null,4);

}

else if (CurrentSymbol == "IWM")
{
VolTrigger = Param("Vol Trigger",172,172,217,1);
AbsGEX = Param("AbsGEX",VolTrigger+1,VolTrigger,217,1);
CallWall = Param("CallWall",VolTrigger+10,VolTrigger,217,1);
PutWall = Param("PutWall",VolTrigger-10,VolTrigger,217,1);

Plot(VolTrigger,"Vol Trigger",colorBlack,styleLine,VolTrigger,Null,1,Null,3);
Plot(AbsGEX,"Abs GEX",colorBlack,styleDashed,AbsGEX,Null,1,Null,4);
Plot(CallWall,"CallWall",colorCUSTOM16,styleThick|styleLine,CallWall,Null,1,Null,4);
Plot(PutWall,"PutWall",colorDarkGreen,styleThick|styleLine,PutWall,Null,1,Null,4);

}


else
{
}

I would suggest setting separate chart for both, or at least separate Sheet for both.

Param()s are not meant to be called conditionally the way you are trying. Params use unique keys (the name is a key). The fact that you are calling Param() in two separate branches does not change the fact that if name is the same the parameter is the same.

If you want to have them separate, the NAMES must be DIFFERENT. Such as "SPX VolTrigger" vs "QQQ VolTrigger".

The only way to have SAME name of parameter but separate values, is to have separate chart IDs as explained in the KB

I do not put params inside if else statements. So it's not my code as you claimed.

You must not put params like that. They are cached.
See upper post by Tomasz.

my apologies, fx... I referring to this post

Thanks Tomasz for the reply, I will create separate chart names and save as separate templates

That's because Params were developed as chart functions originally.
And if (STATUSACTION == ACTIONINDICATOR) means that params shall be used for chart pane only othwise in other environment like analysis remain invisible.
Param value is stored to static variable in chart pane in that code and that stored value is called in other environment such as analysis.

I would recommend that any non-standard use of Params() should be accompanied by comment that explains such non-standard usage.
Generally Param() calls should NOT be done conditionally.
Only if you want to do something unusual (like HIDING parameters from being visible in Analysis like in @fxshrat case) such use may be justified, but should be commented precisely to avoid misunderstanding.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.