Join our facebook group for Amibroker afl code discussion https://www.facebook.com/groups/603980776889348

Auto Target Trading System


How to use Auto Target Trading System Amibroker afl?

Auto Target Trading System afl is one of the complete trading strategy. Auto Target Trading System identifies the trend and gives you three level target. Just follow the blue and red arrow to make your buy/sell decision. Auto Target Trading System can be used in any time frame. Use it with any lagging indicator like MACD, RSI or Stochastic to filter out false signals.

Auto Target Trading System
Auto Target Trading System


//www.aflcode.com
//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_BEGIN("Volume At Price");
PlotVAPOverlay(Param("Lines", 1000, 100, 1000, 10), Param("Width", 0, 0, 100, 1), ParamColor("Color", colorBlue));

_SECTION_END();
_SECTION_BEGIN("BACK COLR");
SetChartBkGradientFill( ParamColor("BgTop", colorPlum),

ParamColor("BgBottom", colorBlack),ParamColor("titleblock",colorPlum));

//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.","") ;



SetBarsRequired(600,0);
 
GraphXSpace = 20;
SetChartOptions( 0, chartShowArrows | chartShowDates );
 
 
//============== TITLE ==============

_SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True ); 
GfxSetBkMode( colorWhite );  
GfxSetTextColor( ParamColor("Color",colorGold) ); 
Hor=Param("Horizontal Position",970,1,1200,1);
Ver=Param("Vertical Position",50,1,830,1); 
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True ); 
GfxSetBkMode( colorWhite );  
GfxSetTextColor(ParamColor("Color",colorBlack) ); 
GfxTextOut(""+DD+"  ("+xx+"%)", Hor , Ver+45 );

_SECTION_END();


BuyPrice = Open;
SellPrice = Open;

Derived=WMA(WMA(WMA(((H+L)/2)+(O-C),92),1),1); 
i=WMA(Derived,3); 
Upper=Ref((Derived+StDev(Derived,7))+ATR(2)/0.8,0); 
Lower=Ref((Derived-StDev(Derived,7))-ATR(2)/1.5,0); 

color=IIf(BarsSince(Cross(Lower,C))> 
BarsSince(Cross(C,upper)), colorBrightGreen,colorRed); 
Plot(C,"",colorDefault,64); 
Plot(Upper,"upper band",colorRed); 
Plot(Lower,"lower band",colorLime);
//Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
//Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

/* Buy or Sell Condition */
Buy = Ref(Cross(C,Lower),0);
Sell = Cross(upper,C);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
//Cover=Buy;
//Short=Sell;

//Buy = Buy;
//Sell = Sell;
//Cover = Cross(C,UPPER);
//Short = Ref(Cross(LowER,C),0);
//Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
//Buy = ExRem(Buy,Sell);
//Sell = ExRem(Sell,Buy);
//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);
/*
*/
/*
dist = 0.8*ATR(10);
dist1 = 2*ATR(10);
for( i = 0; i < BarCount; i++ ) 
{ 
 if( Buy[i] ) 
 {
  PlotText( "\nHNI Buy 10 Lots @" + O[ i ] + "\nTGT=> " + (O[i]*1.0050) +"\nSL=> " + (O[i]*0.9975), i, L[ i ]-dist[i], colorGreen, colorBlack );
 }
 if( Sell[i] )
 {
  PlotText( "\nHNI Sell 10 Lots @" + O[ i ] + "\nTGT=> " + (O[i]*0.9950) + "\nSL=> " + (O[i]*1.0050), i, H[ i ]+dist1[i], colorRed, colorBlack ); 
 }
}
    */ 



for( i = 0; i < BarCount; i++ ){
if (Buy[i] == 1) {
entry = H[i];
sig = "BUY";
sl = (O[i]*0.9970); 
tar1 = entry + (entry * .0047);
tar2 = entry + (entry * .0090);
tar3 = entry + (entry * .0179);
bars = i;
}
if (Sell[i]) {
sig = "SELL";
entry = L[i];
sl = (O[i]*1.0055);

tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0100);
tar3 = entry - (entry * .0170);
bars = i;

}
}

Offset = 20;
Clr = IIf(sig == "BUY", colorDarkGreen, colorRed);
ssl = IIf(bars == BarCount-1, sl[BarCount-1],sl);
sl = ssl[BarCount-1];
Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset);

//PlotShapes(IIf(H>=tar1, shapeDigit1,shapeNone) ,colorOrange,0, H, Offset=-20) ;
Prd1=4;//Param("ATR Period 1-20",4,1,20,1);
Prd2=12;//Param("LookBack Period 1-20",11,1,20,1);
Green=HHV(LLV(L,Prd1)+ATR(Prd1),Prd2); 

//{Red} {Stop loss when Close<Red} 
//RED=LLV(HHV(H,Prd1)-ATR(Prd1),Prd2); 
RED = LLV(HHV(H,PRD2),PRD2);
Color=IIf(C>Green ,colorBrightGreen,IIf(C < RED,colorRed,colorBlue)); 


//Plot(Green,"Green",colorBrightGreen,styleLine); 

//Plot(RED,"Red",ParamColor("RED",colorGold),styleLine); 
//Plot(C,"",Color,64); 

///////////////////////////////////////////////////////////////////





{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorGold );

if (sig =="BUY"){
GfxSelectSolidBrush( colorDarkGreen ); // this is the box background color
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 420;


y = Status( "pxchartheight" );
y=200;

GfxSelectPen( colorGold, 2); 
GfxRoundRect( x, y - 130, x2, y+150 , 7, 7 ) ;
GfxTextOut("Avoid All Sell Confirmation Alert Now ",10,275);
GfxTextOut("Trade Only On Buy Confirmation Signals ",10,300);
GfxTextOut("TREND = BUY TREND ",10,250);
}
else
{
GfxSelectSolidBrush( colorDarkRed ); // this is the box background color
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 420;


y = Status( "pxchartheight" );
y=200;

GfxSelectPen( colorGold, 2); 
GfxRoundRect( x, y - 130, x2, y+150 , 7, 7 ) ;
GfxTextOut("Avoid All Buy Confirmation Alert Now ",10,275);
GfxTextOut("Trade Only On Sell Confirmation Signals ",10,300);
GfxTextOut("TREND = SELL TREND ",10,250);}
//GfxSelectSolidBrush( colorDarkRed ); 
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 420;


y = Status( "pxchartheight" );
y=200;

GfxSelectPen( colorGold, 2); 
GfxRoundRect( x, y - 130, x2, y+25 , 7, 7 ) ;
GfxTextOut( Name(),13,y-120);
GfxTextOut( ("Exit From Trade If "+Interval()/60+ " Min Candle Close SL => " + sl + " "), 13, y-40);


//GfxTextOut( ("" + WriteIf(sig =="Buy",sig + " Only if "+Interval()/60+" Minutes Candle Close Above",sig + " Only if "+Interval()/60+" Minutes Candle Close ") + " => " + entry), 13, y-100);

//GfxTextOut( ("Trailing SL : " + sl + " "), 13, y-80);
GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
//GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-25);;
GfxTextOut( ("Last "+Interval()/60+" Minutes Candle Close Was =>"+Ref(Close,-1)),13,y-20);

/*{if (sig =="BUY");
GfxTextOut( ("NOTE : "),13,y+3 );
GfxTextOut( ("Buy Only If  "+Interval()/60+" Minute Candle Close Above =>" + entry),13,y +150);
if (sig =="SELL");
GfxTextOut( ("Sell Only If "+Interval()/60+" Minute Candle Close Below => "+ entry),13,y +50);}*/
}
_SECTION_BEGIN("KBL Arrow Detection");
 
Buy=Buy; 
Sell=Sell;

PlotShapes(IIf(Buy, shapeSquare,shapeNone) ,colorBlue,0, Low, Offset=-20) ; 
PlotShapes(IIf(Buy, shapeSmallUpTriangle,shapeNone) ,colorLime,0, Low, Offset=-22) ;
PlotShapes(IIf(Sell, shapeSquare,shapeNone),colorRed,0, High, Offset=10) ;
PlotShapes(IIf(Sell, shapeSmallDownTriangle,shapeNone),colorLime,0, High, Offset=-12) ;
/*
PlotShapes(IIf(Cover, shapeSquare,shapeNone) ,colorBlue,0, Low, Offset=-10) ; 
PlotShapes(IIf(Cover, shapeStar,shapeNone) ,colorLime,0, Low, Offset=-10) ;
PlotShapes(IIf(Short, shapeSquare,shapeNone),colorRed,0, High, Offset=-1) ;
PlotShapes(IIf(Short, shapeStar,shapeNone),colorRed,0, High, Offset=-1) ;
*/
_SECTION_END();





_SECTION_BEGIN("Price Line");
dp= Param("dps",3,0,1000,1);
PriceLineColor=ParamColor("PriceLineColor",colorOrange);
PriceLevel = ParamField("PriceField", field = 3 ); 
PriceLeve2 = ParamField("PriceField", field = dp );
Daysback    = Param("Bars Back",1,10,5000,1); 
FirstBar    = BarCount - DaysBack; 
 YY        = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null); 

Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll)); 

side = Param("side",1,0,1000,1);

dist = 0; 

for( i = 0; i < BarCount; i++ ) 
{ 
 if(i+side== BarCount) PlotText( "\n    " + PriceLevel[ i ], i, YY[ i ]-dist[i], colorGold );
 
} 

_SECTION_END();



       /****************/
  /*              */
  /* ALERT OUTPUT */
  /*              */
  /****************/

  TxtX = Param("Text Left1", 430, 0, 1000, 10);
  TxtY = Param("Text Top1", 61, 1, 650, 10);
 
  GfxSelectFont("Tahoma", 14, 700 ); 
  GfxSetBkMode(1); 

  if(LastValue(Buy) OR SelectedValue(Buy))
   {
    GfxSetTextColor(colorBrightGreen); 
    GfxTextOut("BUY Signal Captured :: Waiting For Confirmation", TxtX, TxtY);
    Say(""); 


   }

  else if(LastValue(Sell) OR SelectedValue(Sell))
   {
    GfxSetTextColor(colorRed); 
    GfxTextOut("SELL Signal Captured :: Waiting For Confirmation ", TxtX, TxtY); 
    Say("");
   }

  else
   {
    GfxSetTextColor(colorGold);
              GfxTextOut(" ", TxtX, TxtY); 
    GfxTextOut("", TxtX, TxtY); 
   }
 
_SECTION_BEGIN("sys");

x=Param("xposn",315,0,1000,1);
y=Param("yposn",576,0,1000,1);


GfxSetTextColor(colorGold);
GfxTextOut( ( ""),60,y-110);
GfxSetTextColor(colorGold);
GfxTextOut( ( ""),10,y-90);
GfxSetTextColor(colorGold);
GfxTextOut( ( ""),30,y-70);
/*
GfxSetTextColor(colorBrightGreen);
GfxTextOut( ( "Recieving Channel : Funds Server "),300,y-110);*/
GfxSetTextColor(colorBrightGreen);
GfxTextOut( ( ""),300,y-90);
/*GfxSetTextColor(colorBrightGreen);
GfxTextOut( ( "Data Status : Recieving "),300,y-70);*/
_SECTION_END();
_SECTION_BEGIN("Background text");
C11=ParamColor("up panel",colorBlack );
C12=ParamColor("dn panel",colorBlack );
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",8,1,30,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode( 0 ); 
GfxSelectFont("Tahoma", 12, 500, False, False, 0);
GfxSetTextColor(colorCustom12); 
GfxSetTextAlign( 6 );
GfxSelectFont("Tahoma", 15, 600, False, False, 0);
GfxSetTextColor(colorWhite); 
GfxSetTextAlign( 6 );
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorBrightGreen);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorRed);
pricechange=(C-Ref(C,-1))*100/Ref(C,-1);
changeponit=C-Ref(C,-1);
Vlp=Param("Volume lookback period",15,10,300,10);
Vrg=MA(V,Vlp);
St = StDev(Vrg,Vlp); 
Vp3 = Vrg + 3*st; 
Vp2 = Vrg + 2*st;;
Vp1 = Vrg + 1*st;;
Vn1 = Vrg -1*st; 
Vn2 = Vrg -2*st; 

x=Param("xposn",1,0,1000,1);
y=Param("yposn",1,0,1000,1);

GfxGradientRect( 1, 1, 1400, 40, colorViolet, colorBlack);
GfxSetBkMode(0);
GfxSelectFont( "Georgia", 18, 800, False );
GfxSetTextColor( colorGold );
GfxTextOut( "", x+600, y+10 );
GfxSelectFont( "Tahoma", 16, 800, False );
GfxSetTextColor( colorGold );
GfxTextOut( Name(), x+120, y+10 );
GfxSelectFont( "Century Gothic", 15, 100, False );
GfxSetTextColor( colorGold );
GfxTextOut( Date(), x+1000, y+10 );
GfxSelectFont( "Comic Sans MS", 15, 500, False );
GfxSetTextColor( colorGold );
//GfxTextOut( Interval(2), x+275, y+10 );
//------------------------------------------------------------ H, L, O, C----------------------
GfxGradientRect( 1, 40, 1400, 55, colorViolet, colorBlack );
GfxSetBkMode(0);
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "High:"+WriteVal(H,1.2), x+100, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Low:"+WriteVal(L,1.2), x+200, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Open:"+WriteVal(O,1.2), x+300, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Close:"+WriteVal(C,1.2), x+400, y+40 );
GfxSelectFont( "COMIC SANS MS", 12, 100, False );
GfxSetTextColor( colorGold );
GfxTextOut( "", x+1000, y+35 );
/*
n=130;
per =11.5;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa (C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
//Plot(ValueWhen( (S1==trendlineS ), L),"", colorGreen, styleDashed|styleNoRescale|styleThick);
//Plot(ValueWhen((S11==trendlineR ), H),"", colorRed, styleDashed|styleNoRescale|styleThick);
Buy = Ref(S1==trendlineS ,-5);
Sell = Ref(S11==trendlineR ,-11);
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
//PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorBlue, colorPink),High,Low );
PlotShapes(IIf(Buy, shapeUpTriangle,shapeNone) ,colorGold,0, Low, Offset=-10) ; 
PlotShapes(IIf(Buy, shapeSmallCircle,shapeNone) ,colorBlue,0, Low, Offset=-12) ;
PlotShapes(IIf(Sell, shapeDownTriangle,shapeNone),colorGold,0, High, Offset=-1) ;
PlotShapes(IIf(Sell, shapeSmallCircle,shapeNone),colorRed,0, High, Offset=3) ;
dist = 0.8*ATR(10);
dist1 = 2*ATR(10);
for( i = 0; i < BarCount; i++ ) 
{ 
 if( Buy[i] ) 
 {
  PlotText( "\n     Heavy Fire Up Ahead     " , i, L[ i ]-dist[i], colorBlack, colorGreen );
 }
 if( Sell[i] )
 {
  PlotText( "     Heavy Down Fall Ahead    " , i, H[ i ]+dist1[i], colorBlack, colorRed ); 
 }
}*//*
function GetSecondNum()
{
    Time = Now( 4 );
    Seconds = int( Time % 100 );
    Minutes = int( Time / 100 % 100 );
    Hours = int( Time / 10000 % 100 );
    SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
    return SecondNum;
}

function secleft()
{
 currtime = Now ( 4 );
 hr = int ( currtime / 10000 );
 mnt = int ( ( currtime - hr * 10000 ) / 100 );
 sec = currtime - hr * 10000 - mnt * 100;
 totalsec = hr * 60 ^ 2 + mnt * 60 + sec; 
 left =  Interval() - totalsec % Interval();
 return left;
}
 
function PopupWindowEx( popupID, bodytext, captiontext, timeout, left, top )
{
    displayText = bodytext + "_" + captiontext;
    if ( ( StaticVarGetText( "prevPopup:" + popupID ) != displayText) OR 
   ( StaticVarGet( "prevPopupTime" + popupID ) < GetSecondNum() ) )
    {
        StaticVarSetText( "prevPopup:" + popupID, displayText);
        StaticVarSet( "prevPopupTime" + popupID, GetSecondNum() + timeout );
        PopupWindow( bodytext, Captiontext + popupID, timeout, Left, top );
    }
}

/////////////////////////////////////////////////////////////////////////
// one time popup example by trash ....
// http://www.traderji.com/newreply.php?do=postreply&t=78419
/////////////////////////////////////////////////////////////////////////
/*
period = 5; // number of averaging periods 
m = MA( Close, period ); 
Buy = Cross( Close, m );
Sell = Cross( m, Close );*//*

if( Status( "action" ) == actionIndicator )
{
 Buy = ExRem( Buy, Sell );
 Sell = ExRem( Sell, Buy );

 alertstr1 = Name() + /*"_Last Bartime:"  DateTimeToStr( LastValue( DateTime() )*/"                                                        IF  "+Interval()/60+" MINUTES CANDLE CLOSE ABOVE => " + Ref(H,1)+"                                                                                                                                                                                                                                                                                                                                                                                       MaxWealth Consulting"  ;
  // alertstr2 = Name() + /*"_Last Bartime:"  DateTimeToStr( LastValue( DateTime() )*/"                                                      IF  "+Interval()/60+" MINUTES CANDLE CLOSE BELOW => " + Ref(L,1)+"                                                                                                                                                                                                                                                                                                                                                                                     MaxWealth Consulting" ;                                            
 //buyid = "";
 //sellid = "";  
 
 //duration = secleft();  // one popup ocurrence AFTER confirmed signal
/*
 if ( LastValue( Ref( Buy, -1 ) ) )
  PopupWindowEx( buyid, "BUY   " + alertstr1, "Buy Alert", duration, -1, -1 );
 if ( LastValue( Ref( Sell, -1 ) ) )
  PopupWindowEx( sellid, "SELL   " + alertstr2, "Sell Alert", duration, 0, 0 );
  
 Title = "Intrabar " + StaticVarGetText( "prevPopup:" + buyid ) + 
   "\nIntrabar " + StaticVarGetText( "prevPopup:" + sellid ) +
   "\nBartime left: "+ duration;
 
 //Plot( Buy, "True Buy Sig", colorGreen, styleLine, 0, 1, 0, 0, width = -80 );
 //Plot( Sell, "True Sell Sig", colorRed, styleLine, 0, 1, 0, 0, width ); 
}
*/

/*
n=130;
per =11.5;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa (C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
//Plot(ValueWhen( (S1==trendlineS ), L),"", colorGreen, styleDashed|styleNoRescale|styleThick);
//Plot(ValueWhen((S11==trendlineR ), H),"", colorRed, styleDashed|styleNoRescale|styleThick);
Buy = Ref(S1==trendlineS ,-5);
Sell = Ref(S11==trendlineR ,-7);
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
//PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorBlue, colorPink),High,Low );
PlotShapes(IIf(Buy, shapeUpTriangle,shapeNone) ,colorGold,0, Low, Offset=-10) ; 
PlotShapes(IIf(Buy, shapeSmallCircle,shapeNone) ,colorBlue,0, Low, Offset=-12) ;
PlotShapes(IIf(Sell, shapeDownTriangle,shapeNone),colorGold,0, High, Offset=-1) ;
PlotShapes(IIf(Sell, shapeSmallCircle,shapeNone),colorRed,0, High, Offset=3) ;
dist = 0.8*ATR(10);
dist1 = 2*ATR(10);
for( i = 0; i < BarCount; i++ ) 
{ 
 if( Buy[i] ) 
 {
  PlotText( "\n     Heavy Fire Up Ahead     " , i, L[ i ]-dist[i], colorBlack, colorGreen );
 }
 if( Sell[i] )
 {
  PlotText( "     Heavy Down Fall Ahead    " , i, H[ i ]+dist1[i], colorBlack, colorRed ); 
 }
}
*/
_SECTION_BEGIN("Wilders");
P = ParamField("Price field",-1);
Periods = 15;//Param("Periods", 15, 2, 300, 1, 10 );
Plot(W= Wilders( P, Periods ), _DEFAULT_NAME(), colorDefault, styleNoDraw ); 
_SECTION_END();

_SECTION_BEGIN("Time Left");
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;

x=Param("xposn",50,0,1000,1);
y=Param("yposn",380,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
if ( NewPeriod )
{
GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
Say( "New period" );
}
//GfxRoundRect( x+45, y+40, x-3, y-2, 0, 0 );
//GfxSetBkMode(1);
GfxSelectFont( "Arial", 12, 550, False );
GfxSetTextColor( colorGold );
GfxTextOut( "Time Left For "+Interval()/60+" Minutes Candle Close => "+SecsToGo+" Seconds", x+155, y-179 );
_SECTION_END(); 

B1 = C>RED OR C>W;
B2 = C>RED AND C>W;
B3 = B1 AND B2;

S1 = C<RED OR C<W;
S2 = C<RED AND C<W;
S3 = S1 AND S2;
S4 = H>=W AND C<=W;
S5 = H>=RED;
S6 = S4 OR S5;
S7 = S3 AND S6;
S8 = S4 AND S7;
B3 = ExRem(B3,s8);
S8 = ExRem(S8,b3);
//ex = BarsSince(Sell);
//GfxTextOut("bars =  "+ex,50,100);
s8 = ExRemSpan(s8,10);
b3 = ExRemSpan(b3,10);

PlotShapes(IIf(s8, shapeSmallDownTriangle,shapeNone) ,colorRed,0, H, Offset=-30) ;
PlotShapes(IIf(b3, shapeSmallUpTriangle,shapeNone) ,colorBlue,0, Low, Offset=-30) ; 

      /****************/
  /*              */
  /* ALERT OUTPUT */
  /*              */
  /****************/

  TxtX1 = Param("Text Left", 600, 0, 1000, 10);
  TxtY1 = Param("Text Top", 61, 1, 650, 10);
 
  GfxSelectFont("Tahoma", 14, 700 ); 
  GfxSetBkMode(1); 

  if(LastValue(B3) OR SelectedValue(B3))
   {
    GfxSetTextColor(colorBrightGreen); 
    GfxTextOut("BUY Signal Confirmed  ", TxtX1, TxtY1);
    GfxTextOut("BUY Now Between   "+H+" - "+L, TxtX1, TxtY1+20);
              GfxTextOut("Buy Confirmed @ "+(O+H+L+C)/4,TxtX1-475,TxtY1+37);
              Say(""); 


   }

  else if(LastValue(S8) OR SelectedValue(S8))
   {
    GfxSetTextColor(colorRed);
    GfxTextOut("SELL Signal Confirmed  ", TxtX1, TxtY1); 
              GfxTextOut("SELL Now Between  "+L+" - "+H, TxtX1, TxtY1+20); 
              GfxTextOut("Sell Confirmed @ "+(O+H+L+C)/4,TxtX1-475,TxtY1+37);
    Say("");
   }

  else
   {
    GfxSetTextColor(colorGold);
              GfxTextOut(" ", TxtX1, TxtY1); 
    GfxTextOut("", TxtX1, TxtY1); 
   }

Previous
Next Post »