Need help from Seniors urgently!!!Pl

#1
I am giving an AFL code below.

_SECTION_BEGIN("Price");
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 ) ) ));
_SECTION_END();

SetChartOptions(0, chartShowDates | chartWrapTitle);
GfxTextOut("5 Candle Calculation", 43, 60);

E5 = EMA(Close, 5);
E34 = EMA(Close, 34);

BTrig = Cross(E5, E34);
STrig = Cross(E34, E5);

BT = Flip(BTrig, STrig);
ST = Flip(STrig, BTrig);

B_High = ValueWhen(Btrig,(H + (H*.001)), 1);
S_Low = ValueWhen(STrig, (L - (L*.001)), 1);

BuyPrice=ValueWhen(Btrig, (H + .001), 1);
SellPrice=ValueWhen(STrig, (L -.001), 1);

Buytarget = (BuyPrice*2)-Ref(L, -5);
Buysl=Ref(L,-5);

Selltarget= (SellPrice*2)-(Ref(H, -5));
Sellsl=Ref(H, -5);

Buy = BT AND H > B_High;
Sell= Buytarget OR Buysl;

Filter = Buy OR Sell;

Short = ST AND L < S_Low;
Cover=Selltarget OR Sellsl;

//if(Buy=1)
//{
GfxTextOut("Buy@-- " + ( WriteVal(B_High) ), 43, 100 );
GfxTextOut("Target-- " + ( WriteVal(Buytarget) ), 40, 120 );
GfxTextOut("Sl--" + ( WriteVal(Buysl) ), 40, 140 );
//}
//if(Sell=1)
//{
GfxTextOut("Sell@-- " + ( WriteVal(S_Low ) ), 43, 180 );
GfxTextOut("Target-- " + ( WriteVal(Selltarget) ), 40, 200 );
GfxTextOut("Sl--" + ( WriteVal(Sellsl) ), 40, 220 );
//}

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

_N(Title = StrFormat("{{NAME}} ({{INTERVAL}}), {{DATE}} : {{OHLCX}}, Vol=%1.0f\n{{VALUES}}", V));
COL1=IIf(EMA(Close,5)>EMA(Close,34) AND Low > EMA(Close,34),colorBlue,IIf(EMA(Close,5)<EMA(Close ,34) AND High<EMA(Close,34),colorRed,colorBlack));
Plot( C, "Close", COL1, styleNoTitle | ParamStyle("Style") | styleCandle );

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeStar, shapeNone), colorRed, 0,High, Offset=30);
PlotShapes(IIf(Short==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
PlotShapes(IIf(Cover==1, shapeStar, shapeNone), colorGreen, 0,Low, Offset=-30);

Condition

1. when buy occurs, we need to see only buying price, tgt and sl.
2. when sell occurs, we need to see only selling price, tgt and sl.

3. when buy occurs and hits the tgt, we should cover OR when hits Sl, then also we sholud cover, then we will wait for the next signal
4. same for the sell.
5. Need to use in autotrade.
 

Similar threads