Use SECTION_BEGIN, _SECTION_END functions

Hello everyone,
I create a custom Indicator Including several plots and all of them have different input parameters
when I drag and drop that indicator to the price chart it replaces the location of the first price field which I created as an alternative to the built-in ParamField() function from the first cell to the third cell as the image,
I know I need to use the SECTION_BEGIN, _SECTION_END function but I need to drag and the group that Indicator several times on the chart
and when I use that SECTION_BEGIN, _SECTION_END function returns an error

Capture


HMA_Pricep  = ParamList( "HMA Price", "Open|High|Low|Last|Average|Volume|Vwap" , 0);
HMA_Period = Param( "HMA period", 25, 10, 100 );
HMAUpColor  = ParamColor("HMA UpColor", colorGreen);
HMADwnColor = ParamColor("HMA DownColor", colorRed);
HMAStyle =  ParamStyle("HMA Style", styleLine | styleNoLabel ) | styleNoLabel;


//HMA_Price  = ParamField( "HMA Price", 0 );


// Switch case to get the correct values of Field Price without any duplication as Built parafield::
switch( HMA_Pricep )
{
	case "Open":
		HMA_Price = O;
		break;

	case "High":
		HMA_Price = H;
		break;

	case "Low":
		HMA_Price =L;
		break;

	case "Last":
		HMA_Price = C;
		break;
		
	case "Average":
		HMA_Price = (( H + L + C ) / 3);
		break;
		
	case "Volume":
		HMA_Price = V;
		break;
		
	case "Vwap":
		HMA_Price = OpenInt;
		break;

}

HMA_1st = HMA( HMA_Price, HMA_Period ); 


//  That Process to slop up/down of HMA Line
trend = 0;

for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( HMA_1st[i] > HMA_1st[i - 1] )
			trend[i] = 1;
		else
		{
			if( HMA_1st[i] < HMA_1st[i - 1] )
				trend[i] = -1;
			else
				trend[i] = trend[i - 1];
		}
	}
	else
		trend[i] = 0;
}

// Identify Up/Down of HMA line
//trend   = UpDwnClr( HMA_1st) ; 
upHMA   = trend > 0;
downHMA = trend < 0;

//Coloring HMA slop Up/Down line
HMAColor  = IIf( upHMA, HMAUpColor, IIf( downHMA, HMADwnColor, HMAUpColor ) );



Plot( HMA_1st, "HMA", HMAColor, HMAStyle );

//===============================================================================================================================================
//===============================================================================================================================================
//===============================================================================================================================================

HMA1_Pricep  = ParamList( "HMA1 Price", "Open|High|Low|Last|Average|Volume|Vwap" , 3);
HMA1_Period = Param( "HMA1 period", 25, 10, 100 );
HMA1UpColor  = ParamColor("HMA1 UpColor", colorGreen);
HMA1DwnColor = ParamColor("HMA1 DownColor", colorRed);
HMA1Style =  ParamStyle("HMA1 Style", styleLine | styleNoLabel ) | styleNoLabel;


//HMA_Price  = ParamField( "HMA Price", 0 );
//_SECTION_END();

// Switch case to get the correct values of Field Price without any duplication as Built parafield::
switch( HMA1_Pricep )
{
	case "Open":
		HMA1_Price = O;
		break;

	case "High":
		HMA1_Price = H;
		break;

	case "Low":
		HMA1_Price =L;
		break;

	case "Last":
		HMA1_Price = C;
		break;
		
	case "Average":
		HMA1_Price = (( H + L + C ) / 3);
		break;
		
	case "Volume":
		HMA1_Price = V;
		break;
		
	case "Vwap":
		HMA1_Price = OpenInt;
		break;

}

HMA_2nd= HMA( HMA1_Price, HMA1_Period );   


//  That Process to slop up/down of HMA Line
trend1 = 0;

for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( HMA_2nd[i] > HMA_2nd[i - 1] )
			trend1[i] = 1;
		else
		{
			if( HMA_2nd[i] < HMA_2nd[i - 1] )
				trend1[i] = -1;
			else
				trend1[i] = trend1[i - 1];
		}
	}
	else
		trend1[i] = 0;
}

// Identify Up/Down of HMA line
//trend   = UpDwnClr( HMA_1st) ; 
upHMA1   = trend1 > 0;
downHMA1 = trend1 < 0;

//Coloring HMA slop Up/Down line
HMA1Color  = IIf( upHMA1, HMA1UpColor, IIf( downHMA1, HMA1DwnColor, HMA1UpColor ) );



Plot( HMA_2nd, "HMA1", HMA1Color, HMA1Style );


HMA2_Pricep  = ParamList( "HMA Price", "Open|High|Low|Last|Average|Volume|Vwap" , 2);
HMA2_Period = Param( "HMA2 period", 25, 10, 100 );
HMA2UpColor  = ParamColor("HMA2 UpColor", colorGreen);
HMA2DwnColor = ParamColor("HMA2 DownColor", colorRed);
HMA2Style =  ParamStyle("HMA2 Style", styleLine | styleNoLabel ) | styleNoLabel;


//HMA_Price  = ParamField( "HMA Price", 0 );
//_SECTION_END();

// Switch case to get the correct values of Field Price without any duplication as Built parafield::
switch( HMA2_Pricep )
{
	case "Open":
		HMA2_Price = O;
		break;

	case "High":
		HMA2_Price = H;
		break;

	case "Low":
		HMA2_Price =L;
		break;

	case "Last":
		HMA2_Price = C;
		break;
		
	case "Average":
		HMA2_Price = (( H + L + C ) / 3);
		break;
		
	case "Volume":
		HMA2_Price = V;
		break;
		
	case "Vwap":
		HMA2_Price = OpenInt;
		break;

}

HMA_3rd = HMA( HMA2_Price, HMA2_Period ); 


//  That Process to slop up/down of HMA Line
trend2 = 0;

for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( HMA_3rd[i] > HMA_3rd[i - 1] )
			trend2[i] = 1;
		else
		{
			if( HMA_3rd[i] < HMA_3rd[i - 1] )
				trend2[i] = -1;
			else
				trend2[i] = trend2[i - 1];
		}
	}
	else
		trend2[i] = 0;
}

// Identify Up/Down of HMA line
//trend   = UpDwnClr( HMA_1st) ; 
upHMA2  = trend2 > 0;
downHMA2 = trend2 < 0;

//Coloring HMA slop Up/Down line
HMA2Color  = IIf( upHMA2, HMA2UpColor, IIf( downHMA2, HMA2DwnColor, HMA2UpColor ) );



Plot( HMA_3rd, "HMA2", HMA2Color, HMA2Style );


first_HMA_Choice = ParamList( "firt_selected_HMA ", "HMA1|HMA2|HMA3" ,0);
// select the 2nd HMA for get Diff value ::
second_HMA_Choice = ParamList( "second_selected_HMA ", "HMA1|HMA2|HMA3" ,0);

// Factor value::
factor_value = Param( "factor_value", 0.5, 0, 100 ,0.1);
Diff_color = ParamColor( "Diff color", colorGreen ) ;
DiffStyle =  ParamStyle("Diff-Style", styleLine | styleNoLabel ) | styleNoLabel;
//_SECTION_END();

// Switch case to get the correct values HMA Based our selection::
switch( first_HMA_Choice )
{
	case "HMA1":
		//HMA_value = HMA( HMA_Price, HMA_Period );
		HMA_value = HMA( HMA_Price , HMA_Period );
		
		break;

	case "HMA2":
		//HMA_value = HMA( HMA1_Price, HMA1_Period );
		HMA_value = HMA( HMA_2nd , HMA1_Period );
		break;

	case "HMA3":
		//HMA_value = HMA( HMA2_Price, HMA2_Period );
		HMA_value = HMA( HMA_3rd , HMA2_Period );
		
		break;

}

//Plot( HMA_value, "HMA_value", ParamColor( "Difference color", colorBlue ),  ParamStyle( "HMA1_value" ) , Null, Null, 0, 0, 2);


// Switch case to get the correct values HMA Based our selection::
switch( second_HMA_Choice )
{
	case "HMA1":
		//HMA1_value = HMA( HMA_Price, HMA_Period );
		HMA1_value = HMA( HMA_Price , HMA_Period );
		break;

	case "HMA2":
		//HMA1_value = HMA( HMA1_Price, HMA1_Period );
		HMA1_value = HMA( HMA_2nd, HMA1_Period );
		break;

	case "HMA3":
		//HMA1_value = HMA( HMA2_Price, HMA2_Period );
		HMA1_value = HMA( HMA_3rd, HMA2_Period );
		break;

}


//Plot( HMA1_value, "HMA1_value", ParamColor( "Difference color", colorGreen ), ParamStyle( "HMA1_value" ) , Null, Null, 0, 0, 2 );


//factor_value = 0.5;

Diff = abs(HMA_value - HMA1_value);
Diff = Diff * factor_value ;
// Visualize Diff

//Plot( Diff, "Diff", Diff_color, DiffStyle );




first_HMA_Choice = ParamList( "firt_selected_HMA ", "HMA1|HMA2|HMA3" , 0);
Rule = ParamToggle( "Rule ", "+|-" ,0);
// Up and Down Color 
DiffHMAUpColor = ParamColor("Diff_HMA UpColor", colorGreen);
DiffHMADwnColor = ParamColor("Diff_HMA DownColor", colorRed);
DiffHMAStyle =   ParamStyle("Diff-HMA-Style", styleLine | styleNoLabel ) | styleNoLabel;
//_SECTION_END();

// Switch case to get the correct values HMA Based our selection::
switch( first_HMA_Choice )
{
	case "HMA1":
		
		//HMA_value = HMA( HMA_Price, HMA_Period ) + Diff ;
		//HMA_value = IIf( Rule == 0 , HMA( HMA_Price, HMA_Period ) + Diff, HMA( HMA_Price, HMA_Period ) - Diff );
		HMA_value = IIf( Rule == 0 , HMA( HMA_Price , HMA_Period ) + Diff, HMA( HMA_Price , HMA_Period ) - Diff );
		break;

	case "HMA2":
		//HMA_value = HMA( HMA1_Price, HMA1_Period ) + Diff ;
		//HMA_value = IIf( Rule == 0 , HMA( HMA1_Price, HMA1_Period ) + Diff, HMA( HMA1_Price, HMA1_Period ) - Diff );
		HMA_value = IIf( Rule == 0 , HMA( HMA1_Price , HMA1_Period ) + Diff, HMA( HMA1_Price , HMA1_Period ) - Diff );
		break;

	case "HMA3":
		//HMA_value = HMA( HMA2_Price, HMA2_Period ) + Diff ;
		//HMA_value = IIf( Rule == 0 , HMA( HMA2_Price, HMA2_Period ) + Diff, HMA( HMA2_Price, HMA2_Period ) - Diff );
		HMA_value = IIf( Rule == 0 , HMA( HMA2_Price , HMA2_Period ) + Diff, HMA( HMA2_Price , HMA2_Period ) - Diff );
		break;

}




//  That Process to slop up/down of HMA Line
trend3 = 0;

for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( HMA_value[i] > HMA_value[i - 1] )
			trend3[i] = 1;
		else
		{
			if( HMA_value[i] < HMA_value[i - 1] )
				trend3[i] = -1;
			else
				trend3[i] = trend3[i - 1];
		}
	}
	else
		trend3[i] = 0;
}


// Identify Up/Down of HMA line
//trend = UpDwnClr( HMA_value) ; 
updiffHMA = trend3 > 0;
downdiffHMA = trend3 < 0;

//Coloring HMA slop line
DiffHMAColor  = IIf( updiffHMA, DiffHMAUpColor, IIf( downdiffHMA, DiffHMADwnColor, DiffHMAUpColor ) );
// Visualize Diff-HMA
Plot( HMA_value, "Diff_HMA", DiffHMAColor, DiffHMAStyle );



second_HMA_Choice = ParamList( "second_selected_HMA ", "HMA1|HMA2|HMA3" ,0);
Rule1 = ParamToggle( "Rule1 ", "+|-" ,0);

// Up and Down Color 
DiffHMA1UpColor = ParamColor("Diff_HMA1 UpColor", colorGreen);
DiffHMA1DwnColor = ParamColor("Diff_HMA1 DownColor", colorRed);

DiffHMA1Style =  ParamStyle("Diff-HMA1-Style", styleLine | styleNoLabel ) | styleNoLabel;
//_SECTION_END();

// Switch case to get the correct values HMA Based our selection::
switch( second_HMA_Choice )
{
	case "HMA1":
		
		//HMA_value = HMA( HMA_Price, HMA_Period ) + Diff ;
		//HMA1_value = IIf( Rule1 == 0 , HMA( HMA_Price, HMA_Period ) + Diff, HMA( HMA_Price, HMA_Period ) - Diff );
		HMA1_value = IIf( Rule1 == 0 , HMA( HMA_Price, HMA_Period ) + Diff, HMA( HMA_Price, HMA_Period ) - Diff );
		break;

	case "HMA2":
		//HMA_value = HMA( HMA1_Price, HMA1_Period ) + Diff ;
		//HMA1_value = IIf( Rule1 == 0 , HMA( HMA1_Price, HMA1_Period ) + Diff, HMA( HMA1_Price, HMA1_Period ) - Diff );
		HMA1_value = IIf( Rule1 == 0 , HMA( HMA1_Price, HMA1_Period ) + Diff, HMA( HMA1_Price, HMA1_Period ) - Diff );
		break;
		

	case "HMA3":
		//HMA_value = HMA( HMA2_Price, HMA2_Period ) + Diff ;
		//HMA1_value = IIf( Rule1 == 0 , HMA( HMA2_Price, HMA2_Period ) + Diff, HMA( HMA2_Price, HMA2_Period ) - Diff );
		HMA1_value = IIf( Rule1 == 0 , HMA( HMA2_Price, HMA2_Period ) + Diff, HMA( HMA2_Price, HMA2_Period ) - Diff );
		break;

}





//  That Process to slop up/down of HMA Line
trend4 = 0;


for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( HMA1_value[i] > HMA1_value[i - 1] )
			trend4[i] = 1;
		else
		{
			if( HMA1_value[i] < HMA1_value[i - 1] )
				trend4[i] = -1;
			else
				trend4[i] = trend4[i - 1];
		}
	}
	else
		trend4[i] = 0;
}


// Identify Up/Down of HMA line
//trend = UpDwnClr( HMA1_value) ; 
updiffHMA1 = trend4 > 0;
downdiffHMA1 = trend4 < 0;
//Coloring HMA slop line
DiffHMA1Color  = IIf( updiffHMA1, DiffHMA1UpColor, IIf( downdiffHMA1, DiffHMA1DwnColor, DiffHMA1UpColor ) );
// Visualize Diff-HMA1
Plot( HMA1_value, "Diff_HMA1" , DiffHMA1Color, DiffHMA1Style );

Hello ahm.montaser,

please check out this ... what the hack you are doing :wink: ...

you have to use a AFL structure like this

_SECTION_BEGIN("HMA 1 Section");
// your code ...
_SECTION_END();

_SECTION_BEGIN("HMA 2 Section");
// your code ...
_SECTION_END();

_SECTION_BEGIN("HMA 3 Section");
// your code ...
_SECTION_END();

_SECTION_BEGIN("HMA 4 Section");
// your code ...
_SECTION_END();

_SECTION_BEGIN("HMA 5 Section");
// your code ...
_SECTION_END();

_SECTION_BEGIN("HMA 6 Section");
// your code ...
_SECTION_END();

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( Close, "", ParamColor( "Color", colorDefault ), styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );

// ... only to var init by "Delete indicator" via AB ChartWindow --------------------------------------------------------------------------------
hma_price = hma1_price = hma2_price = hma_2nd = hma_3rd = C;
hma_period = hma1_period = hma2_period = 25;
Diff = 1;

_SECTION_BEGIN("HMA 1 Section");

//===============================================================================================================================================
//===============================================================================================================================================
//===============================================================================================================================================

HMA_Pricep  = ParamList( "HMA Price", "Open|High|Low|Last|Average|Volume|Vwap" , 0);
HMA_Period = Param( "HMA period", 25, 10, 100 );
HMAUpColor  = ParamColor("HMA UpColor", colorGreen);
HMADwnColor = ParamColor("HMA DownColor", colorRed);
HMAStyle =  ParamStyle("HMA Style", styleLine | styleNoLabel ) | styleNoLabel;

//HMA_Price  = ParamField( "HMA Price", 0 );

// Switch case to get the correct values of Field Price without any duplication as Built parafield::
switch( HMA_Pricep )
{
	case "Open":
		HMA_Price = O;
		break;

	case "High":
		HMA_Price = H;
		break;

	case "Low":
		HMA_Price =L;
		break;

	case "Last":
		HMA_Price = C;
		break;
		
	case "Average":
		HMA_Price = (( H + L + C ) / 3);
		break;
		
	case "Volume":
		HMA_Price = V;
		break;
		
	case "Vwap":
		HMA_Price = OpenInt;
		break;

}

HMA_1st = HMA( HMA_Price, HMA_Period ); 

//  That Process to slop up/down of HMA Line
trend = 0;

for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( HMA_1st[i] > HMA_1st[i - 1] )
			trend[i] = 1;
		else
		{
			if( HMA_1st[i] < HMA_1st[i - 1] )
				trend[i] = -1;
			else
				trend[i] = trend[i - 1];
		}
	}
	else
		trend[i] = 0;
}

// Identify Up/Down of HMA line
//trend   = UpDwnClr( HMA_1st) ; 
upHMA   = trend > 0;
downHMA = trend < 0;

//Coloring HMA slop Up/Down line
HMAColor  = IIf( upHMA, HMAUpColor, IIf( downHMA, HMADwnColor, HMAUpColor ) );

Plot( HMA_1st, "HMA", HMAColor, HMAStyle );

_SECTION_END();

_SECTION_BEGIN("HMA 2 Section");

//===============================================================================================================================================
//===============================================================================================================================================
//===============================================================================================================================================

HMA1_Pricep  = ParamList( "HMA1 Price", "Open|High|Low|Last|Average|Volume|Vwap" , 3);
HMA1_Period = Param( "HMA1 period", 25, 10, 100 );
HMA1UpColor  = ParamColor("HMA1 UpColor", colorGreen);
HMA1DwnColor = ParamColor("HMA1 DownColor", colorRed);
HMA1Style =  ParamStyle("HMA1 Style", styleLine | styleNoLabel ) | styleNoLabel;

//HMA_Price  = ParamField( "HMA Price", 0 );

// Switch case to get the correct values of Field Price without any duplication as Built parafield::
switch( HMA1_Pricep )
{
	case "Open":
		HMA1_Price = O;
		break;

	case "High":
		HMA1_Price = H;
		break;

	case "Low":
		HMA1_Price =L;
		break;

	case "Last":
		HMA1_Price = C;
		break;
		
	case "Average":
		HMA1_Price = (( H + L + C ) / 3);
		break;
		
	case "Volume":
		HMA1_Price = V;
		break;
		
	case "Vwap":
		HMA1_Price = OpenInt;
		break;

}

HMA_2nd= HMA( HMA1_Price, HMA1_Period );   

//  That Process to slop up/down of HMA Line
trend1 = 0;

for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( HMA_2nd[i] > HMA_2nd[i - 1] )
			trend1[i] = 1;
		else
		{
			if( HMA_2nd[i] < HMA_2nd[i - 1] )
				trend1[i] = -1;
			else
				trend1[i] = trend1[i - 1];
		}
	}
	else
		trend1[i] = 0;
}

// Identify Up/Down of HMA line
//trend   = UpDwnClr( HMA_1st) ; 
upHMA1   = trend1 > 0;
downHMA1 = trend1 < 0;

//Coloring HMA slop Up/Down line
HMA1Color  = IIf( upHMA1, HMA1UpColor, IIf( downHMA1, HMA1DwnColor, HMA1UpColor ) );

Plot( HMA_2nd, "HMA1", HMA1Color, HMA1Style );

_SECTION_END();

_SECTION_BEGIN("HMA 3 Section");

//===============================================================================================================================================
//===============================================================================================================================================
//===============================================================================================================================================

HMA2_Pricep  = ParamList( "HMA Price", "Open|High|Low|Last|Average|Volume|Vwap" , 2);
HMA2_Period = Param( "HMA2 period", 25, 10, 100 );
HMA2UpColor  = ParamColor("HMA2 UpColor", colorGreen);
HMA2DwnColor = ParamColor("HMA2 DownColor", colorRed);
HMA2Style =  ParamStyle("HMA2 Style", styleLine | styleNoLabel ) | styleNoLabel;

//HMA_Price  = ParamField( "HMA Price", 0 );

// Switch case to get the correct values of Field Price without any duplication as Built parafield::
switch( HMA2_Pricep )
{
	case "Open":
		HMA2_Price = O;
		break;

	case "High":
		HMA2_Price = H;
		break;

	case "Low":
		HMA2_Price =L;
		break;

	case "Last":
		HMA2_Price = C;
		break;
		
	case "Average":
		HMA2_Price = (( H + L + C ) / 3);
		break;
		
	case "Volume":
		HMA2_Price = V;
		break;
		
	case "Vwap":
		HMA2_Price = OpenInt;
		break;

}

HMA_3rd = HMA( HMA2_Price, HMA2_Period ); 

//  That Process to slop up/down of HMA Line
trend2 = 0;

for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( HMA_3rd[i] > HMA_3rd[i - 1] )
			trend2[i] = 1;
		else
		{
			if( HMA_3rd[i] < HMA_3rd[i - 1] )
				trend2[i] = -1;
			else
				trend2[i] = trend2[i - 1];
		}
	}
	else
		trend2[i] = 0;
}

// Identify Up/Down of HMA line
//trend   = UpDwnClr( HMA_1st) ; 
upHMA2  = trend2 > 0;
downHMA2 = trend2 < 0;

//Coloring HMA slop Up/Down line
HMA2Color  = IIf( upHMA2, HMA2UpColor, IIf( downHMA2, HMA2DwnColor, HMA2UpColor ) );

Plot( HMA_3rd, "HMA2", HMA2Color, HMA2Style );

_SECTION_END();

_SECTION_BEGIN("HMA 4 Section");

//===============================================================================================================================================
//===============================================================================================================================================
//===============================================================================================================================================

first_HMA_Choice = ParamList( "firt_selected_HMA ", "HMA1|HMA2|HMA3" ,0);
// select the 2nd HMA for get Diff value ::
second_HMA_Choice = ParamList( "second_selected_HMA ", "HMA1|HMA2|HMA3" ,0);

// Factor value::
factor_value = Param( "factor_value", 0.5, 0, 100 ,0.1);
Diff_color = ParamColor( "Diff color", colorGreen ) ;
DiffStyle =  ParamStyle("Diff-Style", styleLine | styleNoLabel ) | styleNoLabel;

// Switch case to get the correct values HMA Based our selection::
switch( first_HMA_Choice )
{
	case "HMA1":
		//HMA_value = HMA( HMA_Price, HMA_Period );
		HMA_value = HMA( HMA_Price , HMA_Period );
		
		break;

	case "HMA2":
		//HMA_value = HMA( HMA1_Price, HMA1_Period );
		HMA_value = HMA( HMA_2nd , HMA1_Period );
		break;

	case "HMA3":
		//HMA_value = HMA( HMA2_Price, HMA2_Period );
		HMA_value = HMA( HMA_3rd , HMA2_Period );
		
		break;

}

//Plot( HMA_value, "HMA_value", ParamColor( "Difference color", colorBlue ),  ParamStyle( "HMA1_value" ) , Null, Null, 0, 0, 2);

// Switch case to get the correct values HMA Based our selection::
switch( second_HMA_Choice )
{
	case "HMA1":
		//HMA1_value = HMA( HMA_Price, HMA_Period );
		HMA1_value = HMA( HMA_Price , HMA_Period );
		break;

	case "HMA2":
		//HMA1_value = HMA( HMA1_Price, HMA1_Period );
		HMA1_value = HMA( HMA_2nd, HMA1_Period );
		break;

	case "HMA3":
		//HMA1_value = HMA( HMA2_Price, HMA2_Period );
		HMA1_value = HMA( HMA_3rd, HMA2_Period );
		break;

}

//Plot( HMA1_value, "HMA1_value", ParamColor( "Difference color", colorGreen ), ParamStyle( "HMA1_value" ) , Null, Null, 0, 0, 2 );

//factor_value = 0.5;

Diff = abs(HMA_value - HMA1_value);
Diff = Diff * factor_value ;
// Visualize Diff

//Plot( Diff, "Diff", Diff_color, DiffStyle );

_SECTION_END();

_SECTION_BEGIN("HMA 5 Section");

//===============================================================================================================================================
//===============================================================================================================================================
//===============================================================================================================================================

first_HMA_Choice = ParamList( "firt_selected_HMA ", "HMA1|HMA2|HMA3" , 0);
Rule = ParamToggle( "Rule ", "+|-" ,0);
// Up and Down Color 
DiffHMAUpColor = ParamColor("Diff_HMA UpColor", colorGreen);
DiffHMADwnColor = ParamColor("Diff_HMA DownColor", colorRed);
DiffHMAStyle =   ParamStyle("Diff-HMA-Style", styleLine | styleNoLabel ) | styleNoLabel;

// Switch case to get the correct values HMA Based our selection::
switch( first_HMA_Choice )
{
	case "HMA1":
		
		//HMA_value = HMA( HMA_Price, HMA_Period ) + Diff ;
		//HMA_value = IIf( Rule == 0 , HMA( HMA_Price, HMA_Period ) + Diff, HMA( HMA_Price, HMA_Period ) - Diff );
		HMA_value = IIf( Rule == 0 , HMA( HMA_Price , HMA_Period ) + Diff, HMA( HMA_Price , HMA_Period ) - Diff );
		break;

	case "HMA2":
		//HMA_value = HMA( HMA1_Price, HMA1_Period ) + Diff ;
		//HMA_value = IIf( Rule == 0 , HMA( HMA1_Price, HMA1_Period ) + Diff, HMA( HMA1_Price, HMA1_Period ) - Diff );
		HMA_value = IIf( Rule == 0 , HMA( HMA1_Price , HMA1_Period ) + Diff, HMA( HMA1_Price , HMA1_Period ) - Diff );
		break;

	case "HMA3":
		//HMA_value = HMA( HMA2_Price, HMA2_Period ) + Diff ;
		//HMA_value = IIf( Rule == 0 , HMA( HMA2_Price, HMA2_Period ) + Diff, HMA( HMA2_Price, HMA2_Period ) - Diff );
		HMA_value = IIf( Rule == 0 , HMA( HMA2_Price , HMA2_Period ) + Diff, HMA( HMA2_Price , HMA2_Period ) - Diff );
		break;

}

//  That Process to slop up/down of HMA Line
trend3 = 0;

for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( HMA_value[i] > HMA_value[i - 1] )
			trend3[i] = 1;
		else
		{
			if( HMA_value[i] < HMA_value[i - 1] )
				trend3[i] = -1;
			else
				trend3[i] = trend3[i - 1];
		}
	}
	else
		trend3[i] = 0;
}

// Identify Up/Down of HMA line
//trend = UpDwnClr( HMA_value) ; 
updiffHMA = trend3 > 0;
downdiffHMA = trend3 < 0;

//Coloring HMA slop line
DiffHMAColor  = IIf( updiffHMA, DiffHMAUpColor, IIf( downdiffHMA, DiffHMADwnColor, DiffHMAUpColor ) );
// Visualize Diff-HMA
Plot( HMA_value, "Diff_HMA", DiffHMAColor, DiffHMAStyle );

_SECTION_END();

_SECTION_BEGIN("HMA 6 Section");

//===============================================================================================================================================
//===============================================================================================================================================
//===============================================================================================================================================

second_HMA_Choice = ParamList( "second_selected_HMA ", "HMA1|HMA2|HMA3" ,0);
Rule1 = ParamToggle( "Rule1 ", "+|-" ,0);

// Up and Down Color 
DiffHMA1UpColor = ParamColor("Diff_HMA1 UpColor", colorGreen);
DiffHMA1DwnColor = ParamColor("Diff_HMA1 DownColor", colorRed);

DiffHMA1Style =  ParamStyle("Diff-HMA1-Style", styleLine | styleNoLabel ) | styleNoLabel;

// Switch case to get the correct values HMA Based our selection::
switch( second_HMA_Choice )
{
	case "HMA1":
		
		//HMA_value = HMA( HMA_Price, HMA_Period ) + Diff ;
		//HMA1_value = IIf( Rule1 == 0 , HMA( HMA_Price, HMA_Period ) + Diff, HMA( HMA_Price, HMA_Period ) - Diff );
		HMA1_value = IIf( Rule1 == 0 , HMA( HMA_Price, HMA_Period ) + Diff, HMA( HMA_Price, HMA_Period ) - Diff );
		break;

	case "HMA2":
		//HMA_value = HMA( HMA1_Price, HMA1_Period ) + Diff ;
		//HMA1_value = IIf( Rule1 == 0 , HMA( HMA1_Price, HMA1_Period ) + Diff, HMA( HMA1_Price, HMA1_Period ) - Diff );
		HMA1_value = IIf( Rule1 == 0 , HMA( HMA1_Price, HMA1_Period ) + Diff, HMA( HMA1_Price, HMA1_Period ) - Diff );
		break;
		

	case "HMA3":
		//HMA_value = HMA( HMA2_Price, HMA2_Period ) + Diff ;
		//HMA1_value = IIf( Rule1 == 0 , HMA( HMA2_Price, HMA2_Period ) + Diff, HMA( HMA2_Price, HMA2_Period ) - Diff );
		HMA1_value = IIf( Rule1 == 0 , HMA( HMA2_Price, HMA2_Period ) + Diff, HMA( HMA2_Price, HMA2_Period ) - Diff );
		break;

}

//  That Process to slop up/down of HMA Line
trend4 = 0;

for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( HMA1_value[i] > HMA1_value[i - 1] )
			trend4[i] = 1;
		else
		{
			if( HMA1_value[i] < HMA1_value[i - 1] )
				trend4[i] = -1;
			else
				trend4[i] = trend4[i - 1];
		}
	}
	else
		trend4[i] = 0;
}

// Identify Up/Down of HMA line
//trend = UpDwnClr( HMA1_value) ; 
updiffHMA1 = trend4 > 0;
downdiffHMA1 = trend4 < 0;
//Coloring HMA slop line
DiffHMA1Color  = IIf( updiffHMA1, DiffHMA1UpColor, IIf( downdiffHMA1, DiffHMA1DwnColor, DiffHMA1UpColor ) );
// Visualize Diff-HMA1
Plot( HMA1_value, "Diff_HMA1" , DiffHMA1Color, DiffHMA1Style );

_SECTION_END();

AB_section_begin_end_param

Best regards,
Peter

@ahm.montaser at line 164 of your formula you have a duplicate param "label" that produces the result as per your screenshot:

HMA2_Pricep  = ParamList( "HMA Price", "Open|High|Low|Last|Average|Volume|Vwap" , 2);

Should be:

HMA2_Pricep  = ParamList( "HMA2 Price", "Open|High|Low|Last|Average|Volume|Vwap" , 2);

You really need to read the manual.

You should NOT delete/modify _SECTION_BEGIN/_SECTION_END in your formulas.
Leave them untouched as they are. You should not also add those calls to your formulas because they ARE CREATED for you by AmiBroker when you use drag and drop.

These functions are meant to be ADDED BY AmiBroker itself, when doing drag/drop / insert operations as documented in the manual:

https://www.amibroker.com/guide/h_dragdrop.html

(read this ENTIRELY and carefully including last FAQ section).

_SECTION_BEGIN/_SECTION_END mechanism should be left alone to be maintaned by AmiBroker. It is needed to allow AmiBroker to insert/delete indicator parts as well it is used for properly handling multiple insertions of same indicator with different parameter values. Parameter are KEYED using sections names, so again DON'T TOUCH _SECTION functions as they are inserted by AmiBroker.

2 Likes

Okay, thanks for your efforts

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