ParamField built in function

Hello everyone,

when I use Field Price built in function to get Price value to draw Indicator on price chart, its return duplication of close price, why? and How to ignore that duplication?

hmaPeriod = Param( "HMA Period", 20, 1, 200 );
hmaPrice = ParamField( "HMA Price Field", 0 );

paramters

@ahm.montaser, to get an appropriate answer I think you need to better specify what you do (and/or what formula you use) to trigger this duplication problem (which I have never seen using the ParamField() function).

ParamField displays fields that are used in PREVIOUS Plot() statements in your formula, plus standard OHLC prices. Apparently you are using OHLC in your own formula before.

But really you did NOT provide ENTIRE formula so it is guessing game.

Unfortunately your question isn't clear enough and does not provide all necessary details to give you an answer. Please follow this advice: How to ask a good question

thanks, Tomasz
I solved the Isusse but have another question,
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 );

You should NOT delete/modify _SECTION_BEGIN/_SECTION_END in your formulas.
Leave them untouched as they are.

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.

Topic closed because duplicate has been created.