Afl help

mrm

New Member
#1
I HAVE THIS AFL
PERCENT RANK FOR ATR
I'm getting error Ln27 col:2Error 31 Syntax error
I can't figure out what is wrong
Can someone please help to correct error
//PercentRank Function
//As Coded by Ramon Cummins
/*function PercentRank( Data, Periods )
{
Count = 0;
for ( i = 1; i < Periods + 1 ; i++ )
{
Count = Count + IIf ( Ref( Data, 0 ) > Ref( Data, -i ), 1, 0 );
}
return 100 * Count / Periods;


}*/

//Now, lets use the function to rank Average True Range in percentage terms relative to previous ATRs.
//Define ATR as a percentage
ATR_Percentage=(ATR(10)/C)*100;
//Here we define the lookback period (30 days) to compare current to previous ATR%

RankPeriods = Param("PercentRankLookback Periods”, 30,5,252,5 );

//Here we use the Percentank function to rank the ATR% relative to previous ATR%s
ATR_Bounded = PercentRank( ATR_Percentage, RankPeriods );
if ( ParamToggle( “Show ATR_Bounded”, “No|Yes”, 1 )== 1 )
{
Plot( ATR_Bounded, _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle( “Style” ) );
}
Thank you
 

KelvinHand

Well-Known Member
#2
I HAVE THIS AFL
PERCENT RANK FOR ATR
I'm getting error Ln27 col:2Error 31 Syntax error
I can't figure out what is wrong
Can someone please help to correct error
//PercentRank Function
//As Coded by Ramon Cummins
/*function PercentRank( Data, Periods )
{
Count = 0;
for ( i = 1; i < Periods + 1 ; i++ )
{
Count = Count + IIf ( Ref( Data, 0 ) > Ref( Data, -i ), 1, 0 );
}
return 100 * Count / Periods;


}*/

//Now, lets use the function to rank Average True Range in percentage terms relative to previous ATRs.
//Define ATR as a percentage
ATR_Percentage=(ATR(10)/C)*100;
//Here we define the lookback period (30 days) to compare current to previous ATR%

RankPeriods = Param("PercentRankLookback Periods”, 30,5,252,5 );

//Here we use the Percentank function to rank the ATR% relative to previous ATR%s
ATR_Bounded = PercentRank( ATR_Percentage, RankPeriods );
if ( ParamToggle( “Show ATR_Bounded”, “No|Yes”, 1 )== 1 )
{
Plot( ATR_Bounded, _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle( “Style” ) );
}
Thank you
remove line 27: ==1
 

mrm

New Member
#3
kELVIN,
Your sugestion did not solve problem.I was able to find error later after I post it request for help
Thank you for trying to help
Emil
 

mastermind007

Well-Known Member
#4
I HAVE THIS AFL
PERCENT RANK FOR ATR
I'm getting error Ln27 col:2Error 31 Syntax error
I can't figure out what is wrong
Can someone please help to correct error
//PercentRank Function
//As Coded by Ramon Cummins
/*function PercentRank( Data, Periods )
{
Count = 0;
for ( i = 1; i < Periods + 1 ; i++ )
{
Count = Count + IIf ( Ref( Data, 0 ) > Ref( Data, -i ), 1, 0 );
}
return 100 * Count / Periods;


}*/

//Now, lets use the function to rank Average True Range in percentage terms relative to previous ATRs.
//Define ATR as a percentage
ATR_Percentage=(ATR(10)/C)*100;
//Here we define the lookback period (30 days) to compare current to previous ATR%

RankPeriods = Param("PercentRankLookback Periods”, 30,5,252,5 );

//Here we use the Percentank function to rank the ATR% relative to previous ATR%s
ATR_Bounded = PercentRank( ATR_Percentage, RankPeriods );
if ( ParamToggle(Show ATR_Bounded, “No|Yes”, 1 )== 1 )
{
Plot( ATR_Bounded, _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle( “Style” ) );
}
Thank you
All the double quotes in your AFL are actually accented characters which Ami does not recognize. If you see properly, they are either slanting left or right. Correct char (for Ami) will slant in neither direction. See the ParamToggle line where I've red-colored the characters. Using notepad (or Ami's own editor), retype each quote. Search replace will not work.

Lastly, replace _DEFAULT_NAME() in Plot line with "ATR".
 
Last edited:

mastermind007

Well-Known Member
#6

Similar threads