help. Basic to afl trouble

#1
I have converted this basic to afl with no results.

Can you tell me where is the error?

The original one is:

rem filter stop 1% below wmm30 in bull market
if close>weightedaverage[30](close) then
a=weightedaverage[30](close)-weightedaverage[30](close)/100
rem distance with the stop point
distanciamm30=close-a
remou maximun amount of money you can loose(v variable)
v=292
b=v/distanciamm30
endif
if close<weightedaverage[30](close) then
a=weightedaverage[30](close)+weightedaverage[30](close)/100

rem distance from the stop point to the close
distanciamm30=close-a
b=v/distanciamm30
cero=0
endif
return cero, b as "shares"

AND THIS IS THE AFL TRANSCRIPCION.:


I know that it is incorrect couse does not show the same result

// filtro stop 1% por debajo de mm30 en mercado alcista

mm30=WMA(Close,30);
x=Close;
IIf (x>mm30,colorBlue,styleLine);
a=(mm30-mm30)/100;
// distancia del cierre con punto de stop
distanciamm30=Close-a;

// numero de acciones segun riesgo en dinero asumible(variable V)
V=292;
b=V/distanciamm30;

IIf (Close<mm30,colorRed,styleLine) ;
a=mm30+mm30/100;

// distancia del punto stop al cierre
distanciamm30=Close-a;

b=V/distanciamm30;
cero=0;

Plot(b,"Acciones", colorRed);
Plot(Cero,"0",colorBlue,styleLine);
 

KelvinHand

Well-Known Member
#2
I have converted this basic to afl with no results.

Can you tell me where is the error?

The original one is:

rem filter stop 1% below wmm30 in bull market
if close>weightedaverage[30](close) then
a=weightedaverage[30](close)-weightedaverage[30](close)/100
rem distance with the stop point
distanciamm30=close-a
remou maximun amount of money you can loose(v variable)
v=292
b=v/distanciamm30
endif
if close<weightedaverage[30](close) then
a=weightedaverage[30](close)+weightedaverage[30](close)/100

rem distance from the stop point to the close
distanciamm30=close-a
b=v/distanciamm30
cero=0
endif
return cero, b as "shares"

AND THIS IS THE AFL TRANSCRIPCION.:


I know that it is incorrect couse does not show the same result

// filtro stop 1% por debajo de mm30 en mercado alcista

mm30=WMA(Close,30);
x=Close;
IIf (x>mm30,colorBlue,styleLine);
a=(mm30-mm30)/100;
// distancia del cierre con punto de stop
distanciamm30=Close-a;

// numero de acciones segun riesgo en dinero asumible(variable V)
V=292;
b=V/distanciamm30;

IIf (Close<mm30,colorRed,styleLine) ;
a=mm30+mm30/100;

// distancia del punto stop al cierre
distanciamm30=Close-a;

b=V/distanciamm30;
cero=0;

Plot(b,"Acciones", colorRed);
Plot(Cero,"0",colorBlue,styleLine);
PHP:
mm30=WMA(Close,30);

x = IIf (Close>mm30, -1, IIf (Close<mm30, 1, 0));
a =mm30+x*mm30/100;

vv=292;
b=vv/(Close-a);

cero=0;

Plot(b,"Acciones", colorRed);
Plot(Cero,"0",colorBlue,styleLine);
 
Last edited:

vishnu_1990v

Well-Known Member
#3
Kelvinhand Sir,
An AFL code required for cci(14) dotted horizontal lines for values of 0,50,100, -50, and -100, different colors for different values.
For values of 250 and -250 same colors. {All colors required thick dotted lines.}
Warm Regards,
Vishnu_1990v
 

KelvinHand

Well-Known Member
#4
Kelvinhand Sir,
An AFL code required for cci(14) dotted horizontal lines for values of 0,50,100, -50, and -100, different colors for different values.
For values of 250 and -250 same colors. {All colors required thick dotted lines.}
Warm Regards,
Vishnu_1990v
I only bother to help those that try to write the script and failed.
This one is too simple. Learn it yourself. No excuse for "I am new" or "I don't know programming".
Otherwise, wait for other that willing to write free for you.


Examples of repetitive routines

1. ex. Plot the CCI

If you need changing period then
Per = Param("Period", 14, ....);
indy = CCI(Per);
else
indy = CCI(14);


Plot(indy,....);




2. Plot the Grid if not thick dashed required
PlotGrid(-50, colorRed);

3. Plot if other style required
Plot(255, "", colorDarkYellow, styleThick|styleDashed|styleNoLabel);
 
Last edited:
#5
PHP:
_SECTION_BEGIN("CCI");
/* -- Am I Smart ??? --------------------------------------------------
  An AFL code for cci(14) 
   - dotted horizontal lines for 0,50,100, -50, and -100, 
   - different colors for different values.
   - 250 and -250 same colors. 
   - {All colors required thick dotted lines.}
------------------------------------------------------------------------*/

SetChartBkGradientFill( 
	ParamColor("Background Top", colorBlack),
	ParamColor("Background Bottom", colorBlack));
	

per=Param("Period", 14,1,100);

ccicolor = ParamColor("CCI", colorWhite);
levelstyle =ParamStyle("Level Style", styleThick|styleDashed|styleNoRescale);

L0Color = ParamColor("0", colorGrey40);
L50UColor = ParamColor("+50", colorDarkGreen);
L50DColor = ParamColor("-50", colorDarkRed);
L100UColor = ParamColor("+100", colorGreen);
L100DColor = ParamColor("-100", colorRed);
L250Color = ParamColor("+/-250", colorDarkYellow);


Plot(CCI(per), "CCI", ccicolor, styleLine);

Plot(0, "",  L0Color, levelstyle );

Plot(50, "", L50UColor, Levelstyle );
Plot(-50, "",L50DColor, levelstyle);

Plot(100, "",L100UColor, levelstyle);
Plot(-100, "",L100DColor, levelstyle);

Plot(250, "",L250Color, levelstyle);
Plot(-250, "",L250Color, levelstyle);

_SECTION_END();
 

anjanbm

Active Member
#7
AmiSmart ,
Please give afl code of dashed lines with different colors for different times frames for 60min pvt, 30min pvt and 15min pvt separate dashed lines when applied on 5min charts.
anjanbm
 

Similar threads