Percentage below 1

Hello I want to configure below formula
Currently percentage is showing not below 1.
I want the percentage as 0.5% 0.8 %.

Kindly help.
Thanks

_SECTION_BEGIN("MA Percentage Band");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", colorBlack, styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
P = ParamField("Price field",-1);
Periods = Param("Periods", 200, 2, 300, 1, 10 );
Percent = Param("Percentage %", 25, 1,100, 1, 10 );
SelectedIndicator = ParamList( "Show", "SMA,EMA,WMA,DEMA,TEMA", 1 );
 
if ( SelectedIndicator == "SMA" )
{
Positive_Percent_Band = MA( P, Periods )+ (MA( P, Periods )*percent/100);
Negative_Percent_Band = MA( P, Periods )- (MA( P, Periods )*percent/100);
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Plot( Positive_Percent_Band, "Positive %", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Plot( Negative_Percent_Band, " Negative %", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
}
else
if ( SelectedIndicator == "EMA" )
{
Positive_Percent_Band = EMA( P, Periods )+ (EMA( P, Periods )*percent/100);
Negative_Percent_Band = EMA( P, Periods )- (EMA( P, Periods )*percent/100);
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Plot( Positive_Percent_Band, "Positive %", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Plot( Negative_Percent_Band, " Negative %", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
}
else
if ( SelectedIndicator == "WMA" )
{
Positive_Percent_Band = WMA( P, Periods )+ (WMA( P, Periods )*percent/100);
Negative_Percent_Band = WMA( P, Periods )- (WMA( P, Periods )*percent/100);
Plot( WMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Plot( Positive_Percent_Band, "Positive %", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Plot( Negative_Percent_Band, " Negative %", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
}
else
if ( SelectedIndicator == "DEMA" )
{
Positive_Percent_Band = DEMA( P, Periods )+ (DEMA( P, Periods )*percent/100);
Negative_Percent_Band = DEMA( P, Periods )- (DEMA( P, Periods )*percent/100);
Plot( DEMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Plot( Positive_Percent_Band, "Positive %", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Plot( Negative_Percent_Band, " Negative %", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
}
else
if ( SelectedIndicator == "TEMA" )
{
Positive_Percent_Band = TEMA( P, Periods )+ (TEMA( P, Periods )*percent/100);
Negative_Percent_Band = TEMA( P, Periods )- (TEMA( P, Periods )*percent/100);
Plot( TEMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Plot( Positive_Percent_Band, "Positive %", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Plot( Negative_Percent_Band, " Negative %", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
}
_SECTION_END();

Try this:

_SECTION_BEGIN( "MA Percentage Band" );
	SetChartOptions( 0, chartShowArrows | chartShowDates );
	
	P = ParamField( "Price field", -1 );
	Periods = Param( "Periods", 200, 2, 300, 1, 10 );
	Percent = Param( "Percentage %", 0.25, 0.1, 1, 0.01 ) / 100;
	IndicatorList = ParamList( "Show", "SMA,EMA,WMA,DEMA,TEMA", 1 );
	IndicatorColor = ParamColor( "Indicator Color", colorCycle );
	IndicatorStyle = ParamStyle( "Indicator Style", styleLine ) | styleNoRescale;
	
	switch( IndicatorList ) {
		case "SMA":
			MyMA = MA( P, Periods );
			break;

		case "EMA":
			MyMA = EMA( P, Periods );
			break;

		case "WMA":
			MyMA = WMA( P, Periods );
			break;

		case "DEMA":
			MyMA = DEMA( P, Periods );
			break;

		case "TEMA":
			MyMA = TEMA( P, Periods );
			break;
	}
	
	Positive_Percent_Band = MyMA * ( 1 + Percent );
	Negative_Percent_Band = MyMA * ( 1 - Percent );
	
	//Plot( C, "Close", colorDefault, styleBar | styleNoTitle );
	Plot( C, "Close", colorDefault, styleCandle | styleNoTitle );
	
	Plot( MyMA, IndicatorList + "(" + Periods + ")", IndicatorColor, IndicatorStyle );
	Plot( Positive_Percent_Band, "Positive %", IndicatorColor, IndicatorStyle );	
	Plot( Negative_Percent_Band, " Negative %", IndicatorColor, IndicatorStyle );

	_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
_SECTION_END();
3 Likes

Thanks a lot !!:slightly_smiling_face:

2 Likes