Simple Coding Help - No Promise.

Hey There!

How could be an AFL approach to use from a given numbering series selectable from a PARAMLIST("SERIES","FIBO4|LUCAS",1); only to display as selectable periods "PARAM()" that could contain each one ONLY its sequencing (steps) numberings:

FIBO4: 4,8,12,20,32,etc... or;
LUCAS: 2,3,4,7,11,18,etc...

This ones, for example, to be used as a Period NUMBER array for Moving Averages or any other indicator tu use them as PERIODS.

Thanks in Advance!
 
Last edited:

trash

Well-Known Member
Code:
SetOption( "MaxOpenPositions", 50 );
SetPositionSize( 2, spsPercentofequity );

RSILength = 14;   
RSIBuyLevel = 30; 
RSI4 = RSIa( C, RSILength );    

tradedelay = 0; // entry bar delay    
if ( tradedelay > 0 )
{
    pricearray = Open;
}
else
{
    pricearray = Close;
}
 
Buy = Ref( RSI4 < RSIBuyLevel, -tradedelay );
BuyPrice = pricearray;

Sell = 0;
SellPrice = O; // Sell at open price 

//sell 5 bars after purchase 
ApplyStop( stopTypeNBar, 
           stopModeBars, 
           amount = 5, 
           nbarpriority = true, 
           volatile = False, 
           reentrydelay = 0 );
It works. Proof is here

 
Hey There!

How could be an AFL approach to use from a given numbering series selectable from a PARAMLIST("SERIES","FIBO4|LUCAS",1); only to display as selectable periods "PARAM()" that could contain each one ONLY its sequencing (steps) numberings:

FIBO4: 4,8,12,20,32,etc... or;
LUCAS: 2,3,4,7,11,18,etc...

This ones, for example, to be used as a Period NUMBER array for Moving Averages or any other indicator tu use them as PERIODS.

Thanks in Advance!
You can use StrExtract function and as many parallel configured arrays as you may need. Each parallel array must have same number of comma separated elements to avoid freaky situations.

FIBO4 = "4,8,12,20,32";
LUCAS = "2,3,4,7,11,18";

c1 = StrExtract(FIBO4, 3); // Will set string "12" in c1
c2 = StrExtract(LUCAS, 5); // Will set string "11" in c2
 

trash

Well-Known Member
You can use StrExtract function and as many parallel configured arrays as you may need. Each parallel array must have same number of comma separated elements to avoid freaky situations.
StrExtract starts counting at zero. So in order to choose 3rd and 5th element of string,

c1 = StrExtract(FIBO4, 2); // Will set string "12" in c1
c2 = StrExtract(LUCAS, 4); // Will set string "11" in c2
 

lvgandhi

Well-Known Member
I would like to plot horizontal line for previous day's high low and close of last visible bar's date, not current day's previous day.
ie for example if current day is today and in amibroker last visible bar's day is 7th Nov, I would like to plot 5th Nov high low and close.
Any help will be appreciated.
 
Thanks for your sugestion @mastermind007 and @Trash but still don't know if this StrExtract array can be used as the "step" selectable numbers from a PARAM() function. If I use this approach nested for a PARAM() function like this:

Code:
FIBO = "4,8,12,20,32";

c1 = StrExtract(FIBO, 3); // Will set string "20" in c1

PER = ParamList("Periods",c1);												MA1 = MA(P,PER);
AFL Editor still gives me: "Error 5. Argument #2 has incorrect type (the function expects different argument type here.)"

...

You can use StrExtract function and as many parallel configured arrays as you may need. Each parallel array must have same number of comma separated elements to avoid freaky situations.
Thank you guys!
 

trash

Well-Known Member
Thanks for your sugestion @mastermind007 and @Trash but still don't know if this StrExtract array can be used as the "step" selectable numbers from a PARAM() function. If I use this approach nested for a PARAM() function like this:

Code:
FIBO = "4,8,12,20,32";

c1 = StrExtract(FIBO, 3); // Will set string "20" in c1

PER = ParamList("Periods",c1);												MA1 = MA(P,PER);
AFL Editor still gives me: "Error 5. Argument #2 has incorrect type (the function expects different argument type here.)"

...



Thank you guys!
ParamList returns string not number so in your case it needs to be converted to number.

But you don't need strextract. Just use:

Code:
x = ParamToggle( "SERIES", "FIBO4|LUCAS", 1 ); 
PER1 = ParamList( "Periods FIBO4", "4,8,12,20,32" ); 
PER2 = ParamList( "Periods LUCAS", "2,3,4,7,11,18" );

if( x )
    per = StrToNum(per2);
else
    per = StrToNum(per1);
 
Last edited:
StrExtract starts counting at zero. So in order to choose 3rd and 5th element of string,

c1 = StrExtract(FIBO4, 2); // Will set string "12" in c1
c2 = StrExtract(LUCAS, 4); // Will set string "11" in c2
Yes! I normally start my array string as ",..." to avoid this. Good of you to spot this!!
 

Similar threads