قديم 16-12-2012, 01:54 AM
  المشاركه #673

كاتب قدير

تاريخ التسجيل: Oct 2005
المشاركات: 8,424
منادي_2005 غير متواجد حالياً  

_SECTION_BEGIN("Chart Settings");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartBkGradientFill(ParamColor("Upper Chart",1),ParamColor("Lower Chart",1));
_SECTION_END();

SORT=(EMA(Close,3)+EMA(Close,5)+
EMA(Close,8)+EMA(Close,10)+
EMA(Close,12)+EMA(Close,15));

LONG=(EMA(Close,30)+EMA(Close,35)+
EMA(Close,40)+EMA(Close,45)+
EMA(Close,50)+EMA(Close,60));

GMMACD=(SORT-LONG)- EMA(SORT-LONG,9);

Plot(0,"",colorRed,styleLine|styleDashed);
Plot(GMMACD,"",colorAqua,styleLine|styleThick);

SetGradientFill( colorGreen /*top*/, colorRed /*bottom*/, 0 /*baseline level*/, GetChartBkColor() /*baseline color */);
Plot( GMMACD, "Fonksiyon", colorLightOrange, styleLine | styleGradient, Null, Null, 0,0 );


Buy=Cross(GMMACD,0);
Sell=Cross(0,GMMACD);
ExRem(Buy,Sell);
ExRem(Sell,Buy);

Filter= Buy OR Sell;

_SECTION_BEGIN("EXPLORER");

AL=Cross(GMMACD,0);
SAT=Cross(0,GMMACD);


AL_status= WriteIf(AL,"Al?? Yap"," ");
SAT_status=WriteIf(SAT,"Sat?? Yap"," ");

AL_Col=IIf(AL, colorDarkGreen , colorWhite);
SAT_Col=IIf(SAT, colorDarkRed,colorWhite);



Filter = AL OR SAT ;

AddColumn(C, "KAPANI?", 1.2, IIf(C > Ref(C,-1),colorBlue, colorRed));
AddTextColumn(AL_status, "AL WRANGE", 1.2, colorWhite, AL_col);
AddTextColumn(SAT_status, "SAT WRANGE ", 1.2, colorWhite, SAT_col);

_SECTION_END();





_SECTION_BEGIN("Chart Settings");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartBkGradientFill(ParamColor("Upper Chart",1),ParamColor("Lower Chart",1));
_SECTION_END();

SORT=(EMA(Close,3)+EMA(Close,5)+
EMA(Close,8)+EMA(Close,10)+
EMA(Close,12)+EMA(Close,15));

LONG=(EMA(Close,30)+EMA(Close,35)+
EMA(Close,40)+EMA(Close,45)+
EMA(Close,50)+EMA(Close,60));

GMMACD=(SORT-LONG)- EMA(SORT-LONG,9);



Buy=Cross(GMMACD,0);
Sell=Cross(0,GMMACD);
ExRem(Buy,Sell);
ExRem(Sell,Buy);

Filter= Buy OR Sell;



_SECTION_BEGIN("EXPLORER");

AL=Cross(GMMACD,0);
SAT=Cross(0,GMMACD);


AL_status= WriteIf(AL,"Al?? Yap"," ");
SAT_status=WriteIf(SAT,"Sat?? Yap"," ");

AL_Col=IIf(AL, colorDarkGreen , colorWhite);
SAT_Col=IIf(SAT, colorDarkRed,colorWhite);



Filter = AL OR SAT ;

AddColumn(C, "KAPANI?", 1.2, IIf(C > Ref(C,-1),colorBlue, colorRed));
AddTextColumn(AL_status, "AL WRANGE", 1.2, colorWhite, AL_col);
AddTextColumn(SAT_status, "SAT WRANGE ", 1.2, colorWhite, SAT_col);

_SECTION_END();

COLOR=IIf(AL,colorLime,IIf(SAT,colorRed,colorWhite));
Plot(C,"",COLOR,styleCandle|styleThick);
PlotShapes( IIf( Buy, shapeSmallUpTriangle, shapeNone ), colorAqua, layer = 0,yposition = L, offset = -30);
PlotShapes( IIf( Sell, shapeSmallDownTriangle, shapeNone ), colorRed, layer = 0, yposition =H, offset = -30);



رد مع اقتباس
 
 

قديم 16-12-2012, 01:55 AM
  المشاركه #674

كاتب قدير

تاريخ التسجيل: Oct 2005
المشاركات: 8,424
منادي_2005 غير متواجد حالياً  

نطام التداول الكامل


_SECTION_BEGIN("Trend Blaster V1.2");
messageboard =ParamToggle("Message Board","Show|Hide",1);
no = Optimize("TSL",Param("A (Change To Optimise)",10, 1, 55 ,1),1, 55 ,1);
multiplier1 = Optimize("Multiplier1",Param("B (Change To Optimise)",5, 1, 55 ,1),1, 55 ,1);
multiplier2 = Optimize("Multiplier2",Param("C (Change To Optimise)",22, 1, 55 ,1),1, 55 ,1);
showtsl =ParamToggle("Show SL Line","No|Yes");
aggressivemode =ParamToggle("Aggressive Mode","Yes|No",0);
stopreverse =ParamToggle("Switch To Stop And Reverse","No|Yes",0);
CloseAtEnd = ParamToggle("Close Positions EOD", "No|Yes");
ShowBands = ParamToggle("Show Trending Bands", "No|Yes");
supres=ParamToggle("Show Support / Resistance","No|Yes");
ShowCrossover = ParamToggle("Show Crossover", "No|Yes");
AudioAlert = ParamToggle("Human Voice Alert", "No|Yes");
EmailAlert = ParamToggle("E-mail Alert", "No|Yes");
AlertOutput = ParamToggle("Alert Output", "No|Yes");
showtrendline = ParamToggle("Show Trend Line", "No|Yes");
fibs = ParamToggle("Plot Fibonacci Retracement","No|Yes");
text = ParamToggle("Plot Fibonnaci As Text","No|Yes",0);
mktclose=Param("Market Close Time",152500,000000,235959,1 );

Param_Margin = Param("Margin required (used for backtesting only)", 15,0.001,100,0.001);
Param_LotSize = Param("Lot Size (used for backtesting only)", 50,5,5000,5);
Param_NoOfLots = Param("No of lots normally traded (used for backtesting only)",1,1,10000,1);

C13=20;
C14=2.1;
C15=12;
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");

EntrySignal = TBTS_F1();
ExitSignal = TBTS_F2();
Color = IIf( EntrySignal, colorBlue, IIf( ExitSignal, colorRed, colorLightGrey ));
Plot( C, "Price", Color, styleCandle | styleThick );

if (stopreverse==0)
{
if (aggressivemode == 0)

{
dtsl=TBTS_F3(no);
dB=H>dtsl;
dS=L<dtsl;
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);

TimeFrameSet(multiplier1*Interval());
wtsl=TBTS_F3(no);
WB=H>WTSL;
WS=L<WTSL;
TimeFrameRestore();
wtsl=TimeFrameExpand(wtsl,multiplier1*Interval(),expandFirst);
wb=TimeFrameExpand(WB,multiplier1*Interval(),expandFirst);
ws=TimeFrameExpand(WS,multiplier1*Interval(),expandFirst);


TimeFrameSet(multiplier2*Interval());
mtsl=TBTS_F3(no);
MB=H>MTSL;//Cross(H,mtsl);
MS=L<MTSL;//Cross(mtsl,L);
TimeFrameRestore();
mtsl=TimeFrameExpand(mtsl,multiplier2*Interval(),expandFirst);
mb=TimeFrameExpand(MB,multiplier2*Interval(),expandFirst);
ms=TimeFrameExpand(MS,multiplier2*Interval(),expandFirst);
}

if (aggressivemode == 1)
{
dtsl=TBTS_F3(no);
dB=H>dtsl;
dS=L<dtsl;
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);

TimeFrameSet(multiplier1*Interval());
wtsl=TBTS_F3(no);
WB=H>WTSL;
WS=L<WTSL;
TimeFrameRestore();
wtsl=TimeFrameExpand(wtsl,multiplier1*Interval(),expandLast);
wb=TimeFrameExpand(WB,multiplier1*Interval(),expandLast);
ws=TimeFrameExpand(WS,multiplier1*Interval(),expandLast);

TimeFrameSet(multiplier2*Interval());
mtsl=TBTS_F3(no);
MB=H>MTSL;
MS=L<MTSL;
TimeFrameRestore();
mtsl=TimeFrameExpand(mtsl,multiplier2*Interval(),expandLast);
mb=TimeFrameExpand(MB,multiplier2*Interval(),expandLast);
ms=TimeFrameExpand(MS,multiplier2*Interval(),expandLast);
}

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(CloseAtEnd==False, (DS OR (DS AND WS) AND (Low > MTSL)), (DS OR (DS AND WS) AND (Low > MTSL)) OR TimeNum() > mktclose);
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(CloseAtEnd==False, (DB OR (DB AND WB) AND (High < MTSL)), (DB OR (DB AND WB) AND (High < MTSL)) OR TimeNum() > mktclose);
}

if (stopreverse==1)
{
dtsl=TBTS_F4(no);
dB=C>dtsl;
dS=C<dtsl;
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 = Cover = DB;
Sell = Short = DS;
}

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

SellPrice=ValueWhen(Short,C,1);
BuyPrice=ValueWhen(Buy,C,1);
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,1);
BuySL=ValueWhen(Buy,DTSL,1);
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);

Trend = ADX(14) > 25 AND NOT ADX(14) < Ref(ADX(14), -1);
Range = ADX(14) < 25 AND NOT ADX(14) > Ref(ADX(14), -1);


if (AudioAlert==True)
{
if (SelectedValue(Buy)==1) Say("Go long in "+Name()+" at current market price "+C);
if (SelectedValue(Short)==1) Say("Go short in "+Name()+" at current market price "+C);
if (stopreverse==0)
{
if (SelectedValue(Sell AND NOT Short)==1) Say("Exit long in "+Name()+" at current market price "+C);
if (SelectedValue(Cover AND NOT Buy)==1) Say("Exit short in "+Name()+" at current market price "+C);
}
}

if (EmailAlert==True)
{
AlertIf( Buy, "EMAIL", "Long signal generated on "+FullName(), 1 );
if (stopreverse==0)
{
AlertIf( Sell AND NOT Short, "EMAIL", "Exit long signal generated on "+FullName(), 1 );
}
AlertIf( Short, "EMAIL", "Short signal generated on "+FullName(), 1 );
if (stopreverse==0)
{
AlertIf( Cover AND NOT Buy, "EMAIL", "Exit short signal generated on "+FullName(), 1 );
}
}

if (AlertOutput==True) {
AlertIf( Buy, "", "Buy Signal Generated"+Name(), 4 );
AlertIf( Sell AND NOT Short, "", "Exit Long Signal Generated"+Name(), 4 );
AlertIf( Short, "", "Short Signal Generated"+Name(), 4 );
AlertIf( Cover AND NOT Buy, "", "Exit Short Signal Generated"+Name(), 4 );
}

if (showtsl==True)
{
tsl = IIf(Buy OR Long OR Short OR Shrt AND NOT Relax, dtsl,Null);
tslcolor = IIf(Buy OR Long AND NOT Relax, colorGreen, colorRed);
Plot(tsl, "",tslcolor, styleLine|styleDots|styleThick);
}

if
(messageboard == 0 )

{

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

GfxSelectFont( "Tahoma", 13, 100 );

GfxSetBkMode( 1 );

GfxSetTextColor
( colorWhite );

GfxSelectSolidBrush( colorGreen );

pxHeight = Status( "pxchartheight" ) ;

xx = Status( "pxchartwidth");

Left = 1100;

width = 310;

x = 5;

x2 = 290;

y = pxHeight;

GfxSelectPen
( colorLightBlue, 1); // border color

GfxRoundRect
( x, y - 215, x2, y , 7, 7 ) ;

GfxTextOut
( ("For Enquiry: www.stockmaniacs.net"),13,y-210);

GfxTextOut
( ("" + WriteIf(trend, "Trending Market Condition " ,"")), 13, y-185);

GfxTextOut
( ("" + WriteIf(range, "Rangebound Market Condition " ,"")), 13, y-185);

GfxTextOut
( ("" + WriteIf(Buy, "Go Long At "+C+" - SL " +dtsl,"")), 13, y-165);

GfxTextOut
( ("" + WriteIf (Short, "Go Short At "+C+" - SL " +dtsl,"")), 13, y-165);

if (stopreverse==0)
{
GfxTextOut
( ("" + WriteIf (Sell AND NOT Short, "Exit Long At "+C,"")), 13, y-165);

GfxTextOut
( ("" + WriteIf (Cover AND NOT Buy, "Exit Short At "+C,"")), 13, y-165);
}

GfxTextOut
( ("" + WriteIf (Long AND NOT Buy, "Long At "+(BuyPrice)+" - TSL " + dtsl + "","")), 13, y-165);

GfxTextOut
( ("" + WriteIf (shrt AND NOT Short, "Short At "+(SellPrice)+" - TSL " + dtsl + "","")), 13, y-165);

GfxTextOut
( ("" + WriteIf (Relax, "Not In Trade - RELAX!!!","")), 13, y-165);

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

GfxTextOut
( ("" + 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-125);

GfxTextOut
( ("" + WriteIf (Long OR Buy OR Shrt OR Short, "Target 2: "+tar2,"")), 13, y-105);

GfxTextOut
( ("" + WriteIf (Long OR Buy OR Shrt OR Short, "Target 3: "+tar3,"")), 13, y-85);

GfxTextOut
( ("" + WriteIf (buyach1, "Target 1 Done: "+tar1,"")), 13, y-65);

GfxTextOut
( ("" + WriteIf (sellach1, "Target 1 Done: "+tar1,"")), 13, y-65);

GfxTextOut
( ("" + WriteIf (buyach2, "Target 2 Done: "+tar2,"")), 13, y-45);

GfxTextOut
( ("" + WriteIf (sellach2, "Target 2 Done: "+tar2,"")), 13, y-45);

GfxTextOut
( ("" + WriteIf (buyach3, "Target 3 Done: "+tar3,"")), 13, y-25);

GfxTextOut
( ("" + WriteIf (sellach3, "Target 3 Done: "+tar3,"")), 13, y-25);

}

GfxSetBkMode( 1 );
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
//GfxTextOut( "Trend Blaster V1.2", 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 (stopreverse==0)
{
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorGold, 0, L, Offset=-15);
PlotShapes(IIf(Cover, shapeStar, shapeNone),colorGold, 0,L, Offset=-15);
PlotShapes(IIf(CloseAtEnd==True AND TimeNum() > mktclose AND NOT Relax, shapeStar, shapeNone),colorGold, 0,L, Offset=-15);
}

if (messageboard == 1 )
{
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorYellow)+ "Trend Blaster Trading System V1.1 - www.stockmaniacs.net" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorSkyblue) +
" - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Open-"+O+" "+"High-"+H+" "+"Low-"+L+" "+"Close-"+C+" "+ "Volume= "+ WriteVal(V)+"\n"+"\n"+
EncodeColor(colorLime)+"\n"+
WriteIf(trend, "Trending Market Condition " ,"")+
WriteIf(range, "Rangebound Market Condition " ,"")+"\n"+
WriteIf (Buy, "Action: Go Long At "+C+" - SL " +DTSL,"")+
WriteIf (Short, "Action: Go Short At "+C+" - SL " +DTSL,"")+
WriteIf(Long AND NOT Buy, "Action : Long Taken At "+(BuyPrice)+" - Trail SL " + DTSL + "","")+
WriteIf(shrt AND NOT Sell, "Action : Short Taken At "+(SellPrice)+" - Trail SL " + DTSL + "","")+
WriteIf (Sell AND NOT Short, "Exit Long At "+C,"")+
WriteIf (Cover AND NOT Buy, "Exit Short At "+C,"")+
WriteIf(NOT Long AND NOT Buy AND NOT shrt AND NOT Sell, "Action: Not In A Trade - RELAX!!!","")+"\n"+
WriteIf(Long AND NOT Buy, "Profit/Loss: "+(C-BuyPrice)+" Points","")+
WriteIf(shrt AND NOT Sell, "Profit/Loss: "+(SellPrice-C)+" Points","")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 1: "+tar1,"")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 2: "+tar2,"")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 3: "+tar3,"")+"\n"+
WriteIf(buyach1, "Target 1 Done: "+tar1,"")+
WriteIf(sellach1, "Target 1 Done: "+tar1,"")+"\n"+
WriteIf(buyach2, "Target 2 Done: "+tar2,"")+
WriteIf(sellach2, "Target 2 Done: "+tar2,"")+"\n"+
WriteIf(buyach3, "Target 3 Done: "+tar3,"")+
WriteIf(sellach3, "Target 3 Done: "+tar3,""));
}

//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("sMode", True);
SetOption("InterestRate",0);
SetOption("MaxOpenPositions",1);
RoundLotSize = Param_LotSize;
SetOption("MinShares",RoundLotSize);
SetOption("PriceBoundChecking",False);
//SetOption("CommissionMode",3);
//SetOption("CommissionAmount",12.5/RoundLotSize);
SetOption("AccountMargin",Param_Margin);
SetOption("ReverseSignalForcesExit",True);
SetOption("UsePrevBarEquityForPosSizing",True);
ApplyStop(stopTypeTrailing, stopModePoint, DTSL, True, True );

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

//End of Settings for Backtester

/* Standard Error Bands */
Periods = 80;
Smooth = 14;

MALRCurve = TBTS_F5(Periods,Smooth);
SErrorAvg = TBTS_F6(Periods,Smooth);

LowerBand = MALRCurve - SErrorAvg ;
UpperBand = MALRCurve + SErrorAvg ;
if(ShowBands==True)
{
Plot( MALRCurve , "MidBand", ParamColor("ColorMB",colorLime) , ParamStyle("StyleMB", style=styleDashed, Mask=maskDefault ));
Plot( UpperBand , "UpperBand", ParamColor("ColorUp",colorLime) , ParamStyle("StyleUp", style=styleLine, Mask=maskDefault ));
Plot( LowerBand , "LowerBand", ParamColor("ColorLo",colorLime) , ParamStyle("StyleLo", style=styleLine, Mask=maskDefault ));
}

// Support & resistance identification

HaClose = EMA(TBTS_F7(),3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
Temp = Max(High, HaOpen);
Temp = Min(Low,HaOpen);

if(supres==True)
{
Prd1=Param("Res_Period1",10,0,200,1);

test = TEMA ( High , Prd1 ) ;

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,lastmode = True ), Null, LastValue(MPKV,Lastmode = True));//SelectedDate
Plot(SD, "Resist1", colorRed,ParamStyle("ResStyle1",styleLine|styleThick|styleDots|styleNoTitle,ma skAll));

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,lastmode = True ), Null, LastValue(MPKV2,Lastmode = True));//SelectedDate
Plot(SD2, "Resist2", colorRed,ParamStyle("ResStyle2",styleLine|styleNoTitle,maskAll));


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,lastmode = True ), Null, LastValue(MPKV3,Lastmode = True));//SelectedDate
Plot(SD3, "Resist3", colorRed,ParamStyle("ResStyle3",styleLine|styleNoTitle,maskAll));

HaClose = EMA(TBTS_F7(),3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
Temp = Max(High, HaOpen);
Temp = Min(Low,HaOpen);

//SP=L > Ref(L,-1) AND Ref(L,1) < L;//Peak

Prd2=10;

test2 = TEMA ( Low , Prd2 ) ;

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

//PKV5 = ValueWhen(PK,haHigh,5);//PeakValue5
//PKV6 = ValueWhen(PK,haHigh,6);//PeakValue6

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,lastmode = True ), Null, LastValue(MSPV,Lastmode = True));
Plot(SD,"Support1", colorGreen,ParamStyle("SupportLine1",styleLine|styleThick|styleDots|styleNoTit le,maskAll));

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,lastmode = True ), Null, LastValue(MSPV2,Lastmode = True));
Plot(SD2,"Support2", colorGreen,ParamStyle("SupportLine2",styleLine|styleNoTitle,maskAll));

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,lastmode = True ), Null, LastValue(MSPV3,Lastmode = True));
Plot(SD3,"Support3", colorGreen,ParamStyle("SupportLine3",styleLine|styleNoTitle,maskAll));
}

//Fibonacci cluster
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, 1) == 0;
yRp0 = SelectedValue(ValueWhen( pRp, H, HiLB));
xRp0 = SelectedValue(ValueWhen( pRp, x, HiLB));
pSp = TroughBars( L, pctL, 1) == 0;
ySp0 = SelectedValue(ValueWhen( pSp, L, LoLB));
xSp0 = SelectedValue(ValueWhen( pSp, x, LoLB));
Delta = yRp0 - ySp0;

function fib(ret)
{
retval = (Delta * ret);
Fibval = IIf(ret < 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret < 1.0
AND xSp0 > xRp0, ySp0 + retval,IIf(ret > 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret > 1.0
AND xSp0 > xRp0, ySp0 + retval, Null))));
return FibVal;
}

x0 = Min(xSp0,xRp0)-Back;
x1 = (BarCount -1);
//////////////////////////////////////////////////////////////////
r236 = fib(0.236); r236I = LastValue (r236,1);
r382 = fib(0.382); r382I = LastValue (r382,1);
r050 = fib(0.50); r050I = LastValue (r050,1);
r618 = fib(0.618); r618I = LastValue (r618,1);
r786 = fib(0.786); r786I = LastValue (r786,1);
e127 = fib(1.27); e127I = LastValue (e127,1);
e162 = fib(1.62); e162I = LastValue (e162,1);
e200 = fib(2.00); e200I = LastValue (e200,1);
e262 = fib(2.62); e262I = LastValue (e262,1);
e424 = fib(4.24); e424I = LastValue (e424,1);
//////////////////////////////////////////////////////////////////
p00 = IIf(xSp0 > xRp0,ySp0,yRp0); p00I = LastValue (p00,1);
p100 = IIf(xSp0 < xRp0,ySp0,yRp0); p100I = LastValue (p100,1);
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(fibs==True)
{
Plot(LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back),"PR",32,8|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",27,8|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),"",41,style|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(text==1)
{
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);
}
/////////////////////////////////////////////////////////////////
m = 60;
amv0=Volume*(O+H+L+C)/4;
line=Sum(amv0,50)/Sum(Volume,50);
CG=MA(C,14);
holdline=HHV(CG,3);
if(ShowCrossover==True)
{
Plot(line,"Modified",7,1);
Plot(cg,"A",10,1);
Plot(Holdline,"B",13,1);
PlotOHLC(Holdline,Cg,Holdline,Cg,"",13,styleCloud);
}

if (showtrendline == True)

{
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++
THIS SECTION DRAWS TD TREND LINES */

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

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

for( i = 1; i < BarCount AND y0 >= y1; i++ )
{

firstpointL++;
y0=LastValue(Trough(L,percent,firstpointL));
}

x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpointL));
x1=BarCount - 1 - LastValue(TroughBars(Ref(L,-1),percent,1));
LineL = LineArray( x0, y0, x1, y1, 1 );
/*
Plot(C, "C", colorBlack, styleCandle);
*/
Plot( LineL, " Support Trend line", colorGreen,4 +8 );


yt0=LastValue(Peak(H,percent,firstpointH));
yt1=LastValue(Peak(Ref(H,-1),percent,1));

for(i = 1; i < BarCount AND yt0 <= yt1; i++ )
{

firstpointH++;
yt0=LastValue(Peak(H,percent,firstpointH));
}
xt0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpointH));
xt1=BarCount - 1 - LastValue(PeakBars(Ref(H,-1),percent,1));
LineH = LineArray( xt0, yt0, xt1, yt1, 1 );

Plot( LineH, "Resistance Trend line", colorRed,4 + 8 );

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++*/
}

_SECTION_END();



رد مع اقتباس
قديم 16-12-2012, 01:57 AM
  المشاركه #675

كاتب قدير

تاريخ التسجيل: Oct 2005
المشاركات: 8,424
منادي_2005 غير متواجد حالياً  

_SECTION_BEGIN("Trend Blaster V1.2");
messageboard =ParamToggle("Message Board","Show|Hide",1);
no = Optimize("TSL",Param("A (Change To Optimise)",10, 1, 55 ,1),1, 55 ,1);
multiplier1 = Optimize("Multiplier1",Param("B (Change To Optimise)",5, 1, 55 ,1),1, 55 ,1);
multiplier2 = Optimize("Multiplier2",Param("C (Change To Optimise)",22, 1, 55 ,1),1, 55 ,1);
showtsl =ParamToggle("Show SL Line","No|Yes");
aggressivemode =ParamToggle("Aggressive Mode","Yes|No",0);
stopreverse =ParamToggle("Switch To Stop And Reverse","No|Yes",0);
CloseAtEnd = ParamToggle("Close Positions EOD", "No|Yes");
ShowBands = ParamToggle("Show Trending Bands", "No|Yes");
supres=ParamToggle("Show Support / Resistance","No|Yes");
ShowCrossover = ParamToggle("Show Crossover", "No|Yes");
AudioAlert = ParamToggle("Human Voice Alert", "No|Yes");
EmailAlert = ParamToggle("E-mail Alert", "No|Yes");
AlertOutput = ParamToggle("Alert Output", "No|Yes");
showtrendline = ParamToggle("Show Trend Line", "No|Yes");
fibs = ParamToggle("Plot Fibonacci Retracement","No|Yes");
text = ParamToggle("Plot Fibonnaci As Text","No|Yes",0);
mktclose=Param("Market Close Time",152500,000000,235959,1 );

Param_Margin = Param("Margin required (used for backtesting only)", 15,0.001,100,0.001);
Param_LotSize = Param("Lot Size (used for backtesting only)", 50,5,5000,5);
Param_NoOfLots = Param("No of lots normally traded (used for backtesting only)",1,1,10000,1);

C13=20;
C14=2.1;
C15=12;
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");

EntrySignal = TBTS_F1();
ExitSignal = TBTS_F2();
Color = IIf( EntrySignal, colorBlue, IIf( ExitSignal, colorRed, colorLightGrey ));
Plot( C, "Price", Color, styleCandle | styleThick );

if (stopreverse==0)
{
if (aggressivemode == 0)

{
dtsl=TBTS_F3(no);
dB=H>dtsl;
dS=L<dtsl;
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);

TimeFrameSet(multiplier1*Interval());
wtsl=TBTS_F3(no);
WB=H>WTSL;
WS=L<WTSL;
TimeFrameRestore();
wtsl=TimeFrameExpand(wtsl,multiplier1*Interval(),expandFirst);
wb=TimeFrameExpand(WB,multiplier1*Interval(),expandFirst);
ws=TimeFrameExpand(WS,multiplier1*Interval(),expandFirst);


TimeFrameSet(multiplier2*Interval());
mtsl=TBTS_F3(no);
MB=H>MTSL;//Cross(H,mtsl);
MS=L<MTSL;//Cross(mtsl,L);
TimeFrameRestore();
mtsl=TimeFrameExpand(mtsl,multiplier2*Interval(),expandFirst);
mb=TimeFrameExpand(MB,multiplier2*Interval(),expandFirst);
ms=TimeFrameExpand(MS,multiplier2*Interval(),expandFirst);
}

if (aggressivemode == 1)
{
dtsl=TBTS_F3(no);
dB=H>dtsl;
dS=L<dtsl;
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);

TimeFrameSet(multiplier1*Interval());
wtsl=TBTS_F3(no);
WB=H>WTSL;
WS=L<WTSL;
TimeFrameRestore();
wtsl=TimeFrameExpand(wtsl,multiplier1*Interval(),expandLast);
wb=TimeFrameExpand(WB,multiplier1*Interval(),expandLast);
ws=TimeFrameExpand(WS,multiplier1*Interval(),expandLast);

TimeFrameSet(multiplier2*Interval());
mtsl=TBTS_F3(no);
MB=H>MTSL;
MS=L<MTSL;
TimeFrameRestore();
mtsl=TimeFrameExpand(mtsl,multiplier2*Interval(),expandLast);
mb=TimeFrameExpand(MB,multiplier2*Interval(),expandLast);
ms=TimeFrameExpand(MS,multiplier2*Interval(),expandLast);
}

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(CloseAtEnd==False, (DS OR (DS AND WS) AND (Low > MTSL)), (DS OR (DS AND WS) AND (Low > MTSL)) OR TimeNum() > mktclose);
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(CloseAtEnd==False, (DB OR (DB AND WB) AND (High < MTSL)), (DB OR (DB AND WB) AND (High < MTSL)) OR TimeNum() > mktclose);
}

if (stopreverse==1)
{
dtsl=TBTS_F4(no);
dB=C>dtsl;
dS=C<dtsl;
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 = Cover = DB;
Sell = Short = DS;
}

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

SellPrice=ValueWhen(Short,C,1);
BuyPrice=ValueWhen(Buy,C,1);
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,1);
BuySL=ValueWhen(Buy,DTSL,1);
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);

Trend = ADX(14) > 25 AND NOT ADX(14) < Ref(ADX(14), -1);
Range = ADX(14) < 25 AND NOT ADX(14) > Ref(ADX(14), -1);


if (AudioAlert==True)
{
if (SelectedValue(Buy)==1) Say("Go long in "+Name()+" at current market price "+C);
if (SelectedValue(Short)==1) Say("Go short in "+Name()+" at current market price "+C);
if (stopreverse==0)
{
if (SelectedValue(Sell AND NOT Short)==1) Say("Exit long in "+Name()+" at current market price "+C);
if (SelectedValue(Cover AND NOT Buy)==1) Say("Exit short in "+Name()+" at current market price "+C);
}
}

if (EmailAlert==True)
{
AlertIf( Buy, "EMAIL", "Long signal generated on "+FullName(), 1 );
if (stopreverse==0)
{
AlertIf( Sell AND NOT Short, "EMAIL", "Exit long signal generated on "+FullName(), 1 );
}
AlertIf( Short, "EMAIL", "Short signal generated on "+FullName(), 1 );
if (stopreverse==0)
{
AlertIf( Cover AND NOT Buy, "EMAIL", "Exit short signal generated on "+FullName(), 1 );
}
}

if (AlertOutput==True) {
AlertIf( Buy, "", "Buy Signal Generated"+Name(), 4 );
AlertIf( Sell AND NOT Short, "", "Exit Long Signal Generated"+Name(), 4 );
AlertIf( Short, "", "Short Signal Generated"+Name(), 4 );
AlertIf( Cover AND NOT Buy, "", "Exit Short Signal Generated"+Name(), 4 );
}

if (showtsl==True)
{
tsl = IIf(Buy OR Long OR Short OR Shrt AND NOT Relax, dtsl,Null);
tslcolor = IIf(Buy OR Long AND NOT Relax, colorGreen, colorRed);
Plot(tsl, "",tslcolor, styleLine|styleDots|styleThick);
}

if
(messageboard == 0 )

{

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

GfxSelectFont( "Tahoma", 13, 100 );

GfxSetBkMode( 1 );

GfxSetTextColor
( colorWhite );

GfxSelectSolidBrush( colorGreen );

pxHeight = Status( "pxchartheight" ) ;

xx = Status( "pxchartwidth");

Left = 1100;

width = 310;

x = 5;

x2 = 290;

y = pxHeight;

GfxSelectPen
( colorLightBlue, 1); // border color

GfxRoundRect
( x, y - 215, x2, y , 7, 7 ) ;

GfxTextOut
( ("For Enquiry: www.stockmaniacs.net"),13,y-210);

GfxTextOut
( ("" + WriteIf(trend, "Trending Market Condition " ,"")), 13, y-185);

GfxTextOut
( ("" + WriteIf(range, "Rangebound Market Condition " ,"")), 13, y-185);

GfxTextOut
( ("" + WriteIf(Buy, "Go Long At "+C+" - SL " +dtsl,"")), 13, y-165);

GfxTextOut
( ("" + WriteIf (Short, "Go Short At "+C+" - SL " +dtsl,"")), 13, y-165);

if (stopreverse==0)
{
GfxTextOut
( ("" + WriteIf (Sell AND NOT Short, "Exit Long At "+C,"")), 13, y-165);

GfxTextOut
( ("" + WriteIf (Cover AND NOT Buy, "Exit Short At "+C,"")), 13, y-165);
}

GfxTextOut
( ("" + WriteIf (Long AND NOT Buy, "Long At "+(BuyPrice)+" - TSL " + dtsl + "","")), 13, y-165);

GfxTextOut
( ("" + WriteIf (shrt AND NOT Short, "Short At "+(SellPrice)+" - TSL " + dtsl + "","")), 13, y-165);

GfxTextOut
( ("" + WriteIf (Relax, "Not In Trade - RELAX!!!","")), 13, y-165);

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

GfxTextOut
( ("" + 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-125);

GfxTextOut
( ("" + WriteIf (Long OR Buy OR Shrt OR Short, "Target 2: "+tar2,"")), 13, y-105);

GfxTextOut
( ("" + WriteIf (Long OR Buy OR Shrt OR Short, "Target 3: "+tar3,"")), 13, y-85);

GfxTextOut
( ("" + WriteIf (buyach1, "Target 1 Done: "+tar1,"")), 13, y-65);

GfxTextOut
( ("" + WriteIf (sellach1, "Target 1 Done: "+tar1,"")), 13, y-65);

GfxTextOut
( ("" + WriteIf (buyach2, "Target 2 Done: "+tar2,"")), 13, y-45);

GfxTextOut
( ("" + WriteIf (sellach2, "Target 2 Done: "+tar2,"")), 13, y-45);

GfxTextOut
( ("" + WriteIf (buyach3, "Target 3 Done: "+tar3,"")), 13, y-25);

GfxTextOut
( ("" + WriteIf (sellach3, "Target 3 Done: "+tar3,"")), 13, y-25);

}

GfxSetBkMode( 1 );
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
//GfxTextOut( "Trend Blaster V1.2", 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 (stopreverse==0)
{
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorGold, 0, L, Offset=-15);
PlotShapes(IIf(Cover, shapeStar, shapeNone),colorGold, 0,L, Offset=-15);
PlotShapes(IIf(CloseAtEnd==True AND TimeNum() > mktclose AND NOT Relax, shapeStar, shapeNone),colorGold, 0,L, Offset=-15);
}

if (messageboard == 1 )
{
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorYellow)+ "Trend Blaster Trading System V1.1 - www.stockmaniacs.net" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorSkyblue) +
" - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Open-"+O+" "+"High-"+H+" "+"Low-"+L+" "+"Close-"+C+" "+ "Volume= "+ WriteVal(V)+"\n"+"\n"+
EncodeColor(colorLime)+"\n"+
WriteIf(trend, "Trending Market Condition " ,"")+
WriteIf(range, "Rangebound Market Condition " ,"")+"\n"+
WriteIf (Buy, "Action: Go Long At "+C+" - SL " +DTSL,"")+
WriteIf (Short, "Action: Go Short At "+C+" - SL " +DTSL,"")+
WriteIf(Long AND NOT Buy, "Action : Long Taken At "+(BuyPrice)+" - Trail SL " + DTSL + "","")+
WriteIf(shrt AND NOT Sell, "Action : Short Taken At "+(SellPrice)+" - Trail SL " + DTSL + "","")+
WriteIf (Sell AND NOT Short, "Exit Long At "+C,"")+
WriteIf (Cover AND NOT Buy, "Exit Short At "+C,"")+
WriteIf(NOT Long AND NOT Buy AND NOT shrt AND NOT Sell, "Action: Not In A Trade - RELAX!!!","")+"\n"+
WriteIf(Long AND NOT Buy, "Profit/Loss: "+(C-BuyPrice)+" Points","")+
WriteIf(shrt AND NOT Sell, "Profit/Loss: "+(SellPrice-C)+" Points","")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 1: "+tar1,"")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 2: "+tar2,"")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 3: "+tar3,"")+"\n"+
WriteIf(buyach1, "Target 1 Done: "+tar1,"")+
WriteIf(sellach1, "Target 1 Done: "+tar1,"")+"\n"+
WriteIf(buyach2, "Target 2 Done: "+tar2,"")+
WriteIf(sellach2, "Target 2 Done: "+tar2,"")+"\n"+
WriteIf(buyach3, "Target 3 Done: "+tar3,"")+
WriteIf(sellach3, "Target 3 Done: "+tar3,""));
}

//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("sMode", True);
SetOption("InterestRate",0);
SetOption("MaxOpenPositions",1);
RoundLotSize = Param_LotSize;
SetOption("MinShares",RoundLotSize);
SetOption("PriceBoundChecking",False);
//SetOption("CommissionMode",3);
//SetOption("CommissionAmount",12.5/RoundLotSize);
SetOption("AccountMargin",Param_Margin);
SetOption("ReverseSignalForcesExit",True);
SetOption("UsePrevBarEquityForPosSizing",True);
ApplyStop(stopTypeTrailing, stopModePoint, DTSL, True, True );

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

//End of Settings for Backtester

/* Standard Error Bands */
Periods = 80;
Smooth = 14;

MALRCurve = TBTS_F5(Periods,Smooth);
SErrorAvg = TBTS_F6(Periods,Smooth);

LowerBand = MALRCurve - SErrorAvg ;
UpperBand = MALRCurve + SErrorAvg ;
if(ShowBands==True)
{
Plot( MALRCurve , "MidBand", ParamColor("ColorMB",colorLime) , ParamStyle("StyleMB", style=styleDashed, Mask=maskDefault ));
Plot( UpperBand , "UpperBand", ParamColor("ColorUp",colorLime) , ParamStyle("StyleUp", style=styleLine, Mask=maskDefault ));
Plot( LowerBand , "LowerBand", ParamColor("ColorLo",colorLime) , ParamStyle("StyleLo", style=styleLine, Mask=maskDefault ));
}

// Support & resistance identification

HaClose = EMA(TBTS_F7(),3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
Temp = Max(High, HaOpen);
Temp = Min(Low,HaOpen);

if(supres==True)
{
Prd1=Param("Res_Period1",10,0,200,1);

test = TEMA ( High , Prd1 ) ;

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,lastmode = True ), Null, LastValue(MPKV,Lastmode = True));//SelectedDate
Plot(SD, "Resist1", colorRed,ParamStyle("ResStyle1",styleLine|styleThick|styleDots|styleNoTitle,ma skAll));

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,lastmode = True ), Null, LastValue(MPKV2,Lastmode = True));//SelectedDate
Plot(SD2, "Resist2", colorRed,ParamStyle("ResStyle2",styleLine|styleNoTitle,maskAll));


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,lastmode = True ), Null, LastValue(MPKV3,Lastmode = True));//SelectedDate
Plot(SD3, "Resist3", colorRed,ParamStyle("ResStyle3",styleLine|styleNoTitle,maskAll));

HaClose = EMA(TBTS_F7(),3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
Temp = Max(High, HaOpen);
Temp = Min(Low,HaOpen);

//SP=L > Ref(L,-1) AND Ref(L,1) < L;//Peak

Prd2=10;

test2 = TEMA ( Low , Prd2 ) ;

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

//PKV5 = ValueWhen(PK,haHigh,5);//PeakValue5
//PKV6 = ValueWhen(PK,haHigh,6);//PeakValue6

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,lastmode = True ), Null, LastValue(MSPV,Lastmode = True));
Plot(SD,"Support1", colorGreen,ParamStyle("SupportLine1",styleLine|styleThick|styleDots|styleNoTit le,maskAll));

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,lastmode = True ), Null, LastValue(MSPV2,Lastmode = True));
Plot(SD2,"Support2", colorGreen,ParamStyle("SupportLine2",styleLine|styleNoTitle,maskAll));

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,lastmode = True ), Null, LastValue(MSPV3,Lastmode = True));
Plot(SD3,"Support3", colorGreen,ParamStyle("SupportLine3",styleLine|styleNoTitle,maskAll));
}

//Fibonacci cluster
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, 1) == 0;
yRp0 = SelectedValue(ValueWhen( pRp, H, HiLB));
xRp0 = SelectedValue(ValueWhen( pRp, x, HiLB));
pSp = TroughBars( L, pctL, 1) == 0;
ySp0 = SelectedValue(ValueWhen( pSp, L, LoLB));
xSp0 = SelectedValue(ValueWhen( pSp, x, LoLB));
Delta = yRp0 - ySp0;

function fib(ret)
{
retval = (Delta * ret);
Fibval = IIf(ret < 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret < 1.0
AND xSp0 > xRp0, ySp0 + retval,IIf(ret > 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret > 1.0
AND xSp0 > xRp0, ySp0 + retval, Null))));
return FibVal;
}

x0 = Min(xSp0,xRp0)-Back;
x1 = (BarCount -1);
//////////////////////////////////////////////////////////////////
r236 = fib(0.236); r236I = LastValue (r236,1);
r382 = fib(0.382); r382I = LastValue (r382,1);
r050 = fib(0.50); r050I = LastValue (r050,1);
r618 = fib(0.618); r618I = LastValue (r618,1);
r786 = fib(0.786); r786I = LastValue (r786,1);
e127 = fib(1.27); e127I = LastValue (e127,1);
e162 = fib(1.62); e162I = LastValue (e162,1);
e200 = fib(2.00); e200I = LastValue (e200,1);
e262 = fib(2.62); e262I = LastValue (e262,1);
e424 = fib(4.24); e424I = LastValue (e424,1);
//////////////////////////////////////////////////////////////////
p00 = IIf(xSp0 > xRp0,ySp0,yRp0); p00I = LastValue (p00,1);
p100 = IIf(xSp0 < xRp0,ySp0,yRp0); p100I = LastValue (p100,1);
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(fibs==True)
{
Plot(LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back),"PR",32,8|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",27,8|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),"",41,style|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(text==1)
{
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);
}
/////////////////////////////////////////////////////////////////
m = 60;
amv0=Volume*(O+H+L+C)/4;
line=Sum(amv0,50)/Sum(Volume,50);
CG=MA(C,14);
holdline=HHV(CG,3);
if(ShowCrossover==True)
{
Plot(line,"Modified",7,1);
Plot(cg,"A",10,1);
Plot(Holdline,"B",13,1);
PlotOHLC(Holdline,Cg,Holdline,Cg,"",13,styleCloud);
}

if (showtrendline == True)

{
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++
THIS SECTION DRAWS TD TREND LINES */

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

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

for( i = 1; i < BarCount AND y0 >= y1; i++ )
{

firstpointL++;
y0=LastValue(Trough(L,percent,firstpointL));
}

x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpointL));
x1=BarCount - 1 - LastValue(TroughBars(Ref(L,-1),percent,1));
LineL = LineArray( x0, y0, x1, y1, 1 );
/*
Plot(C, "C", colorBlack, styleCandle);
*/
Plot( LineL, " Support Trend line", colorGreen,4 +8 );


yt0=LastValue(Peak(H,percent,firstpointH));
yt1=LastValue(Peak(Ref(H,-1),percent,1));

for(i = 1; i < BarCount AND yt0 <= yt1; i++ )
{

firstpointH++;
yt0=LastValue(Peak(H,percent,firstpointH));
}
xt0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpointH));
xt1=BarCount - 1 - LastValue(PeakBars(Ref(H,-1),percent,1));
LineH = LineArray( xt0, yt0, xt1, yt1, 1 );

Plot( LineH, "Resistance Trend line", colorRed,4 + 8 );

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++*/
}

_SECTION_END();



رد مع اقتباس
قديم 16-12-2012, 01:57 AM
  المشاركه #676

كاتب قدير

تاريخ التسجيل: Oct 2005
المشاركات: 8,424
منادي_2005 غير متواجد حالياً  

_SECTION_BEGIN("_Main_mrtq13");

Title =
EncodeColor(colorWhite)+ Title = Name () + " | "
+EncodeColor(colorYellow) + Date() + " | "

+EncodeColor(colorTurquoise)+ "O : "+ EncodeColor(colorLightGrey)+ O + " | "
+EncodeColor(colorTurquoise)+ "H : "+ EncodeColor(colorLightGrey)+ H + " | "
+EncodeColor(colorTurquoise)+ "L : "+ EncodeColor(colorLightGrey)+ L + " | "
+EncodeColor(colorTurquoise)+ "C : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ C + " | "
+EncodeColor(colorTurquoise)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" Tk."
+EncodeColor(colorTurquoise)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
+EncodeColor(colorTurquoise)+ ") | Volume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1)
;

_SECTION_END();

_SECTION_BEGIN("Haiken");

Show_color = ParamToggle("Display CandleColor", "No|Yes", 1);
r1 =Param( "ColorFast avg", 5, 2, 200, 1 );
r2 =Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 =Param( "ColorSignal avg", 5, 2, 200, 1 );

Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);

HaClose =EMA((O+H+L+C)/4,3);

HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
Temp = Max(High, HaOpen);
Temp = Min(Low,HaOpen);


m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, ColorRGB(230,230,0),IIf(m1>0 AND m1>s1,colorBrightGreen,IIf(m1>0 AND m1<s1,colorOrange,colorDarkRed)));

if(Show_color)

{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );


}

m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, ColorRGB(230,230,0),IIf(m1>0 AND m1>s1,colorWhite,IIf(m1>0 AND m1<s1,colorOrange,colorDarkRed)));
if(Show_color)

{
ColorHighliter = mycolor;
SetBarFillColor( ColorHighliter );
}

barColor=IIf(C>Green ,colorWhite,IIf(C < RED,colorRed,colorYellow));
barColor2=IIf(Close > Open, colorWhite, colorRed);




if( ParamToggle("Plot Normal Candle", "No,Yes", 1 ) )
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, " " , barcolor, styleCandle | styleThick );
else
PlotOHLC( Open, High, Low, Close, " " , barcolor2, styleCandle | styleThick );

_SECTION_END();

_SECTION_BEGIN("Breakout Setting");
Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1);
Sellperiods=Param("Exit Breakout",5,1,100,1,1);
Buy= C>Ref(HHV(High,Buyperiods),-1);
Sell= C<Ref(LLV(Low,Sellperiods),-1);

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
PlotShapes( IIf( Buy, shapeSmallCircle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -10);
PlotShapes( IIf( Sell, shapeSmallCircle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = 10);

_SECTION_END();

_SECTION_BEGIN("Pivot Box");
Hi=Param("High_Period",7,1,50,1);
Lo=Param("Low_Period",7,1,50,1);
A1=ExRemSpan(Ref(High,-2)==HHV(High,Hi),3);
A2=ExRemSpan(Ref(Low,-2)==LLV(Low,Lo),3);
A3=Cross(A1,0.9);
A4=Cross(A2,0.9);
TOP=Ref(HaHigh,-BarsSince(A3));


breakoutLine=Param("BrOutLineLength",10,2,30,0.1);
upDaysback1 = breakoutLine;
upFirstBar1 = BarCount - upDaysBack1;
upst2=TOP;

upYYY2=IIf(BarIndex() >= upFirstbar1,EndValue(upSt2),Null);

Plot(upYYY2,"",ParamColor("BreakoutColor", colorOrange) ,ParamStyle("BreakoutLine",styleLine|styleThick|styleStaircase,maskAll));

bot=Ref(HaLow,-BarsSince(A4));
breakDownLine=Param("BrDownLineLength",10,2,30,0.1 );
dnDaysback1 = breakDownLine;
dnFirstBar1 = BarCount - dnDaysBack1;
dnst2=BOT;

dnYYY2=IIf(BarIndex() >= dnFirstbar1,EndValue(dnSt2),Null);


Plot(dnYYY2,"",ParamColor("BreakDownColor", colorBrightGreen) ,ParamStyle("BreakdownLine",styleLine|styleThick|styleStaircase,maskAll));
_SECTION_END();

function T31(price,periods)
{
s=Param("Hot ?",0.618,0,100,0.001,0);
periods = 2/(periods+1);
e1=AMA(price,periods);
e2=AMA(e1,Periods);
e3=AMA(e2,Periods);
e4=AMA(e3,Periods);
e5=AMA(e4,Periods);
e6=AMA(e5,Periods);
c1=-s*s*s;
c2=3*s*s+3*s*s*s;
c3=-6*s*s-3*s-3*s*s*s;
c4=1+3*s+s*s*s+3*s*s;
Ti3=c1*e6+c2*e5+c3*e4+c4*e3;
return ti3;
}
P = ParamField("Price field");
periods = Param( "Periods", 3, 1, 100, 1 );









_SECTION_BEGIN("Price Line");

PriceLineColor=colorGrey40;
PriceLevel = ParamField("PriceField", field = 3 );

Daysback = Param("Bars Back",500,10,900,1);
FirstBar = BarCount - DaysBack;
YY = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null);

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

_SECTION_END();



_SECTION_BEGIN("Average 0");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 20, 2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;

if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods),
Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4
);
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorDarkYellow),ParamStyle("Style",styleLine |styleThick|styleDots|styleNoTitle ,maskAll),Displacement );

_SECTION_END();


_SECTION_BEGIN("Average 1");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 60, 2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;

if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods),
Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4
);
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorDarkGreen),ParamStyle("Style",styleLine |styleThick|styleDots|styleNoTitle ,maskAll),Displacement );

_SECTION_END();

_SECTION_BEGIN("Average 2");
Average_switch = ParamToggle("Candle On/off", "Off|On");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 100, 2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;

if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods),
Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4
);
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorRGB(70,70,70)),ParamStyle("Style",styleLine |styleThick|stylehidden|styleDots|styleNoTitle ,maskAll),Displacement );

_SECTION_END();


_SECTION_BEGIN("Average 5");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 120 ,2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;

if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods),
Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4
);
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorCustom13),ParamStyle("Style",styleLine |styleThick|styleDots|styleNoTitle ,maskAll),Displacement );
_SECTION_END();


_SECTION_BEGIN("Sell Average 3");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 180, 2, 800 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;

if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods),
Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4
);
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorRGB(150,150,150)),ParamStyle("Style",styleLine |styleThick|styleDots|styleNoTitle ,maskAll),Displacement );
_SECTION_END();


_SECTION_BEGIN("Average 4");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 500, 2, 800 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;

if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods),
Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4
);
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorRGB(190,190,190)),ParamStyle("Style",styleLine |styleThick|stylehidden|styleDots|styleNoTitle ,maskAll),Displacement );
_SECTION_END();




_SECTION_BEGIN("Bands_Short");
BandDays= Param("DaysBack",40,10,900,1);
HighestHigh = HHV( H, BandDays ) ;
LowestLow = LLV( L, BandDays) ;

KS = ( HHV( H, BandDays ) + LLV( L, BandDays) )/2;

Plot(HighestHigh ,"HighestHigh ",colorBlue,styleLine | styleStaircase|styleNoRescale| styleNoLabel|styleNoTitle );
Plot(LowestLow ,"LowestLow ",colorRed,styleLine | styleStaircase );
Plot(KS,"KS",colorGreen,styleLine |styleThick | styleStaircase );

Plot((KS+HighestHigh )/2,"",colorYellow, styleLine | styleThick | styleStaircase );
Plot((KS+LowestLow )/2,"",colorYellow, styleLine | styleThick | styleStaircase );



CloudUpColor1=ParamColor("ShortupColor1",ColorRGB( 0,55,55));
CloudUpColor2=ParamColor("ShortupColor2",ColorRGB( 60,15,0));
CloudDownColor1=ParamColor("ShortDnColor1",ColorRGB(0,0,83));
CloudDownColor2= ParamColor("ShortDnColor2",ColorRGB(43,43,89));

CU1=HighestHigh;
CU2=(KS+HighestHigh )/2;

CD1=LowestLow = LLV( L, 22) ;
CD2=(KS+LowestLow )/2;



PlotOHLC( CU1, CU1,CU2,CU2, "", CloudUpColor1, styleCloud || styleStaircase|styleNoRescale| styleNoLabel|styleNoTitle );
PlotOHLC( CU2, CU2,KS,KS, "", CloudUpColor2, styleCloud || styleStaircase|styleNoRescale| styleNoLabel|styleNoTitle );

PlotOHLC( KS, KS,CD2,CD2, "", CloudDownColor1, styleCloud || styleStaircase|styleNoRescale| styleNoLabel|styleNoTitle );
PlotOHLC( CD2, CD2,CD1,CD1, "", CloudDownColor2, styleCloud || styleStaircase|styleNoRescale| styleNoLabel|styleNoTitle );





_SECTION_END();

_SECTION_BEGIN("Bands_Long");

SupResB = Param("Sup-Res Short",30,0,100,1);
SupResB2 = Param("Sup-Res Short2",12,0,100,1);
SupResC=Param("Res Long",160,0,350,1);
ResL=Param("SupLong",60,0,350,1);

nn=SupResB;


nn2=SupResC;
nn3=ResL;

Hh=HHV(HaHigh,nn);
Ll=LLV(HaLow,nn);

Hh2=HHV(HaHigh,nn2);
L2=LLV(HaLow,nn3);


Plot(Hh2,"",ColorRGB(13,32,29),ParamStyle("LongRes Line",styleLine|styleStaircase|styleNoRescale |styleNoTitle|styleNoLabel|styleThick,maskAll));


Plot(L2,"",ColorRGB(12,12,52),ParamStyle("LongSupL ine",styleLine|styleStaircase|styleNoRescale |styleNoTitle|styleNoLabel|styleThick,maskAll));





_SECTION_END();

_SECTION_BEGIN("Cloud Setting Long");


ParmCloud = ParamToggle("CloudLong", "No|Yes", 1);

CloudResColor=ParamColor("CloudResColorLong",colorDarkGrey);
BrCount7=Param("CloudResLengthLong",300,1,500,1);
for (i=0;i<BarCount-BrCount7;i++)
{
CloudResColor[i] = colorBlack;
}


CS1=LLV(HaLow,nn3);
CR1=HHV(HaHigh,nn2);


if(parmCloud == 1)
{
PlotOHLC( CS1, CS1, CR1,CR1, "", CloudResColor, styleCloud |styleStaircase| styleNoLabel|styleNoRescale |styleNoTitle);
}

_SECTION_END();




_SECTION_BEGIN("Pivot");
nBars = Param("Number of bars", 25, 5, 40);
LP=Param("LookBack Period",250,1,500,1);
bShowTCZ = Param("Show TCZ", 0, 0, 1);
nExploreBarIdx = 0;
nExploreDate = 0;
nCurDateNum = 0;
DN = DateNum();
DT = DateTime();
bTCZLong = False;
bTCZShort = False;
nAnchorPivIdx = 0;
ADX8 = ADX(8);
if(Status("action")==1) {
bDraw = True;
bUseLastVis = 1;
} else {
bDraw = False;
bUseLastVis = False;
bTrace = 1;
nExploreDate = Status("rangetodate");
for (i=LastValue(BarIndex());i>=0;i--) {
nCurDateNum = DN[i];
if (nCurDateNum == nExploreDate) {
nExploreBarIdx = i;
}
}
}
GraphXSpace=7;
if (bDraw) {
}
aHPivs = H - H;
aLPivs = L - L;
aHPivHighs = H - H;
aLPivLows = L - L;
aHPivIdxs = H - H;
aLPivIdxs = L - L;
aAddedHPivs = H - H;
aAddedLPivs = L - L;
aLegVol = H - H;
aRetrcVol = H - H;
nHPivs = 0;
nLPivs = 0;
lastHPIdx = 0;
lastLPIdx = 0;
lastHPH = 0;
lastLPL = 0;
curPivBarIdx = 0;
aHHVBars = HHVBars(H, nBars);
aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);
aLLV = LLV(L, nBars);
nLastVisBar = LastValue(
Highest(IIf(Status("barvisible"), BarIndex(), 0)));
curBar = IIf(nlastVisBar > 0 AND bUseLastVis, nlastVisBar,
IIf(Status("action")==4 AND nExploreBarIdx > 0, nExploreBarIdx,
LastValue(BarIndex())));
curTrend = "";
if (aLLVBars[curBar] < aHHVBars[curBar])
curTrend = "D";
else
curTrend = "U";
if (curBar >= LP) {
for (i=0; i<LP; i++) {
curBar = IIf(nlastVisBar > 0 AND bUseLastVis,
nlastVisBar-i,
IIf(Status("action")==4 AND nExploreBarIdx > 0,
nExploreBarIdx-i,
LastValue(BarIndex())-i));
if (aLLVBars[curBar] < aHHVBars[curBar]) {
if (curTrend == "U") {
curTrend = "D";
curPivBarIdx = curBar - aLLVBars[curBar];
aLPivs[curPivBarIdx] = 1;
aLPivLows[nLPivs] = L[curPivBarIdx];
aLPivIdxs[nLPivs] = curPivBarIdx;
nLPivs++;
}
} else {
if (curTrend == "D") {
curTrend = "U";
curPivBarIdx = curBar - aHHVBars[curBar];
aHPivs[curPivBarIdx] = 1;
aHPivHighs[nHPivs] = H[curPivBarIdx];
aHPivIdxs[nHPivs] = curPivBarIdx;
nHPivs++;
}
}
}
}
curBar =
IIf(nlastVisBar > 0 AND bUseLastVis,
nlastVisBar,
IIf(Status("action")==4 AND nExploreBarIdx > 0,
nExploreBarIdx,
LastValue(BarIndex()))
);
if (nHPivs >= 2 AND nLPivs >= 2) {
lastLPIdx = aLPivIdxs[0];
lastLPL = aLPivLows[0];
lastHPIdx = aHPivIdxs[0];
lastHPH = aHPivHighs[0];
nLastHOrLPivIdx = Max(lastLPIdx, lastHPIdx);
nAddPivsRng = curBar - nLastHOrLPivIdx;
aLLVAfterLastPiv = LLV(L, nAddPivsRng);
nLLVAfterLastPiv = aLLVAfterLastPiv[curBar];
aLLVIdxAfterLastPiv = LLVBars(L, nAddPivsRng);
nLLVIdxAfterLastPiv = curBar - aLLVIdxAfterLastPiv[curBar];
aHHVAfterLastPiv = HHV(H, nAddPivsRng);
nHHVAfterLastPiv = aHHVAfterLastPiv[curBar];
aHHVIdxAfterLastPiv = HHVBars(H, nAddPivsRng);
nHHVIdxAfterLastPiv = curBar - aHHVIdxAfterLastPiv[curBar];
if (lastHPIdx > lastLPIdx) {
if (aHPivHighs[0] < aHPivHighs[1]) {

if (nLLVAfterLastPiv < aLPivLows[0] AND
(nLLVIdxAfterLastPiv - lastHPIdx - 1) >= 1
AND nLLVIdxAfterLastPiv != curBar ) {

aLPivs[nLLVIdxAfterLastPiv] = 1;
aAddedLPivs[nLLVIdxAfterLastPiv] = 1;

for (j=0; j<nLPivs; j++) {
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
}
aLPivLows[0] = nLLVAfterLastPiv;
aLPivIdxs[0] = nLLVIdxAfterLastPiv;
nLPivs++;

}

} else {

if (nLLVAfterLastPiv > aLPivLows[0] AND
(nLLVIdxAfterLastPiv - lastHPIdx - 1) >= 1
AND nLLVIdxAfterLastPiv != curBar ) {

aLPivs[nLLVIdxAfterLastPiv] = 1;
aAddedLPivs[nLLVIdxAfterLastPiv] = 1;

for (j=0; j<nLPivs; j++) {
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
}
aLPivLows[0] = nLLVAfterLastPiv;
aLPivIdxs[0] = nLLVIdxAfterLastPiv;
nLPivs++;

}
}

} else {

if (aHPivHighs[0] < aHPivHighs[1]) {

if (nHHVAfterLastPiv < aHPivHighs[0] AND
(nHHVIdxAfterLastPiv - lastLPIdx - 1) >= 1
AND nHHVIdxAfterLastPiv != curBar ) {

aHPivs[nHHVIdxAfterLastPiv] = 1;
aAddedHPivs[nHHVIdxAfterLastPiv] = 1;

for (j=0; j<nHPivs; j++) {
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nhPivs-(j+1)];
}
aHPivHighs[0] = nHHVAfterLastPiv;
aHPivIdxs[0] = nHHVIdxAfterLastPiv;
nHPivs++;
}
} else {

if (nHHVAfterLastPiv > aHPivHighs[0] AND
(nHHVIdxAfterLastPiv - lastLPIdx - 1) >= 1
AND nHHVIdxAfterLastPiv != curBar ) {
aHPivs[nHHVIdxAfterLastPiv] = 1;
aAddedHPivs[nHHVIdxAfterLastPiv] = 1;
for (j=0; j<nHPivs; j++) {
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nhPivs-(j+1)];
}
aHPivHighs[0] = nHHVAfterLastPiv;
aHPivIdxs[0] = nHHVIdxAfterLastPiv;
nHPivs++;
}

}

}
}

if (bDraw) {
PlotShapes( IIf(aHPivs==1, shapeHollowSmallSquare, shapeNone), colorRed, layer = 0, yposition = HaHigh, offset = 10);
PlotShapes( IIf(aHPivs==1, shapeSmallCircle, shapeNone), colorRed, layer = 0, yposition = HaHigh, offset = 10);



PlotShapes( IIf(aAddedLPivs==1, shapeHollowSmallSquare, shapeNone), colorYellow, layer = 0, yposition = HaLow, offset = -10);
PlotShapes( IIf(aAddedLPivs==1, shapeSquare, shapeNone), colorBlack, layer = 0, yposition = HaLow, offset = -14);


PlotShapes( IIf(aAddedLPivs==1, shapeSmallCircle, shapeNone), colorYellow, layer = 0, yposition = HaLow, offset = -9);


PlotShapes( IIf(aHPivs==1, shapeSmallCircle, shapeNone), colorCustom12, layer = 0, yposition = HaHigh, offset = 9);
PlotShapes( IIf(aHPivs==1, shapeHollowSmallSquare, shapeNone), colorCustom12, layer = 0, yposition = HaHigh, offset = 12);

PlotShapes( IIf(aAddedHPivs==1, shapeSmallCircle, shapeNone), colorCustom10,layer = 0, yposition = HaHigh, offset = 9);
PlotShapes( IIf(aAddedHPivs==1, shapeHollowSmallSquare, shapeNone), colorYellow, layer = 0, yposition = HaHigh, offset = 12);

PlotShapes( IIf(aLPivs==1, shapeSmallCircle, shapeNone), colorPaleGreen, layer = 0, yposition = HaLow, offset = -9);
PlotShapes( IIf(aLPivs==1, shapeHollowSmallSquare, shapeNone), colorGreen, layer = 0, yposition = HaLow, offset = -12);

PlotShapes( IIf(aAddedLPivs==1, shapeSmallCircle, shapeNone), colorYellow, layer = 0, yposition = HaLow, offset = -10);
PlotShapes( IIf(aAddedLPivs==1, shapeHollowSmallSquare, shapeNone), colorYellow, layer = 0, yposition = HaLow, offset = -13);

}



risk = 0;
profInc = 0;
nLeg0Pts = 0;
nLeg0Bars = 0;
nLeg0Vol = 0;
nLeg1Pts = 0;
nLeg1Bars = 0;
nLeg1Vol = 0;
nLegBarsDiff = 0;
nRtrc0Pts = 0;
nRtrc0Bars = 0;
nRtrc0Vol = 0;
nRtrc1Pts = 0;
nRtrc1Bars = 0;
nRtrc1Vol = 0;

minRtrc = 0;
maxRtrc = 0;
minLine = 0;
maxLine = 0;
triggerLine = 0;
firstProfitLine = 0;
triggerInc = 0;
triggerPrc = 0;
firstProfitPrc = 0;
retrcPrc = 0;
retrcBar = 0;
retrcBarIdx = 0;
retrcRng = 0;
aRetrcPrc = H-H;
aRetrcPrcBars = H-H;
aRetrcClose = C;
retrcClose = 0;
if (nHPivs >= 2 AND
nLPivs >=2 AND
aHPivHighs[0] > aHPivHighs[1] AND
aLPivLows[0] > aLPivLows[1]) {

tcz500 =
(aHPivHighs[0] -
(.5 * (aHPivHighs[0] - aLPivLows[1])));

tcz618 =
(aHPivHighs[0] -
(.618 * (aHPivHighs[0] - aLPivLows[1])));

tcz786 =
(aHPivHighs[0] -
(.786 * (aHPivHighs[0] - aLPivLows[0])));

retrcRng = curBar - aHPivIdxs[0];
aRetrcPrc = LLV(L, retrcRng);
aRetrcPrcBars = LLVBars(L, retrcRng);

retrcPrc = aRetrcPrc[curBar];
retrcBarIdx = curBar - aRetrcPrcBars[curBar];
retrcClose = aRetrcClose[retrcBarIdx];
bTCZLong = (

tcz500 >= (tcz786 * (1 - .005))
AND
tcz618 <= (tcz786 * (1 + .005))
AND

retrcClose >= ((1 - .01) * tcz618)
AND
retrcPrc <= ((1 + .01) * tcz500)
);
} else if (nHPivs >= 2 AND nLPivs >=2
AND aHPivHighs[0] < aHPivHighs[1]
AND aLPivLows[0] < aLPivLows[1]) {

tcz500 =
(aHPivHighs[1] -
(.5 * (aHPivHighs[1] - aLPivLows[0])));

tcz618 =
(aHPivHighs[0] -
(.618 * (aHPivHighs[1] - aLPivLows[0])));

tcz786 =
(aHPivHighs[0] -
(.786 * (aHPivHighs[0] - aLPivLows[0])));

retrcRng = curBar - aLPivIdxs[0];
aRetrcPrc = HHV(H, retrcRng);
retrcPrc = aRetrcPrc[curBar];
aRetrcPrcBars = HHVBars(H, retrcRng);
retrcBarIdx = curBar - aRetrcPrcBars[curBar];
retrcClose = aRetrcClose[retrcBarIdx];

bTCZShort = (
tcz500 <= (tcz786 * (1 + .005))
AND
tcz618 >= (tcz786 * (1 - .005))
AND
retrcClose <= ((1 + .01) * tcz618)
AND
retrcPrc >= ((1 - .01) * tcz500)
);
}
if (bTCZShort OR bTCZLong) {
if (bTCZShort) {
if (aLPivIdxs[0] > aHPivIdxs[0]) {
nRtrc0Pts = aHPivHighs[0] - aLPivLows[1];
nRtrc0Bars = aHPivIdxs[0] - aLPivIdxs[1] + 1;
nRtrc1Pts = retrcPrc - aLPivLows[0];
nRtrc1Bars = retrcBarIdx - aLPivIdxs[0] + 1;
} else {
nRtrc0Pts = aHPivHighs[1] - aLPivLows[1];
nRtrc0Bars = aHPivIdxs[1] - aLPivIdxs[1] + 1;
nRtrc1Pts = aHPivHighs[0] - aLPivLows[0];
nRtrc1Bars = aHPivIdxs[0] - aLPivIdxs[0] + 1;
}
} else {
if (aLPivIdxs[0] > aHPivIdxs[0]) {
nRtrc0Pts = aHPivHighs[0] - aLPivLows[1];
nRtrc0Bars = aHPivIdxs[0] - aLPivIdxs[1] + 1;
nRtrc1Pts = retrcPrc - aLPivLows[0];
nRtrc1Bars = retrcBarIdx - aLPivIdxs[0] + 1;
} else {
nRtrc0Pts = aHPivHighs[1] - aLPivLows[0];
nRtrc0Bars = aLPivIdxs[0] - aHPivIdxs[1] + 1;
nRtrc1Pts = aHPivHighs[0] - aLPivLows[0];
nRtrc1Bars = aLPivIdxs[0] - aHPivIdxs[0] + 1;
}
}

if (bShowTCZ) {
Plot(
LineArray( IIf(bTCZLong, aHPivIdxs[0], aLPivIdxs[0]),
tcz500, curBar, tcz500 , 0),
"tcz500", colorPaleBlue, styleLine);
Plot(
LineArray( IIf(bTCZLong, aHPivIdxs[0], aLPivIdxs[0]),
tcz618, curBar, tcz618, 0),
"tcz618", colorPaleBlue, styleLine);
Plot(
LineArray( IIf(bTCZLong, aHPivIdxs[0], aLPivIdxs[0]),
tcz786, curBar, tcz786, 0),
"tcz786", colorTurquoise, styleLine);
}
}

_SECTION_END();
flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);
_SECTION_BEGIN("Weekly_trend");

Prd1=Param("Weekly_Period1",4,1,200,1);
Prd2= Param("Weekly_Period2",5,1,200,1);

TimeFrameSet (inWeekly);

TM = T31 ( Close , Prd1 ) ;
TM2 = T31 ( Close , Prd2 ) ;
TimeFrameRestore();
BullishRevers=Close>TM AND Close<TM2;
Bullish=Close>TM AND Close>TM2;
BearishRevers=Close<TM AND Close>TM2;
Bearish=Close<TM AND Close<TM2;

Type1 = WriteIf( BullishRevers,"bullishrevers", "");
Type2 = WriteIf( Bullish,"bullish", "");
Type3 = WriteIf( BearishRevers,"bearishrevers", "");
Type4 = WriteIf( Bearish,"bearish", "");


RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( Type1 =="bullishrevers")
{
GfxSelectSolidBrush( colorYellow );

}
else

if ( Type2 =="bullish")

{
GfxSelectSolidBrush( ColorRGB(0,50,0));

}

else

if ( Type3 =="bearishrevers")

{
GfxSelectSolidBrush( colorGrey40 );

}

else

if ( Type4 =="bearish")

{
GfxSelectSolidBrush( ColorRGB(50,0,0));

}



GfxSelectPen( colorTeal,2 );


GfxCircle( 70,90,60 );
_SECTION_END();


_SECTION_BEGIN("trending ribbon");

BT=ParamColor("BT", colorRed );

TimeFrameSet (inDaily);
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();
UTM3=IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLightGrey ));

TimeFrameRestore();

UpA=uptrend;
DownB=downtrend;


Trend1 = WriteIf( UpA,"Up1", "");
Trend2 = WriteIf( DownB,"Down1", "");


RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( Trend1 =="Up1")
{
GfxSelectSolidBrush( ColorRGB(0,70,0) );

}
else

if ( Trend2 =="Down1")

{
GfxSelectSolidBrush( ColorRGB(70,0,0));

}
else

if ( Trend2 =="")

{
GfxSelectSolidBrush( colorPaleBlue );

}


GfxSelectPen( colorBlack, 0 );
GfxCircle( 70,90,54 );
_SECTION_END();


_SECTION_BEGIN("Trendslong");

CT=ParamColor("CT", colorRed );

UpTrendCond3 = Cross ( T31( flowerclose, 7), T31( flowerclose, 9) );
dnTrendCond3 = Cross ( T31( flowerclose, 9),T31( flowerclose, 7) );


upt3= T31( flowerclose, 7)> T31( flowerclose, 9) ;
dnTrend3 = T31( flowerclose, 9)>T31( flowerclose, 7) ;

Trendslongup= WriteIf(upt3,"trendlongup", "");
Trendslongdown= WriteIf( dnTrend3,"trendlongdn", "");
Trendslongcon= WriteIf( UpTrendCond3,"trendlongcon", "");

if ( Trendslongup =="trendlongup")
{
GfxSelectSolidBrush(ColorRGB(0,90,0) );

}
else

if (Trendslongdown =="trendlongdn")

{
GfxSelectSolidBrush( ColorRGB(90,0,0));

}

else

if (Trendslongdown =="")

{
GfxSelectSolidBrush( colorYellow );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlack );

GfxSelectPen( colorBlack, 1 );
GfxCircle( 70,90,48 );




_SECTION_END();


_SECTION_BEGIN("Trendsmid");

DT=ParamColor("DT", colorRed );

UpTrendCond2 = Cross ( T31( flowerclose, 5), T31( flowerclose, 7) );
dnTrendCond2 = Cross (T31( flowerclose, 7), T31( flowerclose, 5) );
upt2= T31( flowerclose, 5)> T31( flowerclose, 7) ;
dnTrend2 = T31( flowerclose, 7)>T31( flowerclose, 5) ;



Trendmidup= WriteIf(upt2,"trendmidup", "");
Trendmiddown= WriteIf( dnTrend2,"trendmiddn", "");
Trendmidcon= WriteIf( UpTrendCond2,"trendmidcon", "");

if ( Trendmidup =="trendmidup")
{
GfxSelectSolidBrush( ColorRGB(0,120,0) );

}
else

if (Trendmiddown =="trendmiddn")

{
GfxSelectSolidBrush( ColorRGB(120,0,0));

}

else

if (Trendmidcon =="trendmidcon")

{
GfxSelectSolidBrush( colorYellow );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlack );

GfxSelectPen( colorBlack, 1 );
GfxCircle( 70,90,42 );

_SECTION_END();

_SECTION_BEGIN("Trendsshort");

ET=ParamColor("ET", colorRed );

UpTrendCond1 = Cross( flowerClose, T31( flowerClose, 5 ) );
dnTrendCond1 = Cross( T31( flowerClose, 5 ),flowerClose );
upt1=flowerClose > T31( flowerClose, 5 ) ;
dnTrend1 = flowerClose< T31( flowerClose, 5 );



Trendshortup= WriteIf(upt1,"trendup", "");
Trendshortdown= WriteIf( dnTrend1,"trenddn", "");
Trendshortcon= WriteIf( UpTrendCond1,"trendcon", "");

if ( Trendshortup =="trendup")
{
GfxSelectSolidBrush( ColorRGB(0,150,0) );

}
else

if (Trendshortdown =="trenddn")

{
GfxSelectSolidBrush( ColorRGB(150,0,0));

}

else

if (Trendshortcon =="trendcon")

{
GfxSelectSolidBrush( colorYellow );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlack );

GfxSelectPen( colorBlack, 1 );
GfxCircle( 70,90,36 );




_SECTION_END();



_SECTION_BEGIN("Rays");

FT=ParamColor("FT", colorRed );

Pp1=3;
Pp2=2;

CS33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),4);
CR33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),5);

AtrupTrendCond1 = flowerClose> CS33 ;
AtrdnTrendCond1 =CS33>flowerClose ;


ATRup = WriteIf(AtrupTrendCond1,"atrup", "");
ATRdown= WriteIf( AtrdnTrendCond1,"atrdn", "");

if ( ATRup =="atrup")
{
GfxSelectSolidBrush( ColorRGB(0,180,0) );

}
else

if (ATRdown =="atrdn")

{
GfxSelectSolidBrush( ColorRGB(180,0,0));

}

else

if ( ATRdown =="")

{
GfxSelectSolidBrush( colorGrey40 );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlack );

GfxSelectPen( colorBlack, 1 );
GfxCircle( 70,90,30 );

_SECTION_END();


_SECTION_BEGIN("Exit_Beast-3");

GT=ParamColor("GT", colorRed );

EntrylookbackPeriod=10;
EntryATRperiod=1.9;
EntrySig = C > ( LLV( flowerLow, EntrylookbackPeriod ) + EntryATRperiod * ATR( 10 ) );
ExitSig = C < ( HHV( flowerHigh, EntrylookbackPeriod ) -EntryATRperiod * ATR( 10 ) );


RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

EntryB = WriteIf( EntrySig,"eu", "");
ExitB = WriteIf( ExitSig,"ed", "");

if ( EntryB =="eu")
{
GfxSelectSolidBrush( ColorRGB(0,210,0) );

}
else

if ( ExitB =="ed")

{
GfxSelectSolidBrush( ColorRGB(210,0,0));

}

else

if ( ExitB =="")

{
GfxSelectSolidBrush( colorGrey40 );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlack );

GfxSelectPen( colorBlack, 1 );
GfxCircle( 70,90,24 );

_SECTION_END();



_SECTION_BEGIN("CCI9-2");

HT=ParamColor("HT", colorRed );

ccidn=CCI(8) < 0;
cciup=CCI(9) > 0;


ccresult1 = WriteIf( cciup,"cu", "");
ccresult2 = WriteIf( ccidn,"cd", "");




RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( ccresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,240,0) );

}
else

if ( ccresult2 =="cd")

{
GfxSelectSolidBrush( ColorRGB(240,0,0));

}

else

if ( ccresult2 =="")

{
GfxSelectSolidBrush( colorGrey40 );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlack );

GfxSelectPen( colorBlack, 1 );
GfxCircle( 70,90,18 );




_SECTION_END();




_SECTION_BEGIN("%BB7-1");

IT=ParamColor("IT", colorRed );
p=7;
x=((C+2*StDev(C,p)-MA(C,p))/(4*StDev(C,p)))*100;
bbdown= x < 40;
bbup= x > 40;

bbresult1 = WriteIf( bbup,"bu", "");
bbresult2 = WriteIf( bbdown,"bd", "");
bbresult3 = WriteIf( C,"bearishrevers", "");



RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( bbresult1 =="bu")
{
GfxSelectSolidBrush( ColorRGB(62,255,62) );

}
else

if ( bbresult2 =="bd")

{
GfxSelectSolidBrush( ColorRGB(255,62,62) );

}

else

if ( bbresult2 =="")

{
GfxSelectSolidBrush( colorGrey40 );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlack );

GfxSelectPen( colorBlack, 1 );
GfxCircle( 70,90,12 );


_SECTION_END();


_SECTION_BEGIN("Fast_trend");
JT=ParamColor("JT", colorRed );

Prd3=Param("Daily_Period1",8,1,200,1);
Prd4=Param("Daily_Period2",15,1,200,1);
TimeFrameSet (inDaily);


TM3 = T31 ( C , Prd3) ;
TM4 = T31 ( C , Prd4) ;

TimeFrameRestore();

A=C>TM3 AND C<TM4;
B=C>TM3 AND C>TM4;
C=C<TM3 AND C>TM4;
D=C<TM3 AND C<TM4;

result1 = WriteIf( A,"bullrevers", "");
result2 = WriteIf( B,"bull", "");
result3 = WriteIf( C,"bearishrevers", "");
result4 = WriteIf( D,"bear", "");


RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( result1 =="bullrevers")
{
GfxSelectSolidBrush( colorWhite );

}
else

if ( result2 =="bull")

{
GfxSelectSolidBrush( ColorRGB(113,255,113) );

}

else

if ( result3 =="bearishrevers")

{
GfxSelectSolidBrush( colorGrey40 );

}

else

if ( result4 =="bear")

{
GfxSelectSolidBrush( ColorRGB(255,113,113) );
OP = "M";

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlack );

GfxSelectPen( colorBlack,1);
GfxCircle( 70,90,6 );

//GfxTextOut( OP,92,235) ;

_SECTION_END();



رد مع اقتباس
قديم 16-12-2012, 02:02 AM
  المشاركه #677

كاتب قدير

تاريخ التسجيل: Oct 2005
المشاركات: 8,424
منادي_2005 غير متواجد حالياً  

صــــــــــــــــــــــــورة لآخر أربع مؤشـــــــــــرات

أتمنـــــــــــــــــــى الفائدة للجميــــــــــــــــــــع


رد: مواضيع مدمجة عن معادلات الأمي بروكر



رد مع اقتباس
قديم 17-12-2012, 02:07 PM
  المشاركه #678

عضو هوامير المميز

تاريخ التسجيل: Dec 2011
المشاركات: 310
haat غير متواجد حالياً  

بارك الله فيك بو محمد

المعادلة الاولى والاخيرة شغالين

لكن الثانية والثالثه بهم مشاكل



رد مع اقتباس
قديم 17-12-2012, 04:02 PM
  المشاركه #679

عضو هوامير المؤسس

تاريخ التسجيل: Aug 2005
المشاركات: 1,834
غنيمة غير متواجد حالياً  

بارك الله فيك المعادلات لاتعمل


رد مع اقتباس
قديم 19-12-2012, 08:58 AM
  المشاركه #680

عضو هوامير المؤسس

تاريخ التسجيل: Jul 2005
المشاركات: 1,307
أسعار غير متواجد حالياً  

جزاك الله خير والله يبارك فيك


رد مع اقتباس
قديم 05-01-2013, 07:49 PM
  المشاركه #681

كاتب قدير

تاريخ التسجيل: Oct 2005
المشاركات: 8,424
منادي_2005 غير متواجد حالياً  

وبارك فيكم


رد مع اقتباس
قديم 05-01-2013, 08:22 PM
  المشاركه #682

كاتب قدير

تاريخ التسجيل: Oct 2005
المشاركات: 8,424
منادي_2005 غير متواجد حالياً  

أتمنــــــــــــــــــــــــــى من الأخوان عند نقل أي معادلة لمنتدى آخر عدم نسب المجهود لنفســـه

سواء في هذه المعادلات أو معادلات أخرى وخاصة من الأخوان الذين لا يشاركـــــــــون

وهدفنــــــــــا هنا بهذا المنتدى الفائدة للجميع وبأمكاننا فعل ما يفعله الآخرون بشأن المخفـــي

ولكن ليس هذا من طبعنا بالمنتدى لأنه قائم منذ أنشائه على الوضوح

وهدفه أكتساب المعرفة وتبادل الخبرات

ودمتـــــــــــــــــــــــــــــــــم

أخوكم أبو محمد



رد مع اقتباس
قديم 16-01-2013, 10:24 PM
  المشاركه #683

عضو هوامير المميز

تاريخ التسجيل: Mar 2012
المشاركات: 133
ebrm5664 غير متواجد حالياً  

ابداع ماشاء الله

لو تكرمت ابومحمد عندي معادله احتاج لها محرك بحث

//Volume Cum
//----------------------------------------------------------
// cumulate the volume for each swing

// by reinsley
// Following the S&C "Price+Volume=Price movement by Tom ORD
// S&C's document is stored in Yahoo! files
// Mod of the Pivots And Prices formula
//----------------------------------------------------------


_SECTION_BEGIN( "Price" );
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} \nOpen %g \nHigh %g
\nLow %g \nClose %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )
) ) );
Plot( C, "", colorBlack , styleCandle );
_SECTION_END();

_SECTION_BEGIN( "pivot" );
price = ParamToggle( "Plot Price", "Off|On", 1 );
num = Param( "trend", 4, 1, 10, 1 );
dist = 0.5 * ATR( 10 );
rightfig = Param( "rightfig ", 7, 1, 10, 1 );
xspace = Param( "GraphXSpace ", 10, 1, 20, 1 );

mHHV = HHV( H, num );
mLLV = LLV( L, num );

FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );

for ( b = Firstvisiblebar + num; b <= Lastvisiblebar AND b < BarCount - num;
b++ )
{
i = num;
ml = 0;
mu = 0;

while ( i > 0 )
{

if ( L[b] < L[b+i] )
{
ml++;
}


if ( H[b] > H[b+i] )
{
mu++;
}

i--;
}


if ( ml == num AND L[B] == mLLV[B] )
{
PlotText( "\n *\n", b, L[b], colorGreen );

if ( price == 1 )
{
p = StrRight( NumToStr( L[b], 4.1 ), rightfig );
PlotText( "\n\n" + p, b - 2 , L[b] , colorGreen );
}
}


if ( mu == num AND H[B] == mHHV[B] )
{
PlotText( " *\n", b, H[b], colorRed );

if ( price == 1 )
{
p = StrRight( NumToStr( H[b], 4.1 ), rightfig );
PlotText( p , b - 2 , H[b] + dist[b] + 1, colorRed );
}
}
}

_SECTION_END();

// Vertical Daily Segment
segments = IIf( Interval() < inDaily, Day(), Month() );
segments = segments != Ref( segments , -1 );
Plot( segments, "", colorDarkBlue, styleHistogram | styleOwnScale | styleDashed
| styleNoLabel );

/*
Volbar = TimeFrameGetPrice( "V", in1Minute * 20, 0 );
_TRACE( "Volbar = " + Volbar );
*/
// Seconds Remaining

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();
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;

Secsleft = SecsToGo % 60 ;
Minleft = int( SecsToGo / 60 );

//Title = Title +"\n\\c07Min " + Minleft + "\n\\c05Secs " + Secsleft ;
Title = Title + "\n\\c07 " + Minleft + "\\c07 : " + "\\c07 " + Secsleft ;

// Zig-Hi-Zag-Lo formula
VolON = ParamToggle( "Plot Volume", "Off|On", 1 );
ZigON = ParamToggle( "Plot Zig", "Off|On", 1 );
pr = Param( "ZigZag change amount", 0.3, 0.05, 20, 0.05 );

pk = PeakBars( H, pr ) == 0;
tr = TroughBars( L, pr ) == 0;

zzHi = Zig( H, pr );
zzLo = Zig( L, pr );
Avg = ( zzHi + zzLo ) / 2;

x = IIf( pk, zzHi, IIf( tr, zzLo, IIf( Avg > Ref( Avg, -1 ), H, L ) ) );
zzHiLo = Zig( x, pr );

zzup = zzHiLo > Ref( zzHiLo, -1 ) ;
zzdn = zzHiLo < Ref( zzHiLo, -1 );
ribboncol = IIf( zzup , colorWhite, colorBlack );
// Plot the Zig ribbon
Plot ( 1, "", ribboncol, styleArea | styleOwnScale | styleNoLabel, 0, 100 );

if ( ZigON == 1 )
Plot( zzHiLo, "", ribboncol , styleNoLabel );

//Swing Volume
Volswing = Sum( V, BarsSince( zzup != Ref( zzup, -1 ) ) + 1 );
SwingBar = BarsSince( zzHiLo != Ref( zzHiLo, -1 ) );

// plot Volume at 5% from bottom's pane
percent = Param( "PositTextVol%", 5, 2, 90, 0.5 );
xshift = Param( "xshift %", 4, 1, 90, 0.5 );
yshift = Param( "yshift %", 3, 1, 90, 0.5 );
Miny = Status( "axisminy" );
Maxy = Status( "axismaxy" );
y = Miny + ( Maxy - Miny ) * percent / 100; // at 5 % above bottom of the
paneFirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );

for ( i = Firstvisiblebar + 1; i <= Lastvisiblebar AND i < BarCount - 1; i++ )
{
if ( zzup [i] AND zzup [ i+1] == 0 )
{
if ( VolON == 1 )
{
PlotText( "" + Volswing [ i] , i - xshift , H[i] + yshift ,
colorWhite );
}
}

if ( zzup [i] == 0 AND zzup [ i+1] == 1 )
{
if ( VolON == 1 )
{
PlotText( "" + Volswing [ i] , i - xshift , L[i] - yshift ,
colorBlack );
}
}
}

if ( VolON == 1 )
{
PlotText( "" + Volswing , i + 2 , zzHiLo[BarCount-1], LastValue( ribboncol
) );
}

GraphXSpace = xspace;

والف شكر مقدماً



رد مع اقتباس
قديم 23-03-2013, 07:03 PM
  المشاركه #684

محلل فني
ابو تركي

تاريخ التسجيل: Jul 2006
المشاركات: 1,431
jazli غير متواجد حالياً  

ابدااع ماشاء الله لاقوة الابالله
بارك الله جهدك ووفقك أخي ابومحمد



رد مع اقتباس
إضافة رد


الكلمات الدلالية (Tags)
لعشاق, مواضيع, مجوعة, مدمجة, معادلات, الأمي, المعادلات, الخاصة, بالعضو, بروكر, تستاهلون, خير, ksa, lord, كبيرة, عن


تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة

الانتقال السريع



09:26 AM