Auto Buy Target Stoploss



 Auto Buy Target Stoploss
 Auto Buy Target Stoploss


//www.aflcode.com
_SECTION_BEGIN("BEGIN"); 
Col = IIf(C > O,colorBrightGreen,colorRed); 
Plot(C,"",col,styleBar+styleThick);

_SECTION_BEGIN(" EMA's");
EMA1 = EMA(H,34);
EMA2 = EMA(L,34);
EMA3 = EMA(C,34);

Plot( EMA1, "EMA1" ,ParamColor( "Color1", colorRed ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
Plot( EMA2, "EMA2" ,ParamColor( "Color2", colorGreen ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
Plot( EMA3, "EMA3" ,ParamColor( "Color3", colorBlue ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
_SECTION_END();
TimeFrameSet(inDaily);
DayHigh = LastValue(H);
DayLow = LastValue(L);
TimeFrameRestore();

Title = Date() + ", Op=" + Open + ", Hi=" + High + ", Lo=" + Low + ", LTP=" + Close + ", Change= " + SelectedValue( ROC( C, 1 ) ) + "%" + "\n Today`s High=" + DayHigh + ", Today`s Low=" + DayLow + " © " ;

 


Prev=AMA2(C,1,0);
d=IIf(C>Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),
IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));
a=Cross(Close,d);
b=Cross(d,Close);
state=IIf(BarsSince(a)<BarsSince(b),1,0);
s=state>Ref(state,-1);
ss=state<Ref(state,-1);
sss=state==Ref(state,-1);
col=IIf(state == 1 ,51,IIf(state ==0,4,1));
//Plot(C,"",Col,64);
Buy = s;
Sell = ss;
///shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
///PlotShapes(shape, IIf(Buy,colorGreen,colorRed), 0, IIf(Buy,Low,High));
///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-5);
///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-10);
///PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-7.5);
///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=10);
///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=15);
//PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-12.5);
///WriteIf(s,"EXIT all Short positions\nif trading long positions, enter long Now-\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(L+.75*ATR(5),1.4)+" ,","");
////WriteIf(ss,"exit all long positions today with a Market On Close (MOC) order\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(Ref(H+.75*ATR(5), -1),1.4)+",","");
///WriteIf( sss ,"No trading signals today.","") ;

dist = 2*ATR(20);
dist1 = 5*ATR(20);
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] )
{
PlotText( "\nBuy:" + L[ i ] + "\nT= " + (L[i]*1.005) + "\nSL= " + (L[i]*0.9975), i, L[ i ]-dist[i], colorGreen, colorWhite );
}
if( Sell[i] )
{
PlotText( "Sell:" + H[ i ] + "\nT= " + (H[i]*0.995) + "\nSL= " + (H[i]*1.0025), i, H[ i ]+dist1[i], colorRed, colorWhite );
}
}


Filter = s OR sss OR sss ;
AddColumn(C,"close",1.2);
AddColumn( IIf( s, 66,1 ), "buy", formatChar, 1, bkcolor =IIf (s,colorYellow, colorPink ));
AddColumn( IIf( Ss, 83,1 ), "sell", formatChar, 1, bkcolor =IIf (Ss,colorPink, colorWhite ));
AddColumn( IIf( sss, 87,1 ), "wait", formatChar, 1, bkcolor =IIf (sss,colorYellow, colorRed ));


// Plot the Buy and Sell arrows.
//shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
//PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);
///PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15);
///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);
///PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);

Previous
Next Post »