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

Thunderbird Original Paid AFL

Thunderbird is one of the most popular and highly demanded afl for bumper profit. This afl is based on major support and resistance so the accuracy of this afl is very high. Entry can be made on Red or Green arrow and book the profit as per your need. The high or Low of entry candle could be your stoploss. Dont wait for opposite color arrow to be formed. Just book the profit. This afl can be used for intraday as well swing trading in any time frame.
Thunderbird Original Paid AFL
Thunderbird Original Paid AFL

//www.aflcode.com
_SECTION_BEGIN("TBTS");
SetChartBkColor(ParamColor("Outer panel color ",colorLightYellow));
SetChartBkColor(ParamColor("BackGround Color", colorDarkGrey));


SetChartOptions(0,chartShowArrows|chartShowDates);
Title = EncodeColor(colorYellow)+ Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorSkyblue) +
" - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"O= "+O+", H= "+H+", L= "+L+", C= "+C+", V= "+ WriteVal(V);


NNN =ParamStr("### Paint Trend Bar Direction ###", "-- Color: Bull, Bear & No Trend --");
cBull = ParamColor("Bull Trend", ColorRGB(0,191,255));
cBear = ParamColor("Bear Trend", colorRed);
cNT = ParamColor("No Trend", colorLightGrey);

MMM =ParamStr("### TSL Setup ###", "-- Show, Style, Color, Period --");
Show_TSL =ParamToggle("Show TSL Line","No|Yes",1);
TSL_Mode = ParamToggle("TSL Mode","Normal|Stop n Reverse",1);

TSL_Style = ParamStyle("TSL Style", styleStaircase|styleDashed, maskAll);
TSL_ColorBull = ParamColor("TSL Color Bull", colorGreen);
TSL_ColorBear = ParamColor("TSL Color Bear", colorRed);
TSL_Len = Optimize("TSL_Len",Param("Optimize 1: TSL Period",10, 1, 50 ,1),1, 50 ,1);

CTFx1 = Optimize("CTFx1",Param("Optimize 2: Cur_TF X =>",5, 1, 55 ,1),1, 50 ,1);
CTFx2 = Optimize("CTFx2",Param("Optimize 3: Cur_TF X =>",22, 1, 55 ,1),1, 50 ,1);

Mode_Agressive =ParamToggle("Mode","Normal|Agressive",1);


Show_Ribbon =ParamToggle("Show Ribbon","No|Yes");

CloseTradeAtEOD = ParamToggle("Close Positions at EOD", "No|Yes");
MktCloseTime=Param("Market Close Time",152500,000000,235959,1 );

no=Param("NO OF BARS",10,0,100,1);

Plot( C, "Price", colorWhite, styleCandle | styleThick );

function TBR(no)
{
dres=HHV(H,no);
dsup=LLV(L,no);
davd=IIf(H>Ref(dres,-1),1,IIf(L<Ref(dsup,-1),-1,0));
davn=ValueWhen(davd!=0,davd,1);
dtsl=IIf(davn==1,dsup,dres);
return dtsl;
}
dtsl=TBR(no);
dB=H>dtsl;
dS=L<dtsl;

TF = CTFx1*Interval();
TimeFrameSet(TF);
wtsl=TBR(no);
WB=H>WTSL;
WS=L<WTSL;
TimeFrameRestore();

mode = IIf(Mode_Agressive, expandFirst, expandLast);

wtsl=TimeFrameExpand(wtsl,TF,mode);
wb=TimeFrameExpand(WB,TF,mode);
ws=TimeFrameExpand(WS,TF,mode);

TF = CTFx2*Interval();
TimeFrameSet(TF);
mtsl=TBR(no);
MB=H>MTSL;//Cross(H,mtsl);
MS=L<MTSL;//Cross(mtsl,L);
TimeFrameRestore();
mtsl=TimeFrameExpand(mtsl,TF,mode);
mb=TimeFrameExpand(MB,TF,mode);
ms=TimeFrameExpand(MS,TF,mode); 

Buy = IIf((Low > WTSL AND Low > MTSL), DB, ((WB AND Low > DTSL AND Low > MTSL) OR (MB AND Low > DTSL AND Low > WTSL)));
Sell=IIf(NOT CloseTradeAtEOD, (DS OR (DS AND WS) AND (Low > MTSL)), (DS OR (DS AND WS) AND (Low > MTSL)) OR TimeNum() > MktCloseTime);
Short = IIf((High < WTSL AND High < MTSL), DS, (WS AND High < DTSL AND High < MTSL) OR (MS AND High < DTSL AND High < WTSL));
Cover=IIf(NOT CloseTradeAtEOD, (DB OR (DB AND WB) AND (High < MTSL)), (DB OR (DB AND WB) AND (High < MTSL)) OR TimeNum() > MktCloseTime);

//else
{
dtsl=TBR(no);

dB=C>dtsl;
dS=C<dtsl;
Buy = Cover = DB;
Sell = Short = DS;
}

if (Show_Ribbon)
{
state=IIf(BarsSince(DB)<BarsSince(DS),1,0);
col=IIf(state == 1 ,51,IIf(state ==0,3,1));
Plot(2,"",COL,styleArea|styleOwnScale|styleNoLabel ,0,100);
}


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

BarsSincebuy = BarsSince( Buy );
BarsSinceshort = BarsSince( Short );
LastSignal = IIf( BarsSincebuy < BarsSinceshort, 1, -1 );
SellPrice=ValueWhen(Short,C);
BuyPrice=ValueWhen(Buy,C);

entry = IIf( LastSignal == 1, BuyPrice, ShortPrice );

Long=Flip(Buy,Sell);
Shrt=Flip(Short,Cover);

Relax = NOT Long AND NOT Buy AND NOT shrt AND NOT Sell AND NOT Sell AND NOT Cover;
SellSL=ValueWhen(Short,DTSL);
BuySL=ValueWhen(Buy,DTSL);
BuyDifference= BuyPrice - BuySL;
SellDifference = SellSL - SellPrice;

tar1 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + BuyDifference), (SellPrice - SellDifference));
tar2 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (2*BuyDifference)), (SellPrice - (2*SellDifference)));
tar3 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (4*BuyDifference)), (SellPrice - (4*SellDifference)));

buyach1 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar1, 0);
buyach2 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar2, 0);
buyach3 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar3, 0);

sellach1 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar1, 0);
sellach2 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar2, 0);
sellach3 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar3, 0);

if (Show_TSL)
{
tsl = IIf(Buy OR Long OR Short OR Shrt AND NOT Relax, dtsl,Null);
tslcolor = IIf(Buy OR Long AND NOT Relax, TSL_ColorBull, TSL_ColorBear); 

Plot(tsl, "",tslcolor, TSL_Style, Null, Null, 0, 1);
}


_SECTION_END();


_SECTION_BEGIN("Alert Output");
VoiceAlert = ParamToggle("Voice Alert", "No|Yes");
EmailAlert = ParamToggle("E-mail Alert", "No|Yes");
AlertOutput = ParamToggle("Alert Output", "No|Yes");


if (VoiceAlert)
{
str = " in "+Name()+" at current market price ";

if (SelectedValue(Buy)==1) Say("Go Long"+str+C);
if (SelectedValue(Short)==1) Say("Go Short"+str+C);
if (TSL_Mode==0)
{
if (SelectedValue(Sell AND NOT Short)==1) Say("Exit long"+str+C);
if (SelectedValue(Cover AND NOT Buy)==1) Say("Exit short"+str+C);

}
}


if (EmailAlert)
{
str = " signal generated on "+FullName();

AlertIf( Buy, "EMAIL", "Long"+ str, 1 );
if (TSL_Mode==0)
AlertIf( Sell AND NOT Short, "EMAIL", "Exit Long"+str, 1 );

AlertIf( Short, "EMAIL", "Short"+str, 1 );
if (Mode_TSL==0)
AlertIf( Cover AND NOT Buy, "EMAIL", "Exit Short"+str, 1 );
}


if (AlertOutput) 
{
str = " signal generated on "+Name();

AlertIf( Buy, "", "Long"+str, 4 );
AlertIf( Sell AND NOT Short, "", "Exit Long"+str, 4 );
AlertIf( Short, "", "Short"+str, 4 );
AlertIf( Cover AND NOT Buy, "", "Exit Short"+str, 4 );
}

_SECTION_END();




_SECTION_BEGIN("TrendLines");

Show_TrendLine = ParamToggle("Show", "No|Yes");

if (Show_TrendLine)
{
/*+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++
THIS SECTION DRAWS TD TREND LINES */

percent = 0.01 * 1; /* Adjust this percent as necessary, */

firstpoint = 2;

L1 = Ref(L, -1);
y0=LastValue(Trough(L,percent,firstpoint)); 
y1=LastValue(Trough(L1,percent,1));

for( i = 1; i < BarCount AND y0 >= y1; i++ )
{
firstpoint++; 
y0=LastValue(Trough(L,percent,firstpoint)); 
}

x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpoint)); 
x1=BarCount - 1 - LastValue(TroughBars(L1,percent)); 

TLine=LineArray( x0, y0, x1, y1,True); 
Plot( TLine, "Support Trend line", colorGreen, styleThick|styleDots ); 

firstpoint = 2;
H1 = Ref(H, -1);
y0=LastValue(Peak(H,percent,firstpoint)); 
y1=LastValue(Peak(H1,percent,1));

for(i = 1; i < BarCount AND y0 <= y1; i++ )
{
firstpoint++; 
y0=LastValue(Peak(H,percent,firstpoint)); 
}
x0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpoint)); 
x1=BarCount - 1 - LastValue(PeakBars(H1,percent)); 
TLine = LineArray( x0, y0, x1, y1,True ); 

Plot( TLine, "Resistance Trend line", colorRed, styleThick|styleDots ); 

/*+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++*/
}
_SECTION_END();



_SECTION_BEGIN("Bands");
Show_Bands = ParamToggle("Show", "No|Yes");
Periods = Param("Standard Error", 80, 3, 200, 1);
Smooth = Param("Smooth",14,2,100,1);


//NOTE1 = ParamStr("*** Standard Deviation 1 ***", "");
MB_Color=ParamColor("MidBand Color",colorLime);
MB_Style= ParamStyle("MidBand Style", styleDashed);

OB_Color=ParamColor("OuterBand Color",colorGreen);
OB_Style= ParamStyle("OuterBand Style");





if(Show_Bands)
{
Plot( MALRCurve , "MidBand", MB_Color, MB_Style); 
Plot( UpperBand , "UpperBand", OB_Color, OB_Style); 
Plot( LowerBand , "LowerBand", OB_Color, OB_Style); 
}

_SECTION_END();


// Linear Regression Line with 2 Standard Deviation Channels Plotted Above and Below
_SECTION_BEGIN("Linear Regression Channel");
Show_LRC = ParamToggle("Show", "No|Yes");
P = ParamField("Price Field",-1);
Daysback = Param("LRC Period",21,1,240,1);
shift = Param("LookBack Period",0,0,240,1);

//NOTE1 = ParamStr("*** Standard Deviation 1 ***", "");
SDP = Param("### Standard Deviation 1 ###", 1.5, 0, 6, 0.1);
SDColor = ParamColor("SD1_Color", colorCycle );
SDStyle = ParamStyle("SD1_Style");

//NOTE2 = ParamStr("*** Standard Deviation 2 ***", "");
SDP2 = Param("### Standard Deviation 2 ###", 2.0, 0, 6, 0.1);
SDColor2 = ParamColor("SD2_Color", colorCycle );
SDStyle2 = ParamStyle("SD2_Style");




x = Cum(1);
lastx = LastValue( x ) - shift;
aa = LastValue( Ref(LinRegIntercept( p, Daysback), -shift) );
bb = LastValue( Ref(LinRegSlope( p, Daysback ), -shift) );
y = Aa + bb * ( x - (Lastx - DaysBack +1 ) );

if (Show_LRC) 
{
// ==================Plot the Linear Regression Line ================================================== ========
LRColor = ParamColor("LR Color", colorCycle );
LRStyle = ParamStyle("LR Style");
LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );
Plot( LRLine , "LinReg", LRCOLOR, LRSTYLE ); // styleDots );

// ========================== Plot 1st SD Channel ================================================== =============
SD = SDP/2;

width = LastValue( Ref(SD*StDev(p, Daysback),-shift) ); // THIS IS WHERE THE WIDTH OF THE CHANELS IS SET
SDU = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width , Null ) ;
SDL = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width , Null ) ;

Plot( SDU , "Upper Lin Reg", SDColor,SDStyle );
Plot( SDL , "Lower Lin Reg", SDColor,SDStyle );

// ========================== Plot 2d SD Channel ================================================== =============
SD2 = SDP2/2;

width2 = LastValue( Ref(SD2*StDev(p, Daysback),-shift) ); // THIS IS WHERE THE WIDTH OF THE CHANELS IS SET
SDU2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width2 , Null ) ;
SDL2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width2 , Null ) ;

Plot( SDU2 , "Upper Lin Reg", SDColor2,SDStyle2 );
Plot( SDL2 , "Lower Lin Reg", SDColor2,SDStyle2 );
}

_SECTION_END();



_SECTION_BEGIN("Support & Resistance");

Show_SnR=ParamToggle("Show","No|Yes");

ResPrd=Param("Res.Period",10,0,200,1);
ResColor = ParamColor("Res.Color", colorRed);

Res1Style=ParamStyle("Res1.Style",styleNoTitle|styleThick|styleDots,maskAll);
Res2Style=ParamStyle("Res2.Style",styleNoTitle,maskAll);
Res3Style=ParamStyle("Res3.Style",styleNoTitle,maskAll);

SupPrd=Param("Sup.Period",10,0,200,1);
SupColor = ParamColor("Sup.Color", colorGreen);

Sup1Style=ParamStyle("Sup1.Style",styleNoTitle|styleThick|styleDots,maskAll);
Sup2Style=ParamStyle("Sup2.Style",styleLine|styleNoTitle,maskAll);
Sup3Style=ParamStyle("Sup3.Style",styleLine|styleNoTitle,maskAll);

if(Show_SnR)
{
HaClose = EMA(TBR(no),3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );

test = TEMA ( High , ResPrd ) ;

PK = test > Ref(test,-1) AND Ref(test,1) < High;//Peak
PKV0 = ValueWhen(PK,haHigh,0);//PeakValue0
PKV1 = ValueWhen(PK,haHigh,1);//PeakValue1
PKV2 = ValueWhen(PK,haHigh,2);//PeakValue2

MPK = PKV2 < PKV1 AND PKV1 > PKV0 ;//MajorPeak

MPKV = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,1); //MajorPeakValue
MPKD = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),1); //MajorPeakDate
SD = IIf(DateNum() < LastValue(MPKD), Null, LastValue(MPKV));//SelectedDate

Plot(SD, "Res1", ResColor,Res1Style);

MPKV2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,2); //MajorPeakValue
MPKD2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),2); //MajorPeakDate
SD2 = IIf(DateNum() < LastValue(MPKD2), Null, LastValue(MPKV2));//SelectedDate
Plot(SD2, "Res2", ResColor,Res2Style);


MPKV3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,3); //MajorPeakValue
MPKD3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),3); //MajorPeakDate
SD3 = IIf(DateNum() < LastValue(MPKD3), Null, LastValue(MPKV3));//SelectedDate
Plot(SD3, "Res3", ResColor,Res3Style);


test = TEMA ( Low , SupPrd ) ;

SP = Ref(test,1) > Low AND test < Ref(test,-1);
SPV0 = ValueWhen(SP,haLow,0);//PeakValue0
SPV1 = ValueWhen(SP,haLow,1);//PeakValue1
SPV2 = ValueWhen(SP,haLow,2);//PeakValue2


MSP = SPV2 > SPV1 AND SPV1 < SPV0 ;//MajorPeak

MSPV = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,1);
MSPD = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),1);
SD = IIf(DateNum() < LastValue(MSPD), Null, LastValue(MSPV));
Plot(SD,"Sup1", SupColor,Sup1Style);

MSPV2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,2);
MSPD2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),2);
SD2 = IIf(DateNum() < LastValue(MSPD2), Null, LastValue(MSPV2));
Plot(SD2,"Sup2", SupColor,Sup2Style);

MSPV3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,3);
MSPD3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),3);
SD3 = IIf(DateNum() < LastValue(MSPD3), Null, LastValue(MSPV3));
Plot(SD3,"Sup3", SupColor,Sup3Style);
}

_SECTION_END();


_SECTION_BEGIN("Fibonacci");

Show_Fib = ParamToggle("Show Fibonacci Lines","No|Yes");
Show_FibLabel = ParamToggle("Show Text","No|Yes");

pctH = 0.325; HiLB = 1;
pctL = 0.325; LoLB = 1;
Back = 1;
Fwd = 0;
hts = -33.5;
style =styleLine;

x = BarIndex();

pRp = PeakBars( H, pctH)==0;
yRp0 = SelectedValue(ValueWhen( pRp, H, HiLB));
xRp0 = SelectedValue(ValueWhen( pRp, x, HiLB));

pSp = TroughBars( L, pctL)==0;
ySp0 = SelectedValue(ValueWhen( pSp, L, LoLB));
xSp0 = SelectedValue(ValueWhen( pSp, x, LoLB));
Delta = yRp0 - ySp0;

function fib(val)
{
dist = (Delta * Val);
return
IIf(Val < 1.0 AND xSp0 < xRp0, yRp0 - dist, 
IIf(Val < 1.0 AND xSp0 > xRp0, ySp0 + dist,
IIf(Val > 1.0 AND xSp0 < xRp0, yRp0 - dist, 
IIf(Val > 1.0 AND xSp0 > xRp0, ySp0 + dist, Null)))); 
}

x0 = Min(xSp0,xRp0)-Back;
x1 = (BarCount -1);

//////////////////////////////////////////////////////////////////
r236 = fib(0.236); r236I = LastValue (r236);
r382 = fib(0.382); r382I = LastValue (r382);
r050 = fib(0.50); r050I = LastValue (r050);
r618 = fib(0.618); r618I = LastValue (r618);
r786 = fib(0.786); r786I = LastValue (r786);
e127 = fib(1.272); e127I = LastValue (e127);
e162 = fib(1.618); e162I = LastValue (e162);
e200 = fib(2.00); e200I = LastValue (e200);
e262 = fib(2.618); e262I = LastValue (e262);
e424 = fib(4.236); e424I = LastValue (e424);
//////////////////////////////////////////////////////////////////

p00 = IIf(xSp0 > xRp0,ySp0,yRp0); p00I = LastValue (p00);
p100 = IIf(xSp0 < xRp0,ySp0,yRp0); p100I = LastValue (p100);

color00 =IIf(xSp0 > xRp0,colorLime,colorRed);
color100 =IIf(xSp0 < xRp0,colorLime,colorRed);
//////////////////////////////////////////////////////////////////
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
//////////////////////////////////////////////////////////////////
if(Show_Fib)
{
Plot(LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back),"PR",colorRed, styleDashed|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",colorGreen, styleDashed|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r236,x1,r236,Back),"",45,style|styleNoRescale, Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r382,x1,r382,Back),"",44,style|styleNoRescale, Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r050,x1,r050,Back),"",colorGold,styleDashed|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r618,x1,r618,Back),"",43,style|styleNoRescale, Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r786,x1,r786,Back),"",42,style|styleNoRescale, Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e127,x1,e127,Back),"e127",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e162,x1,e162,Back),"e162",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e200,x1,e200,Back),"p200",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e262,x1,e262,Back),"p262",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e424,x1,e424,Back),"p424",25,style|styleNoRescale,Null, Null,Fwd);
}
//////////////////////////////////////////////////////////////////
if(Show_FibLabel)
{ 

//PlotText(" 0% = " + WriteVal(p00,fraction), LastValue(BarCount-8)+(numbars/hts), p00I, color00);


PlotText(" 0% = " + WriteVal(p00,fraction), LastValue(BarIndex())-(numbars/hts), p00I + 0.05, color00);
PlotText("23% = " + WriteVal(r236,fraction), LastValue(BarIndex())-(numbars/hts), r236I + 0.05, 45);
PlotText("38% = " + WriteVal(r382,fraction), LastValue(BarIndex())-(numbars/hts), r382I + 0.05, 44);
PlotText("50% = " + WriteVal(r050,fraction), LastValue(BarIndex())-(numbars/hts), r050I + 0.05, 41);
PlotText("62% = " + WriteVal(r618,fraction), LastValue(BarIndex())-(numbars/hts), r618I + 0.05, 43);
PlotText("78% = " + WriteVal(r786,fraction), LastValue(BarIndex())-(numbars/hts), r786I + 0.05, 42);
PlotText("100% = " + WriteVal(p100,fraction), LastValue(BarIndex())-(numbars/hts),p100I + 0.05, color100);
PlotText("127% = " + WriteVal(e127,fraction), LastValue(BarIndex())-(numbars/hts),e127I + 0.05, 47);
PlotText("162% = " + WriteVal(e162,fraction), LastValue(BarIndex())-(numbars/hts),e162I + 0.05, 47);
PlotText("200% = " + WriteVal(e200,fraction), LastValue(BarIndex())-(numbars/hts),e200I + 0.05, 47);
PlotText("262% = " + WriteVal(e262,fraction), LastValue(BarIndex())-(numbars/hts),e262I + 0.05, 47);
PlotText("424% = " + WriteVal(e424,fraction), LastValue(BarIndex())-(numbars/hts),e424I + 0.05, 25);

}

_SECTION_END();


_SECTION_BEGIN("Day High/Low");
Show_DHL =ParamToggle("Plot Day High/Low","No|Yes");
ColorHi = ParamColor("Color High", colorBrightGreen);
ColorLo = ParamColor("Color Low", colorDarkRed);


// Day High Low And Pivots
//TIME FRAME CALCULATION
H1 = TimeFrameGetPrice("H", inDaily);  // Today's high
L1 = TimeFrameGetPrice("L", inDaily);  //  low

if (Show_DHL)
{
Plot(H1, "",ColorHi, styleDashed|styleNoLabel);
Plot(L1, "",ColorLo,  styleDashed|styleNoLabel);

}
_SECTION_END();

_SECTION_BEGIN("Volume");
Show_Vol =ParamToggle("Show","No|Yes");
Color = ParamColor("Color", colorGrey50);
if (Show_Vol) 
Plot( Volume, _DEFAULT_NAME(), Color, styleHistogram | styleOwnScale);


_SECTION_END();


/////////////////////////////////////////////////////////////////
_SECTION_BEGIN("MA Cross Over");
ShowCrossover = ParamToggle("Show", "No|Yes");

if(ShowCrossover)
{
amv0=V*(O+H+L+C)/4;
line=Sum(amv0,50)/Sum(V,50);
CG=MA(C,14);
holdline=HHV(CG,3);

Plot(line,"Modified",colorYellow,styleNoLabel);
Plot(cg,"A",10,styleNoLabel);
Plot(Holdline,"B",13,styleNoLabel);
PlotOHLC(Holdline,Cg,Holdline,Cg,"",13,styleCloud| styleNoLabel);
}


_SECTION_BEGIN("Message Board");
Show=ParamToggle("Show","No|Yes",1);

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

if ( SelectedValue( LastSignal ) == 1 )
GfxSelectSolidBrush( colorDarkGreen );
else
GfxSelectSolidBrush( colorDarkRed );

y = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");

Left = 1100;
width = 310;
x = 5;
x2 = 290;

MktCond = TBR(no);


if (Show)
{
GfxSelectPen( colorLightBlue); 
GfxRoundRect( x, y - 210, x2, y , 7, 7 ) ;
GfxTextOut( "Thunder Bird Trading System V1.1",13,y-200);


GfxTextOut( WriteIf(MktCond>0, "Market Condition : Trending",
WriteIf(MktCond<0, "Market Condition : Ranging" ,"")),
13, y-170);

GfxTextOut( 
WriteIf (Buy, "Long At " +(BuyPrice),
WriteIf (Short, "Short At "+(SellPrice),
WriteIf (Relax, "NOT In Trade - RELAX!!!",""))), 
13, y-120);


GfxTextOut( 
WriteIf ( Buy OR Short, "StopLoss : " + dtsl, ""),
13, y-100);

if (TSL_MODE==0)
{
GfxTextOut( WriteIf(Sell AND NOT Short, "Exit Long At "+C,
WriteIf(Cover AND NOT Buy, "Exit Short At "+C,"")),
13, y-130);

}

GfxTextOut( 
WriteIf (Long AND NOT Buy, "Long At " +(BuyPrice),
WriteIf (Shrt AND NOT Short, "Short At "+(SellPrice),
WriteIf (Relax, "NOT In Trade - RELAX!!!",""))), 
13, y-120);

GfxTextOut( 
WriteIf ( (Long AND NOT Buy) OR (Shrt AND NOT Short), "StopLoss : " + dtsl, ""),
13, y-100);



GfxTextOut( 
WriteIf (Long AND NOT Buy, "Current P/L: "+(C-BuyPrice) +" Points",
WriteIf (Shrt AND NOT Short, "Current P/L: "+(SellPrice-C)+" Points","")),
13, y-145);

GfxTextOut( WriteIf (Long OR Buy OR Shrt OR Short, "Target 1 : "+tar1,""), 13, y-70);
GfxTextOut( WriteIf (Long OR Buy OR Shrt OR Short, "Target 2 : "+tar2,""), 13, y-50);
GfxTextOut( WriteIf (Long OR Buy OR Shrt OR Short, "Target 3 : "+tar3,""), 13, y-30);


GfxTextOut( WriteIf (buyach1 OR sellach1, "- Done!",""), 160, y-70); 
GfxTextOut( WriteIf (buyach2 OR sellach2, "- Done!",""), 160, y-50); 
GfxTextOut( WriteIf (buyach3 OR sellach3, "- Done!",""), 160, y-30); 


C13=20;
C14=2.1;
C15=12;

GfxSetBkMode( 1 );
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
//GfxTextOut( "TBTS V1.0", Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
//GfxTextOut( "By", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
//GfxTextOut( "www.stockmaniacs.net", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-25);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-35); 
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-30); 

PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=25);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=35); 
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-30);

if (TSL_MODE==0)
{
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorGold, 0, L, Offset=-15);
PlotShapes(IIf(Cover, shapeStar, shapeNone),colorGold, 0,L, Offset=-15);
PlotShapes(IIf(CloseTradeAtEOD==True AND TimeNum() > MktCloseTime AND NOT Relax, shapeStar, shapeNone),colorGold, 0,L, Offset=-15);
}
}
_SECTION_END();


_SECTION_BEGIN("BackTesting");

BackTest_Margin = Param("Margin Required", 15,0.001,100,0.001);
BackTest_LotSize = Param("LotSize", 50,5,5000,5);
BackTest_nLots = Param("# Lots Traded",1,1,10000,1);


//Settings for exploration

Filter=Buy OR Short;
AddColumn( IIf( Buy, 66 , 83 ), "Signal", formatChar, colorDefault, IIf( Buy , colorGreen, colorRed ) );
AddColumn(Close,"Entry Price",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(dtsl,"Stop Loss",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar1,"Target 1",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar2,"Target 2",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar3,"Target 3",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(Volume,"Volume",1.0, colorDefault, IIf ((Volume > 1.25 * EMA( Volume, 34 )),colorBlue,colorYellow));


//Settings for Backtester
SetOption("AllowSameBarExit", False);
SetOption("AllowPositionShrinking", False);
SetOption("FuturesMode", True);
SetOption("InterestRate",0);
SetOption("MaxOpenPositions",1);
RoundLotSize = BackTest_LotSize;
SetOption("MinShares",RoundLotSize);
SetOption("PriceBoundChecking",False);
//SetOption("CommissionMode",3);
//SetOption("CommissionAmount",12.5/RoundLotSize);
SetOption("AccountMargin",BackTest_Margin);
SetOption("ReverseSignalForcesExit",True);
SetOption("UsePrevBarEquityForPosSizing",True);
ApplyStop(stopTypeTrailing, stopModePoint, DTSL, True, True );

PositionSize = C*RoundLotSize*BackTest_nLots;
SetTradeDelays(0,0,0,0);
BuyPrice = Close;
SellPrice = Close;
ShortPrice = Close;
CoverPrice = Close;

//End of Settings for Backtester
_SECTION_END();



_SECTION_BEGIN("Magified Market Price");

FS=Param("Font Size",30,11,100,1);
Hor=Param("Horizontal Position",940,1,1200,1);
Ver=Param("Vertical Position",12,1,830,1); 

YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);

GfxSetBkMode( 1 ); 

GfxSelectFont("Times New Roman", FS, 700, True ); 
GfxSetTextColor( colorLime ); 
GfxTextOut(""+C, Hor , Ver );


GfxSelectFont("Times New Roman", 11, 700, True ); 
GfxSetTextColor(colorYellow ); 
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+45 );

_SECTION_END();
Previous
Next Post »