I can Create AFL but Need Strategy

the following are the coding done for the esignal backtesting for the bollinger indicator (%b) - entry -exit - stoploss - target .

PROGRAM

global variable Declaration :

Var xUpper=null;
Var xLower=null;
Var Stop=null;
Var Target=null;
Var bInit=false;

function main()
{
if(getCurrentBarIndex()==0)
return;
if(bInit==false)
xUpper=Upperbollingerband(10);
xlower=Lowerbollingerband(10);
bInit=true;
}
return new Array(xUpper.getvalue(0), Xlower.getvalue(0));

Var nU=xUpper.getvalue(-1);
Var nL=xLower.getvalue(-1);
if(nU==null || nL==null)
return;
if(Strategy.isLong()==false && Low(0)<=nL)
{
Strategy.doLong("Long Signal",Strategy.LIMIT , Strategy.THISBAR, Strategy.DEFAULT , Math.Min(nL ,open(0));
elseif(Strategy.isShort()==false && high(0)>=nU)
{
Strategy.doShort("Short Signal ", Strategy.LIMIT , Strategy.THISBAR , Strategy.DEFAULT , Math.max(nU,open(0));
}
}
stop = Entry - 3*ATR(10);
Target =Entry+5*ATR(10);
}


Plz check the code , i am getting compling and execution problem for the backtesting code . can anyone correct the mistakes .Revert me back with right executsble code.

hari prasad
mail : [email protected]
 
Hi friedns,

Here i have one formula its very usefull for del trading but its messing buy sell arrow so its not possible to auto analysis please add buy sell arrow so i can scan with auto analysis

Buy condition -: if candle color is blue buy.
Sell condition -: If candle color is oreng sell

Formula is below

_SECTION_BEGIN("YPF");
EntrySignal = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) );
ExitSignal = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) );
Color = IIf( EntrySignal, colorAqua, IIf( ExitSignal, colorOrange, colorGrey50 ));
TrailStop = HHV( C - 2 * ATR(10), 15 );
ProfitTaker = EMA( H, 13 ) + 2 * ATR(10);
/* plot price chart and stops */
Plot( C, "Price", Color, styleCandle | styleThick );
/* plot color ribbon */
Plot( 1, "", Color, styleArea | styleOwnScale | styleNoLabel, -0.1, 50 );
BanlanceSignal = ( LLV( L, 20 ) + 2 * ATR( 10 ) );
TYP=(High + Low + 2*Close)/4;
CI=(TYP-MA(TYP,14))/(0.015*StDev(TYP,14));
EM2=EMA(CI,5);

// Sigma
Var1=EMA((Close-Ref(Close,-5))/Ref(Close,-5),5);
Var2=EMA((Close-Ref(Close,-20))/Ref(Close,-20),3);
Var3=EMA((Close-Ref(Close,-30))/Ref(Close,-30),3);

G1= EMA(Var1,5);
G2= EMA(Var2,20);
G3= EMA(Var3,30);

Buy=EM2<-80 AND EM2>Ref(EM2,-1) AND Ref(EM2,-1)<=Ref(EM2,-2)AND G1>Ref(G1,-1);
PlotShapes( IIf( Buy, shapeDigit0, shapeNone ), colorBrightGreen ,layer = 0, yposition = C, offset = -20 );
Sell=IIf( EntrySignal, colorAqua, IIf( ExitSignal, colorOrange, colorGrey50 ));
_SECTION_END();



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



Thanks in advance
 

Blackhole

Well-Known Member
I need some some in afl, hope

like i want to start trade nifty with 200 unit (8 lots) and start booking profit after

25 point book 50 %
25point book 25%
25 point book 25%

if in any case prf booking missed selll or cover entire position in reverse trend or move sl in afl

if incurred loss increase by 2 lot in our case 250 : 10 lots, if again loss increase by 2 lots.........


only intraday....ie 4 loss in same day 4 times lot is increased, if entire day is in loss...next day trading with same lot size....\\\\



i searched on net and download some codes with scale in and outbut got errors and its not working.

....same code with pyramiding....ie instead of booking profit it should add at regular internals and then sell off.....




thanks
 

Similar threads