إضافة رد
أدوات الموضوع
قديم 08-04-2014, 12:18 PM
  المشاركه #13

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

تاريخ التسجيل: Jul 2006
المشاركات: 242
mmnnss غير متواجد حالياً  

ماشاء الله لاقوة الا بالله اخونا ومشرفنا الغالي منادي _2005 ...
أكرم به وأنعم أبشروا بالخير تداخل معنا محترفوا الصنعة فمرحبا ألف بهم جميعا ...
والحقيقة توقيت أكثر من رائع في المؤشر وهذا هو المطلوب ....
فإن كان الأمر لا حرج فيه .. فتكرم بمعادلته على إخوتك ...
وإن كان خاصاً فهذا من حقك وندعو لك بكل خير ..

أخوك الصغير أبويوسف ،،



رد مع اقتباس
 
 

قديم 08-04-2014, 12:35 PM
  المشاركه #14

كاتب قدير

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

اقتباس:
المشاركة الأصلية كتبت بواسطة mmnnss مشاهدة المشاركة
ماشاء الله لاقوة الا بالله اخونا ومشرفنا الغالي منادي _2005 ...
أكرم به وأنعم أبشروا بالخير تداخل معنا محترفوا الصنعة فمرحبا ألف بهم جميعا ...
والحقيقة توقيت أكثر من رائع في المؤشر وهذا هو المطلوب ....
فإن كان الأمر لا حرج فيه .. فتكرم بمعادلته على إخوتك ...
وإن كان خاصاً فهذا من حقك وندعو لك بكل خير ..

أخوك الصغير أبويوسف ،،
تحياتي لك وأنا شخصيــــــــــــا لا يوجد لدي خاص

تفضــــــــــــــــل

/* /// DEVELOPING BY ::KESARIINVESTMENT.COM::

// We DEVELOPING AMIBROKER AFL plugin DLL SOFTER LOING SYSTEM FOR SERVER

// CONTACT US ::KESARIINVESTMENT.COM:: OR (تم حذف الإيميل لأن عرضه مخالف لشروط المنتدى) OR
// (تم حذف الإيميل لأن عرضه مخالف لشروط المنتدى)
*/
_SECTION_BEGIN("Stochastic Slow");
if( Status("action") == actionCommentary )
{ printf("(ation is not available yet)");}
uptrend= IIf( StochK(15,3) > StochD(17,3,3), 1, 0 );
downtrend=IIf( StochK(15,3)<StochD(17,3,3), 1, 0 );
crossBuy=Cross(StochK(15,9),StochD(15,3,3));
crossSell=Cross(StochD(15,5,3),StochK(15,3));
kks=StochK( 15 , 3);kkd=StochD( 15 ,3, 3 );kksup=( 50 > kks) AND ( 50 > kkd);kksdw=( 50 < kks) AND ( 50 < kkd);
_SECTION_END();
_SECTION_BEGIN("KESARIINVESTMENT.COM");
SetChartBkGradientFill( ParamColor("BgTop", colorGrey40),ParamColor("BgBottom", colorGrey40));
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartOptions(0,0,chartGrid20 |chartGrid50 |chartGrid80);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} < open %g > < high %g > < low %g > < close %g > (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
Periods = Param("Periods", 11, 1, 300, 1 );
HM=EMA( High , Periods );LM=EMA( Low ,Periods );CM=C;
Buy = Cross(CM,HM) AND kksup ;
Sell = Cross( LM,CM) AND kksdw ;
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorBlue, 0,L, Offset=-27);

PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorRed, 0,H, Offset=-27);

GraphXSpace = 15;
dist = 1.1*ATR(54);

for( i = 0; i < BarCount; i++ )
{
if( Buy[i] ) PlotText( " Buy\n " + C[ i ], i, L[ i ]-dist[i], colorDarkGreen );
if( Sell[i] ) PlotText( " Sell\n " + C[ i ], i, H[ i ]+dist[i], colorRed );
}
Filter= Buy OR Sell;
GfxSelectFont( "Arial", 10, 700, False );
GfxSetTextAlign(0);
GfxTextOut( ": : WWW.KESARIINVESTMENT.COM : :", 550, 30);
GfxTextOut( ": : (تم حذف الإيميل لأن عرضه مخالف لشروط المنتدى) : :", 550, 46);
_SECTION_END();



رد مع اقتباس
قديم 08-04-2014, 02:19 PM
  المشاركه #15

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

تاريخ التسجيل: Jul 2006
المشاركات: 242
mmnnss غير متواجد حالياً  

شكر المحسن من محاسن الأخلاق
رد: حاول معي الوصول الى افضل المؤشرات التى اعطت الايجابية للنقل الجماعي يوم الخميس !!

وإن مكافأة المحسن خلق فطري ينشأ من خلق الوفاء؛ إذ أن القلوب مجبولة على حب من أحسن إليها. والمؤمن المستقيم لا يكون شاكراً لله حتى يكون معترفاً بالفضل لأهل الفضل، وفي ذلك يقول النبي صلى الله عليه وسلم: " لا يشكر الله من لا يشكر الناس". ( صحيح سنن أبي داود

رد: حاول معي الوصول الى افضل المؤشرات التى اعطت الايجابية للنقل الجماعي يوم الخميس !!

والدعاء جزاء كما في الحديث "من أسدى إليكم معروفاً فكافئوه، فإن لم تجدوا ما تكافئونه به فادعوا له حتى تعلموا أن قد كافأتموه" . وكانت عائشة إذا أرسلت إلى قومٍ بصدقة تقول للرسول : اسمع ما يدعون به لنا ، حتى ندعو لهم بمثل ما دعوا لنا ويبقى أجرنا على الله.


رد: حاول معي الوصول الى افضل المؤشرات التى اعطت الايجابية للنقل الجماعي يوم الخميس !!



رد مع اقتباس
قديم 08-04-2014, 06:42 PM
  المشاركه #16

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

تاريخ التسجيل: Jun 2005
المشاركات: 305
جهني غير متواجد حالياً  

اقتباس:
المشاركة الأصلية كتبت بواسطة amm1430 مشاهدة المشاركة
رد: حاول معي الوصول الى افضل المؤشرات التى اعطت الايجابية للنقل الجماعي يوم الخميس !!
ممكن المعادلة
وشكرا



رد مع اقتباس
قديم 08-04-2014, 11:43 PM
  المشاركه #17

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

تاريخ التسجيل: Apr 2012
المشاركات: 223
amm1430 غير متواجد حالياً  

_SECTION_BEGIN("MC");
Mothc=Ref(H,-1)>H AND Ref(L,-1)<L;
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(L,-1))));
TDL = LineArray(0, y0, (BarCount-1), y0);
Plot(TDL, "", colorBrightGreen,styleDashed|styleNoLabel);
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(H,-1))));
TDH= LineArray(0, y0, (BarCount-1), y0);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,H,5);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,L,-5);
Plot(TDH, "", colorRed,styleDashed|styleNoLabel);
Buy=Cross(C,TDH);
Sell=Cross(TDL,C);

numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("Text Shift", -50,-100,100,10);
PlotText("" + WriteVal(TDH,fraction),
SelectedValue(BarIndex()+0.5)-(numbars/hts),SelectedValue(TDH),colorRed);
PlotText("" + WriteVal(TDL,fraction),
SelectedValue(BarIndex()+0.5)-(numbars/hts),SelectedValue(TDL),colorBrightGreen);
_SECTION_END();







_SECTION_BEGIN("zzt");
para = ParamToggle("plot zz0","off,on");
cbar = Param("cbar",4,2,50,1);
per = Param("per",5,1,30,1);
zz0 = Zig(C,per);
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );
tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
pu = tr + 0.01 * abs(tr)*per;
pd = pk - 0.01 * abs(pk)*per;
zzt = IIf(C>= pu AND zz0 > zz1, 1,
IIf(C<= pd AND zz0 < zz1, -1, 0 ) );
zzt= ValueWhen( zzt != 0, zzt );
colorp2= IIf((C>O)OR(C<O),colorWhite,colorYellow);
Plot(IIf(para,zz0,Null)," ",colorWhite,styleNoLine|styleNoTitle|styleNoLabel);
pr=PeakBars(High,3)==0;
ps =TroughBars(Low,3)==0;
rf=ValueWhen(pr,High);
sf=ValueWhen(ps,Low);
rf1 = IIf(rf AND BarsSince(pr) <=cbar,rf,Null);
sf1 = IIf(sf AND BarsSince(ps ) <=cbar,sf,Null);
Plot(rf1,"",colorOrange,styleDots | styleNoLine);
Plot(sf1,"",colorOrange,styleDots | styleNoLine);
Plot(rf,"",colorLightOrange,40+16|styleNoLabel);
Plot(sf,"",colorLightOrange,40+16|styleNoLabel);
PlotShapes(IIf(pr, shapeSmallSquare,shapeNone),colorWhite,0,H,10);
PlotShapes(shapeSmallCircle*pr,colorBlack,0,H,10);
PlotShapes(IIf(ps, shapeSmallSquare,shapeNone),colorWhite,0,L,-10);
PlotShapes(shapeSmallCircle*ps,colorBlack,0,L,-10);
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("text shift", -50,-100,100,10);

PlotText("RF=" + WriteVal(rf,fraction),
SelectedValue(BarIndex()+7)-(numbars/hts),SelectedValue(rf),colorCustom12);
PlotText("SF=" + WriteVal(sf,fraction),
SelectedValue(BarIndex()+7)-(numbars/hts),SelectedValue(sf),colorYellow);
_SECTION_END();


PlotShapes(IIf(ps, shapeSmallSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(ps, shapeSmallSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(ps, shapeUpArrow, shapeNone),colorBlack, 0,L, Offset=-45);
PlotShapes(IIf(pr, shapeSmallSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(pr, shapeSmallSquare, shapeNone),colorRed, 0,H, Offset=50);
PlotShapes(IIf(pr, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

_SECTION_END();



_SECTION_BEGIN("META SIGNAL ");
Buy=C>(Ref(HHV(H,1),-2)*(1.005));
Sell=C<(Ref(LLV(L,1),-2)*(1.005));
A=(BarsSince(Buy)<BarsSince(Sell));
B=(BarsSince(Buy)>BarsSince(Sell));
A= ExRem(Buy,Sell);
B = ExRem(Sell, Buy);


_SECTION_END();



_SECTION_BEGIN(" vol 8 9");
Buy=Cross(V,MA(V,10)*2)AND C>O;
Sell=Cross(V,MA(V,10)*2)AND C<O;


_SECTION_BEGIN("Bullish Hook & Bearish Hook");
q= Cross(C, EMA(C,5))AND RSI(14)>30;
t= Cross(EMA(C,5), C)AND RSI(14)<70;



_SECTION_BEGIN("MACD");
r1 = Param("Fast avg", 10, 2, 200, 1);
r2 = Param("Slow avg", 22, 2, 200, 1);
r3 = Param("Signal avg", 5, 2, 200, 1);

m1 = MACD(r1,r2);
s1 = Signal(r1,r2,r3);

_SECTION_END();
Hist=m1-s1;
Buy= Cross(Hist,0);
Sell = Cross( 0, Hist );


_SECTION_BEGIN("Signals");

//Zero crossover up
j1 = Cross(m1,s1)AND m1>0;
PlotShapes(IIf(j1,shapeDigit1 ,Null),colorBlue,0,L,Offset=-45);
PlotShapes(IIf(j1,shapeHollowUpArrow,Null),colorBlue,0,L,Offset=-55);

// crossover above zero
j2 = Cross(m1,s1)AND m1<0 ;

PlotShapes(IIf(j2,shapeDigit2 ,Null),colorDarkBlue,0,L,Offset=-45);
PlotShapes(IIf(j2,shapeHollowUpArrow,Null),colorDarkBlue,0,L,Offset=-55);
//Zero crossover down
j3 = Cross(s1,m1) AND m1>0;

PlotShapes(IIf(j3,shapeDigit4 ,Null),colorCustom12,0,H,Offset=65);
PlotShapes(IIf(j3,shapeHollowDownArrow,Null),colorCustom12,0,H,Offset=-75);
Plot(J3,"",colorViolet,styleHistogram|styleDashed|styleOwnScale|styleNoLabel,0 ,1,0,0);

if (SelectedValue(j3)==1)Say("SELL mackd");

_SECTION_BEGIN("Patterns Wave");
Change = Param("Wave Period",5,0,100,1);



procedure PlotShapeAt( x, y, shape, shift )
{
PlotShapes( IIf( BarIndex() == x, shape, 0 ), colorWhite, 0, y, shift );
}

bi = BarIndex();
sbi = SelectedValue( bi );
GraphXSpace = 2;

upshift = 90;
if( SelectedValue( PeakBars( C, Change ) < TroughBars( C, Change ) ) )
{
pt1 = PeakBars( C, Change, 1 ) == 0 ;
pt2 = TroughBars( C, Change, 1 ) == 0 ;
}
else
{
pt1 = TroughBars( C, Change, 1 ) == 0 ;
pt2 = PeakBars( C, Change, 1 ) == 0 ;
upshift = -upshift;
}
bpt1 = SelectedValue( ValueWhen( pt1, bi ) );
bpt2 = SelectedValue( ValueWhen( pt2, bi ) );
bpt3 = SelectedValue( ValueWhen( pt1, bi, 2 ) );
bpt4 = SelectedValue( ValueWhen( pt2, bi, 2 ) );
bpt5 = SelectedValue( ValueWhen( pt1, bi, 3 ) );
bpt6 = SelectedValue( ValueWhen( pt2, bi, 3 ) );
PlotShapeAt( bpt1, C, shapeDigit5, upshift );
PlotShapeAt( bpt2, C, shapeDigit4, -upshift );
PlotShapeAt( bpt3, C, shapeDigit3, upshift );
PlotShapeAt( bpt4, C, shapeDigit2, -upshift );
PlotShapeAt( bpt5, C, shapeDigit1, upshift );
_SECTION_END();




_SECTION_BEGIN("trend");

SetChartOptions(0,chartShowArrows|chartShowDates);
ScanLookBack = Param("Scan Lookback", 2, 1, 25 );
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);


_SECTION_END();
_SECTION_BEGIN("INIT");

SetChartOptions(0,chartShowArrows|chartShowDates);
ScanLookBack = Param("Scan Lookback", 2, 1, 25 );
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);





_SECTION_BEGIN("wma89");
P = ParamField("Field");
Type = ParamList("Type", "Weighted,Simple,Exponential,Double Exponential,Tripple Exponential,Wilders");
Periods89 = Param("Periods89", 89, 2, 300 );
Displacement2 = Param("Displacement2", 2, -50, 50 );
bbb= WMA( P, Periods89 );
colr = IIf(Avg >= bbb,colorGreen,colorRed);

Buy=Cover=Cross(Avg,bbb);
Sell=Short=Cross(bbb,Avg);
MYcolor = IIf( EMA(C,13)>EMA(EMA(C,13),9) AND C>Peak(C,2,1), colorGreen, IIf(EMA(C,13)>EMA(EMA(C,13),9) AND C<Peak(C,2,1),colorBlue, colorBrown ));
_SECTION_BEGIN( "Zig Hi Lo" );
// ZIG hilo version by Joris Schuller
// from ZigZag Hi Lo.afl : simplified version
pltzig = ParamToggle( "Plot ZigHL ", "Off|On", 1 );
change = Param( "ZigZag-HL %", 3, 0.01, 3, 0.01 );
za2 = 0;

pk = PeakBars( H, change ) == 0;
tr = TroughBars( L, change ) == 0;
pkbars = PeakBars( H, change );
trbars = TroughBars( L, change );
zHi = Zig( H, change );
zLo = Zig( L, change );
HLAvg = ( zHi + zLo ) / 2;
zp2 = IIf( pk, zHi, IIf( tr, zLo, IIf( pkbars <= trbars, L, H ) ) );//Modified zp to reduce occasional erroneous Pk/Tr connections at very small ZigPerc values
za2 = Zig( zp2, change );

if ( pltzig == 1 )
{
}

_SECTION_END();
_SECTION_BEGIN( "123 Pattern" );

procedure
PlotShape( x, y, shape, shift )
{
PlotShapes( IIf( BarIndex() == x, shape, 0 ), colorOrange, 0, y, shift );
}

bi = BarIndex();
sbi = SelectedValue( bi );
upshift = Param( "upshift ", 30, 1, 100, 1 );

if ( SelectedValue( PeakBars( za2 , Change ) < TroughBars( za2 , Change ) ) )
{
pt3 = PeakBars( za2 , Change, 1 ) == 0 ;
pt2 = TroughBars( za2 , Change, 1 ) == 0 ;
ydigit1 = H;
ydigit2 = L;
ydigit3 = H;
}
else
{
pt3 = TroughBars( za2 , change, 1 ) == 0 ;
pt2 = PeakBars( za2 , change, 1 ) == 0 ;
ydigit1 = L;
ydigit2 = H;
ydigit3 = L;
upshift = -upshift;
}

bpt1 = SelectedValue( ValueWhen( pt3, bi ) ); // x axis

bpt2 = SelectedValue( ValueWhen( pt2, bi ) );
bpt3 = SelectedValue( ValueWhen( pt3, bi , 2 ) );

pltdigit = ParamToggle( "Plot 123 Digit ", "Off|On", 1 );

if ( pltdigit == 1 )
{
PlotShape( bpt1, ydigit3 , shapeDigit3, upshift );
PlotShape( bpt2, ydigit2 , shapeDigit2, -upshift );
PlotShape( bpt3, ydigit1 , shapeDigit1, upshift );
}

_SECTION_END();

_SECTION_BEGIN("MC");
Mothc=Ref(H,-1)>H AND Ref(L,-1)<L;
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(L,-1))));
TDL = LineArray(0, y0, (BarCount-1), y0);
Plot(TDL, "", colorBrightGreen,styleDashed|styleNoLabel);
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(H,-1))));
TDH= LineArray(0, y0, (BarCount-1), y0);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,H,5);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,L,-5);
Plot(TDH, "", colorRed,styleDashed|styleNoLabel);
Buy=Cross(C,TDH);
Sell=Cross(TDL,C);

numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("Text Shift", -50,-100,100,10);
PlotText("" + WriteVal(TDH,fraction),
SelectedValue(BarIndex()+0.5)-(numbars/hts),SelectedValue(TDH),colorRed);
PlotText("" + WriteVal(TDL,fraction),
SelectedValue(BarIndex()+0.5)-(numbars/hts),SelectedValue(TDL),colorBrightGreen);
_SECTION_END();



_SECTION_END();

_SECTION_END();_SECTION_END();
_SECTION_BEGIN("Name");
GfxSetOverlayMode(1);
pxh= Status("pxHeight"); pxw=Status("pxWidth");
GfxSelectFont("Tahoma",pxh/30);
GfxSetTextColor(colorWhite);
GfxSetTextAlign(6); GfxSetBkMode(0);
GfxTextOut(FullName(),pxw/2,pxh/12);
GfxSelectFont("Tahoma",pxh/15);
GfxTextOut("",pxw/2,pxh/3);
_SECTION_END();


;

_SECTION_BEGIN("companysympole");

_SECTION_BEGIN("companyclos");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorWhite);
GfxTextOut("C="+C+" ",580,1);
}
_SECTION_END();

_SECTION_BEGIN("companyhigh");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorCustom13);
GfxTextOut("H="+H+" ",480,1);
}
_SECTION_END();

_SECTION_BEGIN("companyopen");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorWhite);
GfxTextOut("O="+O+" ",380,1);
}
_SECTION_END();

_SECTION_BEGIN("companylow");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorYellow);
GfxTextOut("L="+L+" ",280,1);
}
_SECTION_END();


_SECTION_BEGIN("CNcP");
Cd1=-(O-C)/(H-L)*100;
Cd=Prec((Cd1),2);
ColorE=IIf(Cd>=68,colorYellow,IIf(Cd<=-68,colorRed,colorCustom12));
_SECTION_END();
_SECTION_BEGIN("Price");
BarColor = IIf((Cd>=68)OR (Cd<=-68),colorYellow,colorCustom12);
Plot(C, "", BarColor, styleNoTitle| styleThick | styleCandle|styleNoLabel);
Plot(C, "",styleCandle, colorBlack, styleThick);
_SECTION_END();

_SECTION_BEGIN("");
r= MACD(10, 22);
dd= Signal(10,22,5);
Hist=r-dd;
BuyHist= Cross(Hist,0);
SellHist = Cross( 0, Hist );



_SECTION_BEGIN("MA(20)");

BarColor = IIf((C>MA(C,20)),colorWhite,colorRed);
Plot(MA(C,20),"",BarColor,styleThick);
BuyMA= Cross(C,MA(C,20));
SellMA= Cross( MA(C,20), C );
_SECTION_END();


_SECTION_BEGIN("Magnified Price");
FS=Param("Font Size",15,11,100,1);
GfxSelectFont("Arial", FS, 700, True );
GfxSetBkMode(ColorRGB(255,170,188));
GfxSetTextColor( ParamColor("Color",colorYellow) );
Hor=Param("Horizontal Position",390,2,1,2);
Ver=Param("Vertical Position",1,1,1,1);
GfxTextOut("C="+C,Hor , Ver+55 );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);

GfxSelectFont("Arial", 12, 700, True );
GfxSetBkMode( colorYellow );
GfxSetTextColor(ParamColor("Color",colorBlue) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+80 );

_SECTION_END();


_SECTION_BEGIN("Nd");
Nd=((C)-(O))/(L)*10000;
Filter=Close;
AddColumn(Nd , "Nd",1.2,colorBrown);

_SECTION_BEGIN(" Nd");
{ GfxSelectFont("Arial",12, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorCustom12);
GfxTextOut("Nd="+WriteVal(Nd,format=1.2)+"% ",750,1);
GfxSetTextColor(colorWhite);

}
_SECTION_END();

_SECTION_BEGIN("CNcP");
Cd1=-(O-C)/(H-L)*100;
Cd=Prec((Cd1),2);
Filter=Close;
AddColumn(Cd , "Cd",1.2,colorOrange);
_SECTION_END();


_SECTION_BEGIN(" Cd");
{ GfxSelectFont("Arial",13, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorGold);
GfxTextOut("Cd="+WriteVal(Cd,format=1.2)+"% ",870,1);
}
_SECTION_END();






_SECTION_BEGIN(" ZigZagTrend ");
array = Close;
amount = Param("Amount", 5, 1, 50, 0.5 );
zz0 = Zig( array, amount );
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );
tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
PU = tr + 0.01 * abs(tr)*amount;
PD = pk - 0.01 * abs(pk)*amount;
ZZT = IIf( array >= PU AND zz0 > zz1, 1,
IIf( array <= PD AND zz0 < zz1, -1, 0 ) );
ZZT = ValueWhen( ZZT != 0, ZZT );
Com=IIf(ZZT>0,colorBlue,IIf(ZZT<0,colorRed,colorBlack));

_SECTION_BEGIN("Font Color");
function GfxConvertBarToPixelX(Bar)
{
lvb = Status("lastvisiblebar"); fvb = Status("firstvisiblebar");
pxchartleft = Status("pxchartleft"); pxchartwidth = Status("pxchartwidth");
return pxchartleft + Bar * pxchartwidth / (Lvb-fvb + 1);
}
procedure MultiRibbon(RibbonColor, Position, Label)
{
LineColor =colorWhite;
Position =2* Position;
x2 = Status("pxchartright");
y2 = Status("pxchartbottom");
RibbonColor =IIf(GfxConvertBarToPixelX(BarIndex()-Status("firstvisiblebarindex")) > y2/1.5 *
(2/100)*10,RibbonColor, colorWhite);
Plot(0, "",LineColor, styleOwnScale|styleNoLabel,0,100);
Plot(Position, "",LineColor,styleOwnScale| styleNoLabel,0,100);
Plot(Position, "",RibbonColor,styleArea|styleOwnScale|styleNoLabel, 0,100);

GfxSelectFont("Arial", y2/1 * (2.7/180),200);
GfxDrawText(Label,8, y2 *1.006-(y2 * Position/100) , y2/1.6*
(2/100)*10,y2,2+32+256);
GfxSetTextColor(colorBlue);
}
multiribbon(COM,1, "Trend");


Buy=Cross(ZZT,0);
Sell=Cross(0,ZZT);
PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone) ,colorBlue,0,L,-15);
PlotShapes(IIf(Sell,shapeSmallDownTriangle, shapeNone),colorRed,0,H,-15);

_SECTION_BEGIN("Zig_Zag_");

PercentChange = 4;
mystartbar = SelectedValue(BarIndex()); // FOR GRAPHING

mystartbardate = LastValue(ValueWhen(mystartbar == BarIndex(), DateNum(),1));

InitialValue = LastValue(ValueWhen(mystartbardate == DateNum(), C , 1 ) ) ;


ZZ = Zig(C,LastValue(PercentChange)) ;
PivotLow = Ref(IIf(Ref(ROC(ZZ,1),-1) < 0 AND ROC(ZZ,1) > 0, 1,Null),1);
PivotHigh = Ref(IIf(Ref(ROC(ZZ,1),-1) > 0 AND ROC(ZZ,1) < 0, 1,Null),1);

PlotShapes(IIf(PivotLow, shapeDigit1, shapeNone),colorYellow, 0,L, Offset=-32);

PlotShapes(IIf(PivotHigh, shapeDigit1, shapeNone),colorYellow, 0,H, Offset=32);



_SECTION_BEGIN("ZigZag");
{ GfxSelectFont("Arial",13, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorGold);
GfxTextOut(" ZigZag="+WriteVal(ZZ,format=1.2)+"",75,20);
}
_SECTION_END();

_SECTION_BEGIN("MACD");
ml = MACD(6, 13);
dd= Signal(6,13,5);
Hist=ml-dd;
col_hist= IIf(Hist > BBandTop( Hist, 5, 0.5 ),colorLightBlue,IIf(Hist < BBandBot( Hist, 5, 0.5 ),colorBlue,colorRed));
pr=PeakBars(C,5)==0;
ps =TroughBars(C,5)==0;
PlotShapes(IIf(ps,shapeDigit2 ,Null),colorBlue,0,L,-45);
PlotShapes(IIf(pr,shapeDigit2 ,Null),colorBlue,0,H,45);




_SECTION_BEGIN("Fibonacci And Gann Projections");
Change = 5;
GannIncrement = 0.0625;
{
}
procedure PlotBlueDot( x, y )
{


for( i = -2; i <= 2; i++ )
{
if( i != 0 )
{
yGann = ( sqrt( y ) + i * GannIncrement ) ^ 2;

}
}
}
bi = BarIndex();
sbi = SelectedValue( bi );
GraphXSpace = 2;

upshift =65;
if( SelectedValue( PeakBars( C, Change ) < TroughBars( C, Change ) ) )
{
pt1 = PeakBars( C, Change, 1 ) == 0 ;
pt2 = TroughBars( C, Change, 1 ) == 0 ;
}
else
{
pt1 = TroughBars( C, Change, 1 ) == 0 ;
pt2 = PeakBars( C, Change, 1 ) == 0 ;
upshift = -upshift;
}
bpt1 = SelectedValue( ValueWhen( pt1, bi ) );
bpt2 = SelectedValue( ValueWhen( pt2, bi ) );
bpt3 = SelectedValue( ValueWhen( pt1, bi, 2 ) );
bpt4 = SelectedValue( ValueWhen( pt2, bi, 2 ) );
bpt5 = SelectedValue( ValueWhen( pt1, bi, 3 ) );
bpt6 = SelectedValue( ValueWhen( pt2, bi, 3 ) );
PlotShapeAt( bpt1, C, shapeDigit1, upshift );
PlotShapeAt( bpt2, C, shapeDigit2, -upshift );
PlotShapeAt( bpt3, C, shapeDigit3, upshift );
PlotShapeAt( bpt4, C, shapeDigit4, -upshift );
PlotShapeAt( bpt5, C, shapeDigit5, upshift );
PlotShapeAt( bpt6, C, shapeDigit6, -upshift );
Level = SelectedValue( ValueWhen( pt1, C ) );
PlotBlueDot( round( bpt1 + 1.618 * ( bpt1 - bpt2 ) ), Level );
PlotBlueDot( round( bpt1 + 0.382 * ( bpt1 - bpt2 ) ), Level );
PlotBlueDot( round( bpt1 + 0.5 * ( bpt2 - bpt3 ) ), Level );
PlotBlueDot( round( bpt1 + 1.732 * ( bpt2 - bpt3 ) ), Level );
PlotBlueDot( round( bpt1 + 0.618 * ( bpt4 - bpt5 ) ), Level );
PlotBlueDot( round( bpt1 + 2 * ( bpt4 - bpt5 ) ), Level );
PlotBlueDot( round( bpt2 + 0.6707 * ( bpt4 - bpt2 ) ), Level );
PlotBlueDot( round( bpt2 + 2.618 * ( bpt4 - bpt2 ) ), Level );
PlotBlueDot( round( bpt2 + 1 * ( bpt6 - bpt2 ) ), Level );
PlotBlueDot( round( bpt2 + 3 * ( bpt6 - bpt2 ) ), Level );


_SECTION_END();











_SECTION_BEGIN("zzt");
para = ParamToggle("plot zz0","off,on");
cbar = Param("cbar",10,2,50,1);
per = Param("per",5,1,30,1);
zz0 = Zig(C,per);
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );
tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
pu = tr + 0.01 * abs(tr)*per;
pd = pk - 0.01 * abs(pk)*per;
zzt = IIf(C>= pu AND zz0 > zz1, 1,
IIf(C<= pd AND zz0 < zz1, -1, 0 ) );
zzt= ValueWhen( zzt != 0, zzt );
colorp2= IIf((C>O)OR(C<O),colorWhite,colorYellow);
Plot(IIf(para,zz0,Null)," ",colorWhite,styleLine|styleNoTitle);
pr=PeakBars(High,5)==0;
ps =TroughBars(Low,5)==0;
rf=ValueWhen(pr,High);
sf=ValueWhen(ps,Low);
rf1 = IIf(rf AND BarsSince(pr) <=cbar,rf,Null);
sf1 = IIf(sf AND BarsSince(ps ) <=cbar,sf,Null);
Plot(rf1,"",colorRed,styleDots | styleNoLine|styleNoLabel);
Plot(sf1,"",colorBrightGreen,styleDots | styleNoLine|styleNoLabel);



_SECTION_END();
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("text shift", -50,-100,100,10);
PlotText("" + WriteVal(rf,fraction),
SelectedValue(BarIndex()+6)-(numbars/hts),SelectedValue(rf),colorWhite,colorRed);
PlotText("" + WriteVal(sf,fraction),
SelectedValue(BarIndex()+6)-(numbars/hts),SelectedValue(sf),colorWhite,colorGreen);
_SECTION_END();




Plot( Open, "open", 0, stylehidden| styleNoTitle );
Plot(Close, "close", 0, stylehidden| styleNoTitle );
Plot(High, "high", 0, stylehidden| styleNoTitle );
Plot(Low, "low", 0, stylehidden| styleNoTitle );

numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("text shift", -50,-100,100,10);

_SECTION_END();






_SECTION_BEGIN("MotheCandle");
Mothc=Ref(H,-1)>H AND Ref(L,-1)<L;
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(L,-1))));
TDL = LineArray(0, y0, (BarCount-1), y0);
Plot(TDL, "", colorGold,styleDashed|styleNoLabel);
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(H,-1))));
TDH= LineArray(0, y0, (BarCount-1), y0);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)), colorGold,0,H,5);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,L,-5);
Plot(TDH, "", colorCustom12,styleDashed|styleNoLabel);
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("Text Shift", -50,-100,100,10);

PlotText("" + WriteVal(TDH,fraction),
SelectedValue(BarIndex())-(numbars/hts),SelectedValue(TDH),colorCustom12);
PlotText("" + WriteVal(TDL,fraction),
SelectedValue(BarIndex())-(numbars/hts),SelectedValue(TDL),colorGold);
_SECTION_END();







_SECTION_BEGIN("AuthorName");
k = (GetPerformanceCounter()/100)%100;
printf("GetPerformance Counter %g",k);
GfxSelectFont("jokerman", 12,800);
GfxSetBkMode(1);
GfxSetTextColor(colorGold);
GfxTextOut("MotherCandle",450,20);
RequestTimedRefresh(10);
_SECTION_END();


_SECTION_BEGIN("WMA 50");
slope = Param("slope",2,2,100,1);
Color20= IIf(LinRegSlope(WMA(C,50),slope)<0,colorCustom13,colorCustom13);
event1= LinRegSlope(WMA(C,50),slope)<1;
Plot( WMA( C,50), "",Color20,styleNoLine|styleNoLabel);

_SECTION_END();
_SECTION_BEGIN("WMA 50");
{ GfxSelectFont("Bernard MT Condensed",12, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorCustom13);
GfxTextOut("WMA50="+WMA( C,50),250,20);
}
_SECTION_END();




_SECTION_END();




_SECTION_BEGIN("Pivot_Finder");
/* **********************************

Code to automatically identify pivots

********************************** */

// -- what will be our lookback range for the hh and ll?
farback=Param("How Far back to go",100,0,5000,10);
nBars = Param("Number of bars", 8, 5, 40);


// -- Create 0-initialized arrays the size of barcount

aHPivs = H - H;

aLPivs = L - L;

// -- More for use, not necessary for basic plotting

aHPivHighs = H - H;

aLPivLows = L - L;

aHPivIdxs = H - H;

aLPivIdxs = L - L;

nHPivs = 0;

nLPivs = 0;

lastHPIdx = 0;

lastLPIdx = 0;

lastHPH = 0;

lastLPL = 0;

curPivBarIdx = 0;

// -- looking back from the current bar, how many bars

// back were the hhv and llv values of the previous

// n bars, etc.?

aHHVBars = HHVBars(H, nBars);

aLLVBars = LLVBars(L, nBars);

aHHV = HHV(H, nBars);

aLLV = LLV(L, nBars);

// -- Would like to set this up so pivots are calculated back from

// last visible bar to make it easy to "go back" and see the pivots

// this code would find. However, the first instance of

// _Trace output will show a value of 0

aVisBars = Status("barvisible");

nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));

_TRACE("Last visible bar: " + nLastVisBar);

// -- Initialize value of curTrend

curBar = (BarCount-1);

curTrend = "";

if (aLLVBars[curBar] <

aHHVBars[curBar]) {

curTrend = "D";

}

else {

curTrend = "U";

}

// -- Loop through bars. Search for

// entirely array-based approach

// in version

for (i=0; i<farback; i++) {

curBar = (BarCount - 1) - i;

// -- Have we identified a pivot? If trend is down...

if (aLLVBars[curBar] < aHHVBars[curBar]) {

// ... and had been up, this is a trend change

if (curTrend == "U") {

curTrend = "D";

// -- Capture pivot information

curPivBarIdx = curBar - aLLVBars[curBar];

aLPivs[curPivBarIdx] = 1;

aLPivLows[nLPivs] = L[curPivBarIdx];

aLPivIdxs[nLPivs] = curPivBarIdx;

nLPivs++;

}

// -- or current trend is up

} else {

if (curTrend == "D") {

curTrend = "U";

curPivBarIdx = curBar - aHHVBars[curBar];

aHPivs[curPivBarIdx] = 1;

aHPivHighs[nHPivs] = H[curPivBarIdx];

aHPivIdxs[nHPivs] = curPivBarIdx;

nHPivs++;

}

// -- If curTrend is up...else...

}

// -- loop through bars

}

// -- Basic attempt to add a pivot this logic may have missed

// -- OK, now I want to look at last two pivots. If the most

// recent low pivot is after the last high, I could

// still have a high pivot that I didn't catch

// -- Start at last bar

curBar = (BarCount-1);

candIdx = 0;

candPrc = 0;

lastLPIdx = aLPivIdxs[0];

lastLPL = aLPivLows[0];

lastHPIdx = aHPivIdxs[0];

lastHPH = aHPivHighs[0];

if (lastLPIdx > lastHPIdx) {

// -- Bar and price info for candidate pivot

candIdx = curBar - aHHVBars[curBar];

candPrc = aHHV[curBar];

if (

lastHPH < candPrc AND

candIdx > lastLPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aHPivs[candIdx] = 1;

// ...and then rearrange s in the

// pivot information arrays

for (j=0; j<nHPivs; j++) {

aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-

(j+1)];

aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];

}

aHPivHighs[0] = candPrc ;

aHPivIdxs[0] = candIdx;

nHPivs++;

}

} else {


// -- Bar and price info for candidate pivot

candIdx = curBar - aLLVBars[curBar];

candPrc = aLLV[curBar];

if (

lastLPL > candPrc AND

candIdx > lastHPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aLPivs[candIdx] = 1;

// ...and then rearrange s in the

// pivot information arrays

for (j=0; j<nLPivs; j++) {

aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];

aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];

}

aLPivLows[0] = candPrc;

aLPivIdxs[0] = candIdx;

nLPivs++;

}

}

// -- Dump inventory of high pivots for debugging



for (k=0; k<nHPivs; k++) {

_TRACE("High pivot no. " + k

+ " at barindex: " + aHPivIdxs[k] + ", "

+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],

DateTime(), 1), formatDateTime)

+ ", " + aHPivHighs[k]);

}

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

// -- OK, let's plot the pivots using arrows

PlotShapes(IIf(aHPivs==1, shapeSmallDownTriangle, shapeNone), colorRed, 0, High, Offset=-14);
PlotShapes(IIf(aLPivs==1, shapeSmallUpTriangle , shapeNone), colorBrightGreen, 0, Low, Offset=-13);

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


/* **********************************

Code to automatically identify pivots

********************************** */
// -- what will be our lookback range for the hh and ll?
farback=Param("How Far back to go",500,12,30,1);
nBars = Param("Number of bars", 8, 1, 30, 1);
// -- Create 0-initialized arrays the size of barcount
aHPivs = H - H;
aLPivs = L - L;
// -- More for use, not necessary for basic plotting
aHPivHighs = H - H;
aLPivLows = L - L;
aHPivIdxs = H - H;
aLPivIdxs = L - L;
nHPivs = 0;
nLPivs = 0;
lastHPIdx = 0;
lastLPIdx = 0;
lastHPH = 0;
lastLPL = 0;
curPivBarIdx = 0;
// -- looking back from the current bar, how many bars
// back were the hhv and llv values of the previous
// n bars, etc.?
aHHVBars = HHVBars(H, nBars);
aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);
aLLV = LLV(L, nBars);
// -- Would like to set this up so pivots are calculated back from
// last visible bar to make it easy to "go back" and see the pivots
// this code would find. However, the first instance of
// _Trace output will show a value of 0
aVisBars = Status("barvisible");
nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
_TRACE("Last visible bar: " + nLastVisBar);
// -- Initialize value of curTrend
curBar = (BarCount-1);
curTrend = "";
if (aLLVBars[curBar] <
aHHVBars[curBar]) {
curTrend = "D";
}
else {
curTrend = "U";
}
// -- Loop through bars. Search for
// entirely array-based approach
// in version
for (i=0; i<farback; i++) {
curBar = (BarCount - 1) - i;
// -- Have we identified a pivot? If trend is down...
if (aLLVBars[curBar] < aHHVBars[curBar]) {
// ... and had been up, this is a trend change
if (curTrend == "U") {
curTrend = "D";
// -- Capture pivot information
curPivBarIdx = curBar - aLLVBars[curBar];
aLPivs[curPivBarIdx] = 1;
aLPivLows[nLPivs] = L[curPivBarIdx];
aLPivIdxs[nLPivs] = curPivBarIdx;
nLPivs++;
}
// -- or current trend is up
} else {
if (curTrend == "D") {
curTrend = "U";
curPivBarIdx = curBar - aHHVBars[curBar];
aHPivs[curPivBarIdx] = 1;
aHPivHighs[nHPivs] = H[curPivBarIdx];
aHPivIdxs[nHPivs] = curPivBarIdx;
nHPivs++;
}
// -- If curTrend is up...else...
}
// -- loop through bars
}
// -- Basic attempt to add a pivot this logic may have missed
// -- OK, now I want to look at last two pivots. If the most
// recent low pivot is after the last high, I could
// still have a high pivot that I didn't catch
// -- Start at last bar
curBar = (BarCount-1);
candIdx = 0;
candPrc = 0;
lastLPIdx = aLPivIdxs[0];
lastLPL = aLPivLows[0];
lastHPIdx = aHPivIdxs[0];
lastHPH = aHPivHighs[0];
if (lastLPIdx > lastHPIdx) {
// -- Bar and price info for candidate pivot
candIdx = curBar - aHHVBars[curBar];
candPrc = aHHV[curBar];
if (
lastHPH < candPrc AND
candIdx > lastLPIdx AND
candIdx < curBar) {
// -- OK, we'll add this as a pivot...
aHPivs[candIdx] = 1;
// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nHPivs; j++) {
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-
(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];
}
aHPivHighs[0] = candPrc ;
aHPivIdxs[0] = candIdx;
nHPivs++;
}
} else {
// -- Bar and price info for candidate pivot
candIdx = curBar - aLLVBars[curBar];
candPrc = aLLV[curBar];
if (
lastLPL > candPrc AND
candIdx > lastHPIdx AND
candIdx < curBar) {
// -- OK, we'll add this as a pivot...
aLPivs[candIdx] = 1;
// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nLPivs; j++) {
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
}
aLPivLows[0] = candPrc;
aLPivIdxs[0] = candIdx;
nLPivs++;
}
}
// -- Dump inventory of high pivots for debugging
/*
for (k=0; k<nHPivs; k++) {
_TRACE("High pivot no. " + k
+ " at barindex: " + aHPivIdxs[k] + ", "
+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],
DateTime(), 1), formatDateTime)
+ ", " + aHPivHighs[k]);
}
*/
// -- OK, let's plot the pivots using arrows
PlotShapes(IIf(aHPivs==1, shapeHollowSmallDownTriangle, shapeNone), colorOrange, 0, High, Offset=-25);
PlotShapes(IIf(aLPivs==1, shapeHollowSmallUpTriangle , shapeNone), colorWhite, 0, Low, Offset=-23);

Sell = aHPivs == 1 ;
Buy = aLPivs == 1 ;
Filter=Buy OR Sell;
Sell=ExRem(Sell,Buy);
Buy=ExRem(Buy,Sell);





_SECTION_END();










_SECTION_BEGIN("td fractl line");
strength = Param("strength",1,1,15,1);
pr=PeakBars(RSI(14),strength)==0;

_SECTION_END();
_SECTION_BEGIN("td fractl line");
ps =TroughBars(RSI(14),strength)==0;

_SECTION_END();
_SECTION_BEGIN("price risistance");
rt=SelectedValue(ValueWhen(pr,H));
st=SelectedValue(ValueWhen(ps,L));


_SECTION_BEGIN("td fractl line");
pr=PeakBars(RSI(14),strength)==0;
pivothigh = Ref(pr,-1)<pr AND pr>Ref(pr,1);
y0=SelectedValue(ValueWhen(pivothigh,H,2));
y1=SelectedValue(ValueWhen(pivothigh,H,1));
x0=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,2));
x1=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,1));
linea=LineArray(x0,y0,x1,y1,1);

_SECTION_END();
_SECTION_BEGIN("td fractl line");
ps =TroughBars(RSI(14),strength)==0;
pivotlow = Ref(ps,-1)<ps AND ps>Ref(ps,1);
yt0=SelectedValue(ValueWhen(pivotlow,L,2));
yt1=SelectedValue(ValueWhen(pivotlow,L,1));
xt0=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,2));
xt1=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,1));
lineb=LineArray(xt0,yt0,xt1,yt1,1);



_SECTION_BEGIN("V");
_SECTION_END();


_SECTION_BEGIN("EMA Time Frame");
r= RSI(14);
pR=PeakBars(RSI(14),1)==0;
pivothigh = Ref(pR,-1)<pR AND pR>Ref(pR,1);
y0=SelectedValue(ValueWhen(pivothigh,RSI(14),2));
y1=SelectedValue(ValueWhen(pivothigh,RSI(14),1));
x0=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,2));
x1=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,1));
LineA=LineArray(x0,y0,x1,y1,1);
pS =TroughBars(RSI(14),1)==0;
pivotlow = Ref(pS,-1)<pS AND pS>Ref(pS,1);
yt0=SelectedValue(ValueWhen(pivotlow,RSI(14),2));
yt1=SelectedValue(ValueWhen(pivotlow,RSI(14),1));
xt0=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,2));
xt1=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,1));
LineB=LineArray(xt0,yt0,xt1,yt1,1);

_SECTION_BEGIN("DIV");
u00=LastValue(Peak(H,1,2));
u11=LastValue(Peak(H,1,1));
a00=BarCount - 1 - LastValue(PeakBars(H,1,2));
price_start1=Close[a00];
a11=BarCount - 1 - LastValue(PeakBars(H,1,1));
price_end1=Close[a11];
Line = LineArray(a00,u00,a11,u11, 0 );
LastPointSell = LineArray(a11-1,u11-1,a11,u11,0);

GG=u11<u00 AND price_end1>price_start1;
PlotShapes(shapeSmallCircle*GG ,colorDarkRed,0,Line,-2);




_SECTION_END();

_SECTION_BEGIN("DIV");
u0=LastValue(Trough(L,1,2));
u1=LastValue(Trough(L,1,1));
a0=BarCount - 1 - LastValue(TroughBars(L,1,2));
price_start=Close[a0];
a1=BarCount - 1 - LastValue(TroughBars(L,1,1));
price_end=Close[a1];
Line = LineArray(a0,u0,a1,u1, 0 );

TT=u1>u0 AND price_end<price_start;
LastPointBuy = LineArray(a1-1,u1-1,a1,u1,0);
PlotShapes(shapeSmallCircle*TT,colorCustom11,0,Line,-2);


_SECTION_END();

SetChartBkColor( ParamColor("background",colorDarkTeal));


SetChartOptions(0, chartShowDates | chartWrapTitle);

Type = ParamList("Average Type", "Wilders");
P = Param("Averaging Period", 20, 3, 100,1);
Q = Param("%Change", 1, 0.1, 10, 0.1);
BP = Param("BB Period", 20, 3, 100);
BW = Param("BB Width", 2, 0.5, 10, 0.5);
BBOption = ParamToggle("Plot BB", "No I Yes");

A=Param( "Swing", 20, 1, 100);
SL = Max(LLV(L, 5), Trough(L, Q, 1));

Tgt = 2 * H - SL;
MeanPrice = Prec((O + C) / 2, 2);

Part = 100 * (H - A) / (H - L);

BBTop = BBandTop(C, BP, BW);
BBBot = BBandBot(C, BP, BW);

res=HHV(H,A);
sup=LLV(L,A);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);

// line code
Plot(tsl, _DEFAULT_NAME(), ParamColor( "ColorD", colorRed ), styleStaircase|styleNoLabel|styleNoLine);

// arrows code
Buy=Cross(C,Ref(res,-1));
Sell=Cross(Ref(sup,-1),C);
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

Bought = Flip(Buy, Sell);
Sold = Flip(Sell, Buy);
NextTgt = ValueWhen(Buy, Tgt, 1);

for(i = 1; i < BarCount; i++)
{
if(Bought[i] AND NOT Buy[i])
{
SL[i] = Max(SL[i], SL[i - 1]);
if(C[i - 1] >= 0.9999 * NextTgt[i - 1]) NextTgt[i] = Tgt[i - 1];
NextTgt[i] = Max(NextTgt[i], NextTgt[i - 1]);
}
}
BuyDate = ValueWhen(Buy, Ref(DateTime(), 1), 1);
BuyPrice = ValueWhen(Buy, Ref(MeanPrice, 1), 1);
SellPrice = ValueWhen(Sell, Ref(MeanPrice, 1), 1);

TgtReached = IIf(Bought AND NOT Buy AND C >= 0.9999 * NextTgt, True, False);
SLHit = IIf(Bought AND NOT Buy AND C < SL, True, False);
SLHit = ExRem(SLHit, Buy);
Plot(IIf(Bought, NextTgt, Null), "Target", colorRed,styleNoLine|styleNoTitle|styleNoLabel);
Plot(SL, "Trail SL", colorGrey40, styleNoLine|styleNoTitle|styleNoLabel);
_SECTION_BEGIN(" ");
{ GfxSelectFont("Arial",13, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorDarkYellow);
GfxTextOut("TR="+WriteVal(NextTgt,format=1.2)+"",740,20);
GfxSetTextColor(colorBlue);
GfxTextOut("Trail="+WriteVal(SL,format=1.2)+"",850 ,20);
GfxSetTextColor(colorRed);
GfxTextOut(" SL="+WriteVal(tsl,format=1.2)+"",970,20);

}
_SECTION_END();
_SECTION_BEGIN(" Bullish sign & Bearish sign ");
SetChartOptions(0,chartShowArrows|chartShowDates);

rg=(H-L);
arg=Wilders(rg,30);

Vl=V<Ref(V,-1) AND V<Ref(V,-2);

mp=(H+L)/2;


_SECTION_BEGIN("VSA");

eftup=H>Ref(H,-1) AND L>Ref(L,-1) AND C>Ref(C,-1) AND C>=((H-L)*0.7+L) AND rg>arg AND V>Ref(V,-1);

eftdn=H<Ref(H,-1) AND L<Ref(L,-1) AND C<Ref(C,-1) AND C<=((H-L)*0.25+L) AND rg>arg AND V>Ref(V,-1);
_SECTION_END();

PlotShapes(shapeSmallCircle*eftup, colorDarkTeal, 0, mp, 0 );
PlotShapes(shapeSmallCircle*eftdn, colorBlack, 0, mp, 0 );

_SECTION_BEGIN("BB");
bb2top = BBandTop(Close,20,2.25);
bb1top = BBandTop(Close,20,1);
bb2bot = BBandBot(Close,20,2.25);
bb1bot = BBandBot(Close,20,1);

Plot (bb1top,"",IIf(bb1top > Ref(bb1top,-1) AND bb1bot < Ref(bb1bot,-1),colorYellow,colorYellow),32);
Plot (bb1bot,"",IIf(bb1top > Ref(bb1top,-1) AND bb1bot < Ref(bb1bot,-1),colorYellow,colorYellow),32);
Plot (bb2top,"",IIf(bb2top > Ref(bb2top,-1) AND bb2bot < Ref(bb2bot,-1),colorLightGrey,colorLightGrey),32);
Plot (bb2bot,"",IIf(bb2top > Ref(bb2top,-1) AND bb2bot < Ref(bb2bot,-1),colorLightGrey,colorLightGrey),32);
PlotOHLC(bb2top,bb2top,bb1top,bb1top,"",ColorRGB(56,63,118),styleCloud|styleNo Label);
PlotOHLC(bb1bot,bb1bot,bb2bot,bb1bot,"",ColorRGB(56,63,118),styleCloud|styleNo Label);


_SECTION_END();


_SECTION_BEGIN("EMA Time Frame");
r= RSI(14);
pR=PeakBars(RSI(14),1)==0;
pivothigh = Ref(pR,-1)<pR AND pR>Ref(pR,1);
y0=SelectedValue(ValueWhen(pivothigh,RSI(14),2));
y1=SelectedValue(ValueWhen(pivothigh,RSI(14),1));
x0=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,2));
x1=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,1));
LineA=LineArray(x0,y0,x1,y1,1);
pS =TroughBars(RSI(14),1)==0;
pivotlow = Ref(pS,-1)<pS AND pS>Ref(pS,1);
yt0=SelectedValue(ValueWhen(pivotlow,RSI(14),2));
yt1=SelectedValue(ValueWhen(pivotlow,RSI(14),1));
xt0=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,2));
xt1=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,1));
LineB=LineArray(xt0,yt0,xt1,yt1,1);

_SECTION_BEGIN("DIV");
u00=LastValue(Peak(H,1,2));
u11=LastValue(Peak(H,1,1));
a00=BarCount - 1 - LastValue(PeakBars(H,1,2));
price_start1=Close[a00];
a11=BarCount - 1 - LastValue(PeakBars(H,1,1));
price_end1=Close[a11];
Line = LineArray(a00,u00,a11,u11, 0 );
LastPointSell = LineArray(a11-1,u11-1,a11,u11,0);

GG=u11<u00 AND price_end1>price_start1;
PlotShapes(shapeSmallCircle*GG ,colorDarkRed,0,Line,-2);




_SECTION_END();

_SECTION_BEGIN("DIV");
u0=LastValue(Trough(L,1,2));
u1=LastValue(Trough(L,1,1));
a0=BarCount - 1 - LastValue(TroughBars(L,1,2));
price_start=Close[a0];
a1=BarCount - 1 - LastValue(TroughBars(L,1,1));
price_end=Close[a1];
Line = LineArray(a0,u0,a1,u1, 0 );

TT=u1>u0 AND price_end<price_start;
LastPointBuy = LineArray(a1-1,u1-1,a1,u1,0);
PlotShapes(shapeSmallCircle*TT,colorCustom11,0,Line,-2);

_SECTION_END();




_SECTION_BEGIN("zzt");
para = ParamToggle("plot zz0","off,on");
cbar = Param("cbar",4,2,50,1);
per = Param("per",5,1,30,1);
zz0 = Zig(C,per);
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );
tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
pu = tr + 0.01 * abs(tr)*per;
pd = pk - 0.01 * abs(pk)*per;
zzt = IIf(C>= pu AND zz0 > zz1, 1,
IIf(C<= pd AND zz0 < zz1, -1, 0 ) );
zzt= ValueWhen( zzt != 0, zzt );
colorp2= IIf((C>O)OR(C<O),colorWhite,colorYellow);
Plot(IIf(para,zz0,Null)," ",colorWhite,styleNoLine|styleNoTitle|styleNoLabel);
pr=PeakBars(High,3)==0;
ps =TroughBars(Low,3)==0;
rf=ValueWhen(pr,High);
sf=ValueWhen(ps,Low);
rf1 = IIf(rf AND BarsSince(pr) <=cbar,rf,Null);
sf1 = IIf(sf AND BarsSince(ps ) <=cbar,sf,Null);
Plot(rf1,"",colorOrange,styleDots | styleNoLine);
Plot(sf1,"",colorOrange,styleDots | styleNoLine);
Plot(rf,"",colorLightOrange,40+16|styleNoLabel);
Plot(sf,"",colorLightOrange,40+16|styleNoLabel);
PlotShapes(IIf(pr, shapeSmallSquare,shapeNone),colorWhite,0,H,10);
PlotShapes(shapeSmallCircle*pr,colorBlack,0,H,10);
PlotShapes(IIf(ps, shapeSmallSquare,shapeNone),colorWhite,0,L,-10);
PlotShapes(shapeSmallCircle*ps,colorBlack,0,L,-10);
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("text shift", -50,-100,100,10);

PlotText("RF=" + WriteVal(rf,fraction),
SelectedValue(BarIndex()+7)-(numbars/hts),SelectedValue(rf),colorCustom12);
PlotText("SF=" + WriteVal(sf,fraction),
SelectedValue(BarIndex()+7)-(numbars/hts),SelectedValue(sf),colorYellow);
_SECTION_END();


PlotShapes(IIf(ps, shapeSmallSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(ps, shapeSmallSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(ps, shapeUpArrow, shapeNone),colorBlack, 0,L, Offset=-45);
PlotShapes(IIf(pr, shapeSmallSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(pr, shapeSmallSquare, shapeNone),colorRed, 0,H, Offset=50);
PlotShapes(IIf(pr, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

_SECTION_END();



رد مع اقتباس
قديم 09-04-2014, 02:22 AM
  المشاركه #18

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

تاريخ التسجيل: Jul 2006
المشاركات: 52
Stock112 غير متواجد حالياً  

الله يجزاك خير اخوي amm1430
بس لو توضحلي كيف اظهر العلامات الرمادية الي تحت الرسم
لانها ما ظهرت عندي بعد تركيب المعادلة



رد مع اقتباس
قديم 09-04-2014, 02:48 AM
  المشاركه #19

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

تاريخ التسجيل: Jun 2005
المشاركات: 305
جهني غير متواجد حالياً  

نعم العلامات الرمادية. الظل شكله حلو
هل هو مؤشر اخر وممكن تعرض لنا معادلته
. وفقك الله وزادك من فضله



رد مع اقتباس
قديم 16-06-2016, 11:15 PM
  المشاركه #20

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

تاريخ التسجيل: Dec 2014
المشاركات: 1,001
الكاد غير متواجد حالياً  

بارك الله فيك


رد مع اقتباس
قديم 14-01-2017, 11:52 PM
  المشاركه #21

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

تاريخ التسجيل: Sep 2014
المشاركات: 102
adel828 غير متواجد حالياً  

ياليت تعديل الخطأ بالمعادلة ولكم وافر الشكر والتقدير
_SECTION_BEGIN("MC");
Mothc=Ref(H,-1)>H AND Ref(L,-1)<L;
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(L,-1))));
TDL = LineArray(0, y0, (BarCount-1), y0);
Plot(TDL, "", colorBrightGreen,styleDashed|styleNoLabel);
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(H,-1))));
TDH= LineArray(0, y0, (BarCount-1), y0);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,H,5);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,L,-5);
Plot(TDH, "", colorRed,styleDashed|styleNoLabel);
Buy=Cross(C,TDH);
Sell=Cross(TDL,C);

numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("Text Shift", -50,-100,100,10);
PlotText("" + WriteVal(TDH,fraction),
SelectedValue(BarIndex()+0.5)-(numbars/hts),SelectedValue(TDH),colorRed);
PlotText("" + WriteVal(TDL,fraction),
SelectedValue(BarIndex()+0.5)-(numbars/hts),SelectedValue(TDL),colorBrightGreen);
_SECTION_END();







_SECTION_BEGIN("zzt");
para = ParamToggle("plot zz0","off,on");
cbar = Param("cbar",4,2,50,1);
per = Param("per",5,1,30,1);
zz0 = Zig(C,per);
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );
tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
pu = tr + 0.01 * abs(tr)*per;
pd = pk - 0.01 * abs(pk)*per;
zzt = IIf(C>= pu AND zz0 > zz1, 1,
IIf(C<= pd AND zz0 < zz1, -1, 0 ) );
zzt= ValueWhen( zzt != 0, zzt );
colorp2= IIf((C>O)OR(C<O),colorWhite,colorYellow);
Plot(IIf(para,zz0,Null)," ",colorWhite,styleNoLine|styleNoTitle|styleNoLabel);
pr=PeakBars(High,3)==0;
ps =TroughBars(Low,3)==0;
rf=ValueWhen(pr,High);
sf=ValueWhen(ps,Low);
rf1 = IIf(rf AND BarsSince(pr) <=cbar,rf,Null);
sf1 = IIf(sf AND BarsSince(ps ) <=cbar,sf,Null);
Plot(rf1,"",colorOrange,styleDots | styleNoLine);
Plot(sf1,"",colorOrange,styleDots | styleNoLine);
Plot(rf,"",colorLightOrange,40+16|styleNoLabel);
Plot(sf,"",colorLightOrange,40+16|styleNoLabel);
PlotShapes(IIf(pr, shapeSmallSquare,shapeNone),colorWhite,0,H,10);
PlotShapes(shapeSmallCircle*pr,colorBlack,0,H,10);
PlotShapes(IIf(ps, shapeSmallSquare,shapeNone),colorWhite,0,L,-10);
PlotShapes(shapeSmallCircle*ps,colorBlack,0,L,-10);
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("text shift", -50,-100,100,10);

PlotText("RF=" + WriteVal(rf,fraction),
SelectedValue(BarIndex()+7)-(numbars/hts),SelectedValue(rf),colorCustom12);
PlotText("SF=" + WriteVal(sf,fraction),
SelectedValue(BarIndex()+7)-(numbars/hts),SelectedValue(sf),colorYellow);
_SECTION_END();


PlotShapes(IIf(ps, shapeSmallSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(ps, shapeSmallSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(ps, shapeUpArrow, shapeNone),colorBlack, 0,L, Offset=-45);
PlotShapes(IIf(pr, shapeSmallSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(pr, shapeSmallSquare, shapeNone),colorRed, 0,H, Offset=50);
PlotShapes(IIf(pr, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

_SECTION_END();



_SECTION_BEGIN("META SIGNAL ");
Buy=C>(Ref(HHV(H,1),-2)*(1.005));
Sell=C<(Ref(LLV(L,1),-2)*(1.005));
A=(BarsSince(Buy)<BarsSince(Sell));
B=(BarsSince(Buy)>BarsSince(Sell));
A= ExRem(Buy,Sell);
B = ExRem(Sell, Buy);


_SECTION_END();



_SECTION_BEGIN(" vol 8 9");
Buy=Cross(V,MA(V,10)*2)AND C>O;
Sell=Cross(V,MA(V,10)*2)AND C<O;


_SECTION_BEGIN("Bullish Hook & Bearish Hook");
q= Cross(C, EMA(C,5))AND RSI(14)>30;
t= Cross(EMA(C,5), C)AND RSI(14)<70;



_SECTION_BEGIN("MACD");
r1 = Param("Fast avg", 10, 2, 200, 1);
r2 = Param("Slow avg", 22, 2, 200, 1);
r3 = Param("Signal avg", 5, 2, 200, 1);

m1 = MACD(r1,r2);
s1 = Signal(r1,r2,r3);

_SECTION_END();
Hist=m1-s1;
Buy= Cross(Hist,0);
Sell = Cross( 0, Hist );


_SECTION_BEGIN("Signals");

//Zero crossover up
j1 = Cross(m1,s1)AND m1>0;
PlotShapes(IIf(j1,shapeDigit1 ,Null),colorBlue,0,L,Offset=-45);
PlotShapes(IIf(j1,shapeHollowUpArrow,Null),colorBlue,0,L,Offset=-55);

// crossover above zero
j2 = Cross(m1,s1)AND m1<0 ;

PlotShapes(IIf(j2,shapeDigit2 ,Null),colorDarkBlue,0,L,Offset=-45);
PlotShapes(IIf(j2,shapeHollowUpArrow,Null),colorDarkBlue,0,L,Offset=-55);
//Zero crossover down
j3 = Cross(s1,m1) AND m1>0;

PlotShapes(IIf(j3,shapeDigit4 ,Null),colorCustom12,0,H,Offset=65);
PlotShapes(IIf(j3,shapeHollowDownArrow,Null),colorCustom12,0,H,Offset=-75);
Plot(J3,"",colorViolet,styleHistogram|styleDashed|styleOwnScale|styleNoLabel,0 ,1,0,0);

if (SelectedValue(j3)==1)Say("SELL mackd");

_SECTION_BEGIN("Patterns Wave");
Change = Param("Wave Period",5,0,100,1);



procedure PlotShapeAt( x, y, shape, shift )
{
PlotShapes( IIf( BarIndex() == x, shape, 0 ), colorWhite, 0, y, shift );
}

bi = BarIndex();
sbi = SelectedValue( bi );
GraphXSpace = 2;

upshift = 90;
if( SelectedValue( PeakBars( C, Change ) < TroughBars( C, Change ) ) )
{
pt1 = PeakBars( C, Change, 1 ) == 0 ;
pt2 = TroughBars( C, Change, 1 ) == 0 ;
}
else
{
pt1 = TroughBars( C, Change, 1 ) == 0 ;
pt2 = PeakBars( C, Change, 1 ) == 0 ;
upshift = -upshift;
}
bpt1 = SelectedValue( ValueWhen( pt1, bi ) );
bpt2 = SelectedValue( ValueWhen( pt2, bi ) );
bpt3 = SelectedValue( ValueWhen( pt1, bi, 2 ) );
bpt4 = SelectedValue( ValueWhen( pt2, bi, 2 ) );
bpt5 = SelectedValue( ValueWhen( pt1, bi, 3 ) );
bpt6 = SelectedValue( ValueWhen( pt2, bi, 3 ) );
PlotShapeAt( bpt1, C, shapeDigit5, upshift );
PlotShapeAt( bpt2, C, shapeDigit4, -upshift );
PlotShapeAt( bpt3, C, shapeDigit3, upshift );
PlotShapeAt( bpt4, C, shapeDigit2, -upshift );
PlotShapeAt( bpt5, C, shapeDigit1, upshift );
_SECTION_END();




_SECTION_BEGIN("trend");

SetChartOptions(0,chartShowArrows|chartShowDates);
ScanLookBack = Param("Scan Lookback", 2, 1, 25 );
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);


_SECTION_END();
_SECTION_BEGIN("INIT");

SetChartOptions(0,chartShowArrows|chartShowDates);
ScanLookBack = Param("Scan Lookback", 2, 1, 25 );
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);





_SECTION_BEGIN("wma89");
P = ParamField("Field");
Type = ParamList("Type", "Weighted,Simple,Exponential,Double Exponential,Tripple Exponential,Wilders");
Periods89 = Param("Periods89", 89, 2, 300 );
Displacement2 = Param("Displacement2", 2, -50, 50 );
bbb= WMA( P, Periods89 );
colr = IIf(Avg >= bbb,colorGreen,colorRed);

Buy=Cover=Cross(Avg,bbb);
Sell=Short=Cross(bbb,Avg);
MYcolor = IIf( EMA(C,13)>EMA(EMA(C,13),9) AND C>Peak(C,2,1), colorGreen, IIf(EMA(C,13)>EMA(EMA(C,13),9) AND C<Peak(C,2,1),colorBlue, colorBrown ));
_SECTION_BEGIN( "Zig Hi Lo" );
// ZIG hilo version by Joris Schuller
// from ZigZag Hi Lo.afl : simplified version
pltzig = ParamToggle( "Plot ZigHL ", "Off|On", 1 );
change = Param( "ZigZag-HL %", 3, 0.01, 3, 0.01 );
za2 = 0;

pk = PeakBars( H, change ) == 0;
tr = TroughBars( L, change ) == 0;
pkbars = PeakBars( H, change );
trbars = TroughBars( L, change );
zHi = Zig( H, change );
zLo = Zig( L, change );
HLAvg = ( zHi + zLo ) / 2;
zp2 = IIf( pk, zHi, IIf( tr, zLo, IIf( pkbars <= trbars, L, H ) ) );//Modified zp to reduce occasional erroneous Pk/Tr connections at very small ZigPerc values
za2 = Zig( zp2, change );

if ( pltzig == 1 )
{
}

_SECTION_END();
_SECTION_BEGIN( "123 Pattern" );

procedure
PlotShape( x, y, shape, shift )
{
PlotShapes( IIf( BarIndex() == x, shape, 0 ), colorOrange, 0, y, shift );
}

bi = BarIndex();
sbi = SelectedValue( bi );
upshift = Param( "upshift ", 30, 1, 100, 1 );

if ( SelectedValue( PeakBars( za2 , Change ) < TroughBars( za2 , Change ) ) )
{
pt3 = PeakBars( za2 , Change, 1 ) == 0 ;
pt2 = TroughBars( za2 , Change, 1 ) == 0 ;
ydigit1 = H;
ydigit2 = L;
ydigit3 = H;
}
else
{
pt3 = TroughBars( za2 , change, 1 ) == 0 ;
pt2 = PeakBars( za2 , change, 1 ) == 0 ;
ydigit1 = L;
ydigit2 = H;
ydigit3 = L;
upshift = -upshift;
}

bpt1 = SelectedValue( ValueWhen( pt3, bi ) ); // x axis

bpt2 = SelectedValue( ValueWhen( pt2, bi ) );
bpt3 = SelectedValue( ValueWhen( pt3, bi , 2 ) );

pltdigit = ParamToggle( "Plot 123 Digit ", "Off|On", 1 );

if ( pltdigit == 1 )
{
PlotShape( bpt1, ydigit3 , shapeDigit3, upshift );
PlotShape( bpt2, ydigit2 , shapeDigit2, -upshift );
PlotShape( bpt3, ydigit1 , shapeDigit1, upshift );
}

_SECTION_END();

_SECTION_BEGIN("MC");
Mothc=Ref(H,-1)>H AND Ref(L,-1)<L;
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(L,-1))));
TDL = LineArray(0, y0, (BarCount-1), y0);
Plot(TDL, "", colorBrightGreen,styleDashed|styleNoLabel);
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(H,-1))));
TDH= LineArray(0, y0, (BarCount-1), y0);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,H,5);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,L,-5);
Plot(TDH, "", colorRed,styleDashed|styleNoLabel);
Buy=Cross(C,TDH);
Sell=Cross(TDL,C);

numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("Text Shift", -50,-100,100,10);
PlotText("" + WriteVal(TDH,fraction),
SelectedValue(BarIndex()+0.5)-(numbars/hts),SelectedValue(TDH),colorRed);
PlotText("" + WriteVal(TDL,fraction),
SelectedValue(BarIndex()+0.5)-(numbars/hts),SelectedValue(TDL),colorBrightGreen);
_SECTION_END();



_SECTION_END();

_SECTION_END();_SECTION_END();
_SECTION_BEGIN("Name");
GfxSetOverlayMode(1);
pxh= Status("pxHeight"); pxw=Status("pxWidth");
GfxSelectFont("Tahoma",pxh/30);
GfxSetTextColor(colorWhite);
GfxSetTextAlign(6); GfxSetBkMode(0);
GfxTextOut(FullName(),pxw/2,pxh/12);
GfxSelectFont("Tahoma",pxh/15);
GfxTextOut("",pxw/2,pxh/3);
_SECTION_END();


;

_SECTION_BEGIN("companysympole");

_SECTION_BEGIN("companyclos");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorWhite);
GfxTextOut("C="+C+" ",580,1);
}
_SECTION_END();

_SECTION_BEGIN("companyhigh");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorCustom13);
GfxTextOut("H="+H+" ",480,1);
}
_SECTION_END();

_SECTION_BEGIN("companyopen");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorWhite);
GfxTextOut("O="+O+" ",380,1);
}
_SECTION_END();

_SECTION_BEGIN("companylow");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorYellow);
GfxTextOut("L="+L+" ",280,1);
}
_SECTION_END();


_SECTION_BEGIN("CNcP");
Cd1=-(O-C)/(H-L)*100;
Cd=Prec((Cd1),2);
ColorE=IIf(Cd>=68,colorYellow,IIf(Cd<=-68,colorRed,colorCustom12));
_SECTION_END();
_SECTION_BEGIN("Price");
BarColor = IIf((Cd>=68)OR (Cd<=-68),colorYellow,colorCustom12);
Plot(C, "", BarColor, styleNoTitle| styleThick | styleCandle|styleNoLabel);
Plot(C, "",styleCandle, colorBlack, styleThick);
_SECTION_END();

_SECTION_BEGIN("");
r= MACD(10, 22);
dd= Signal(10,22,5);
Hist=r-dd;
BuyHist= Cross(Hist,0);
SellHist = Cross( 0, Hist );



_SECTION_BEGIN("MA(20)");

BarColor = IIf((C>MA(C,20)),colorWhite,colorRed);
Plot(MA(C,20),"",BarColor,styleThick);
BuyMA= Cross(C,MA(C,20));
SellMA= Cross( MA(C,20), C );
_SECTION_END();


_SECTION_BEGIN("Magnified Price");
FS=Param("Font Size",15,11,100,1);
GfxSelectFont("Arial", FS, 700, True );
GfxSetBkMode(ColorRGB(255,170,188));
GfxSetTextColor( ParamColor("Color",colorYellow) );
Hor=Param("Horizontal Position",390,2,1,2);
Ver=Param("Vertical Position",1,1,1,1);
GfxTextOut("C="+C,Hor , Ver+55 );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);

GfxSelectFont("Arial", 12, 700, True );
GfxSetBkMode( colorYellow );
GfxSetTextColor(ParamColor("Color",colorBlue) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+80 );

_SECTION_END();


_SECTION_BEGIN("Nd");
Nd=((C)-(O))/(L)*10000;
Filter=Close;
AddColumn(Nd , "Nd",1.2,colorBrown);

_SECTION_BEGIN(" Nd");
{ GfxSelectFont("Arial",12, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorCustom12);
GfxTextOut("Nd="+WriteVal(Nd,format=1.2)+"% ",750,1);
GfxSetTextColor(colorWhite);

}
_SECTION_END();

_SECTION_BEGIN("CNcP");
Cd1=-(O-C)/(H-L)*100;
Cd=Prec((Cd1),2);
Filter=Close;
AddColumn(Cd , "Cd",1.2,colorOrange);
_SECTION_END();


_SECTION_BEGIN(" Cd");
{ GfxSelectFont("Arial",13, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorGold);
GfxTextOut("Cd="+WriteVal(Cd,format=1.2)+"% ",870,1);
}
_SECTION_END();






_SECTION_BEGIN(" ZigZagTrend ");
array = Close;
amount = Param("Amount", 5, 1, 50, 0.5 );
zz0 = Zig( array, amount );
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );
tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
PU = tr + 0.01 * abs(tr)*amount;
PD = pk - 0.01 * abs(pk)*amount;
ZZT = IIf( array >= PU AND zz0 > zz1, 1,
IIf( array <= PD AND zz0 < zz1, -1, 0 ) );
ZZT = ValueWhen( ZZT != 0, ZZT );
Com=IIf(ZZT>0,colorBlue,IIf(ZZT<0,colorRed,colorBlack));

_SECTION_BEGIN("Font Color");
function GfxConvertBarToPixelX(Bar)
{
lvb = Status("lastvisiblebar"); fvb = Status("firstvisiblebar");
pxchartleft = Status("pxchartleft"); pxchartwidth = Status("pxchartwidth");
return pxchartleft + Bar * pxchartwidth / (Lvb-fvb + 1);
}
procedure MultiRibbon(RibbonColor, Position, Label)
{
LineColor =colorWhite;
Position =2* Position;
x2 = Status("pxchartright");
y2 = Status("pxchartbottom");
RibbonColor =IIf(GfxConvertBarToPixelX(BarIndex()-Status("firstvisiblebarindex")) > y2/1.5 *
(2/100)*10,RibbonColor, colorWhite);
Plot(0, "",LineColor, styleOwnScale|styleNoLabel,0,100);
Plot(Position, "",LineColor,styleOwnScale| styleNoLabel,0,100);
Plot(Position, "",RibbonColor,styleArea|styleOwnScale|styleNoLabel, 0,100);

GfxSelectFont("Arial", y2/1 * (2.7/180),200);
GfxDrawText(Label,8, y2 *1.006-(y2 * Position/100) , y2/1.6*
(2/100)*10,y2,2+32+256);
GfxSetTextColor(colorBlue);
}
multiribbon(COM,1, "Trend");


Buy=Cross(ZZT,0);
Sell=Cross(0,ZZT);
PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone) ,colorBlue,0,L,-15);
PlotShapes(IIf(Sell,shapeSmallDownTriangle, shapeNone),colorRed,0,H,-15);

_SECTION_BEGIN("Zig_Zag_");

PercentChange = 4;
mystartbar = SelectedValue(BarIndex()); // FOR GRAPHING

mystartbardate = LastValue(ValueWhen(mystartbar == BarIndex(), DateNum(),1));

InitialValue = LastValue(ValueWhen(mystartbardate == DateNum(), C , 1 ) ) ;


ZZ = Zig(C,LastValue(PercentChange)) ;
PivotLow = Ref(IIf(Ref(ROC(ZZ,1),-1) < 0 AND ROC(ZZ,1) > 0, 1,Null),1);
PivotHigh = Ref(IIf(Ref(ROC(ZZ,1),-1) > 0 AND ROC(ZZ,1) < 0, 1,Null),1);

PlotShapes(IIf(PivotLow, shapeDigit1, shapeNone),colorYellow, 0,L, Offset=-32);

PlotShapes(IIf(PivotHigh, shapeDigit1, shapeNone),colorYellow, 0,H, Offset=32);



_SECTION_BEGIN("ZigZag");
{ GfxSelectFont("Arial",13, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorGold);
GfxTextOut(" ZigZag="+WriteVal(ZZ,format=1.2)+"",75,20);
}
_SECTION_END();

_SECTION_BEGIN("MACD");
ml = MACD(6, 13);
dd= Signal(6,13,5);
Hist=ml-dd;
col_hist= IIf(Hist > BBandTop( Hist, 5, 0.5 ),colorLightBlue,IIf(Hist < BBandBot( Hist, 5, 0.5 ),colorBlue,colorRed));
pr=PeakBars(C,5)==0;
ps =TroughBars(C,5)==0;
PlotShapes(IIf(ps,shapeDigit2 ,Null),colorBlue,0,L,-45);
PlotShapes(IIf(pr,shapeDigit2 ,Null),colorBlue,0,H,45);




_SECTION_BEGIN("Fibonacci And Gann Projections");
Change = 5;
GannIncrement = 0.0625;
{
}
procedure PlotBlueDot( x, y )
{


for( i = -2; i <= 2; i++ )
{
if( i != 0 )
{
yGann = ( sqrt( y ) + i * GannIncrement ) ^ 2;

}
}
}
bi = BarIndex();
sbi = SelectedValue( bi );
GraphXSpace = 2;

upshift =65;
if( SelectedValue( PeakBars( C, Change ) < TroughBars( C, Change ) ) )
{
pt1 = PeakBars( C, Change, 1 ) == 0 ;
pt2 = TroughBars( C, Change, 1 ) == 0 ;
}
else
{
pt1 = TroughBars( C, Change, 1 ) == 0 ;
pt2 = PeakBars( C, Change, 1 ) == 0 ;
upshift = -upshift;
}
bpt1 = SelectedValue( ValueWhen( pt1, bi ) );
bpt2 = SelectedValue( ValueWhen( pt2, bi ) );
bpt3 = SelectedValue( ValueWhen( pt1, bi, 2 ) );
bpt4 = SelectedValue( ValueWhen( pt2, bi, 2 ) );
bpt5 = SelectedValue( ValueWhen( pt1, bi, 3 ) );
bpt6 = SelectedValue( ValueWhen( pt2, bi, 3 ) );
PlotShapeAt( bpt1, C, shapeDigit1, upshift );
PlotShapeAt( bpt2, C, shapeDigit2, -upshift );
PlotShapeAt( bpt3, C, shapeDigit3, upshift );
PlotShapeAt( bpt4, C, shapeDigit4, -upshift );
PlotShapeAt( bpt5, C, shapeDigit5, upshift );
PlotShapeAt( bpt6, C, shapeDigit6, -upshift );
Level = SelectedValue( ValueWhen( pt1, C ) );
PlotBlueDot( round( bpt1 + 1.618 * ( bpt1 - bpt2 ) ), Level );
PlotBlueDot( round( bpt1 + 0.382 * ( bpt1 - bpt2 ) ), Level );
PlotBlueDot( round( bpt1 + 0.5 * ( bpt2 - bpt3 ) ), Level );
PlotBlueDot( round( bpt1 + 1.732 * ( bpt2 - bpt3 ) ), Level );
PlotBlueDot( round( bpt1 + 0.618 * ( bpt4 - bpt5 ) ), Level );
PlotBlueDot( round( bpt1 + 2 * ( bpt4 - bpt5 ) ), Level );
PlotBlueDot( round( bpt2 + 0.6707 * ( bpt4 - bpt2 ) ), Level );
PlotBlueDot( round( bpt2 + 2.618 * ( bpt4 - bpt2 ) ), Level );
PlotBlueDot( round( bpt2 + 1 * ( bpt6 - bpt2 ) ), Level );
PlotBlueDot( round( bpt2 + 3 * ( bpt6 - bpt2 ) ), Level );


_SECTION_END();











_SECTION_BEGIN("zzt");
para = ParamToggle("plot zz0","off,on");
cbar = Param("cbar",10,2,50,1);
per = Param("per",5,1,30,1);
zz0 = Zig(C,per);
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );
tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
pu = tr + 0.01 * abs(tr)*per;
pd = pk - 0.01 * abs(pk)*per;
zzt = IIf(C>= pu AND zz0 > zz1, 1,
IIf(C<= pd AND zz0 < zz1, -1, 0 ) );
zzt= ValueWhen( zzt != 0, zzt );
colorp2= IIf((C>O)OR(C<O),colorWhite,colorYellow);
Plot(IIf(para,zz0,Null)," ",colorWhite,styleLine|styleNoTitle);
pr=PeakBars(High,5)==0;
ps =TroughBars(Low,5)==0;
rf=ValueWhen(pr,High);
sf=ValueWhen(ps,Low);
rf1 = IIf(rf AND BarsSince(pr) <=cbar,rf,Null);
sf1 = IIf(sf AND BarsSince(ps ) <=cbar,sf,Null);
Plot(rf1,"",colorRed,styleDots | styleNoLine|styleNoLabel);
Plot(sf1,"",colorBrightGreen,styleDots | styleNoLine|styleNoLabel);



_SECTION_END();
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("text shift", -50,-100,100,10);
PlotText("" + WriteVal(rf,fraction),
SelectedValue(BarIndex()+6)-(numbars/hts),SelectedValue(rf),colorWhite,colorRed);
PlotText("" + WriteVal(sf,fraction),
SelectedValue(BarIndex()+6)-(numbars/hts),SelectedValue(sf),colorWhite,colorGreen);
_SECTION_END();




Plot( Open, "open", 0, stylehidden| styleNoTitle );
Plot(Close, "close", 0, stylehidden| styleNoTitle );
Plot(High, "high", 0, stylehidden| styleNoTitle );
Plot(Low, "low", 0, stylehidden| styleNoTitle );

numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("text shift", -50,-100,100,10);

_SECTION_END();






_SECTION_BEGIN("MotheCandle");
Mothc=Ref(H,-1)>H AND Ref(L,-1)<L;
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(L,-1))));
TDL = LineArray(0, y0, (BarCount-1), y0);
Plot(TDL, "", colorGold,styleDashed|styleNoLabel);
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(H,-1))));
TDH= LineArray(0, y0, (BarCount-1), y0);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)), colorGold,0,H,5);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,L,-5);
Plot(TDH, "", colorCustom12,styleDashed|styleNoLabel);
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("Text Shift", -50,-100,100,10);

PlotText("" + WriteVal(TDH,fraction),
SelectedValue(BarIndex())-(numbars/hts),SelectedValue(TDH),colorCustom12);
PlotText("" + WriteVal(TDL,fraction),
SelectedValue(BarIndex())-(numbars/hts),SelectedValue(TDL),colorGold);
_SECTION_END();







_SECTION_BEGIN("AuthorName");
k = (GetPerformanceCounter()/100)%100;
printf("GetPerformance Counter %g",k);
GfxSelectFont("jokerman", 12,800);
GfxSetBkMode(1);
GfxSetTextColor(colorGold);
GfxTextOut("MotherCandle",450,20);
RequestTimedRefresh(10);
_SECTION_END();


_SECTION_BEGIN("WMA 50");
slope = Param("slope",2,2,100,1);
Color20= IIf(LinRegSlope(WMA(C,50),slope)<0,colorCustom13,colorCustom13);
event1= LinRegSlope(WMA(C,50),slope)<1;
Plot( WMA( C,50), "",Color20,styleNoLine|styleNoLabel);

_SECTION_END();
_SECTION_BEGIN("WMA 50");
{ GfxSelectFont("Bernard MT Condensed",12, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorCustom13);
GfxTextOut("WMA50="+WMA( C,50),250,20);
}
_SECTION_END();




_SECTION_END();




_SECTION_BEGIN("Pivot_Finder");
/* **********************************

Code to automatically identify pivots

********************************** */

// -- what will be our lookback range for the hh and ll?
farback=Param("How Far back to go",100,0,5000,10);
nBars = Param("Number of bars", 8, 5, 40);


// -- Create 0-initialized arrays the size of barcount

aHPivs = H - H;

aLPivs = L - L;

// -- More for use, not necessary for basic plotting

aHPivHighs = H - H;

aLPivLows = L - L;

aHPivIdxs = H - H;

aLPivIdxs = L - L;

nHPivs = 0;

nLPivs = 0;

lastHPIdx = 0;

lastLPIdx = 0;

lastHPH = 0;

lastLPL = 0;

curPivBarIdx = 0;

// -- looking back from the current bar, how many bars

// back were the hhv and llv values of the previous

// n bars, etc.?

aHHVBars = HHVBars(H, nBars);

aLLVBars = LLVBars(L, nBars);

aHHV = HHV(H, nBars);

aLLV = LLV(L, nBars);

// -- Would like to set this up so pivots are calculated back from

// last visible bar to make it easy to "go back" and see the pivots

// this code would find. However, the first instance of

// _Trace output will show a value of 0

aVisBars = Status("barvisible");

nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));

_TRACE("Last visible bar: " + nLastVisBar);

// -- Initialize value of curTrend

curBar = (BarCount-1);

curTrend = "";

if (aLLVBars[curBar] <

aHHVBars[curBar]) {

curTrend = "D";

}

else {

curTrend = "U";

}

// -- Loop through bars. Search for

// entirely array-based approach

// in version

for (i=0; i<farback; i++) {

curBar = (BarCount - 1) - i;

// -- Have we identified a pivot? If trend is down...

if (aLLVBars[curBar] < aHHVBars[curBar]) {

// ... and had been up, this is a trend change

if (curTrend == "U") {

curTrend = "D";

// -- Capture pivot information

curPivBarIdx = curBar - aLLVBars[curBar];

aLPivs[curPivBarIdx] = 1;

aLPivLows[nLPivs] = L[curPivBarIdx];

aLPivIdxs[nLPivs] = curPivBarIdx;

nLPivs++;

}

// -- or current trend is up

} else {

if (curTrend == "D") {

curTrend = "U";

curPivBarIdx = curBar - aHHVBars[curBar];

aHPivs[curPivBarIdx] = 1;

aHPivHighs[nHPivs] = H[curPivBarIdx];

aHPivIdxs[nHPivs] = curPivBarIdx;

nHPivs++;

}

// -- If curTrend is up...else...

}

// -- loop through bars

}

// -- Basic attempt to add a pivot this logic may have missed

// -- OK, now I want to look at last two pivots. If the most

// recent low pivot is after the last high, I could

// still have a high pivot that I didn't catch

// -- Start at last bar

curBar = (BarCount-1);

candIdx = 0;

candPrc = 0;

lastLPIdx = aLPivIdxs[0];

lastLPL = aLPivLows[0];

lastHPIdx = aHPivIdxs[0];

lastHPH = aHPivHighs[0];

if (lastLPIdx > lastHPIdx) {

// -- Bar and price info for candidate pivot

candIdx = curBar - aHHVBars[curBar];

candPrc = aHHV[curBar];

if (

lastHPH < candPrc AND

candIdx > lastLPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aHPivs[candIdx] = 1;

// ...and then rearrange s in the

// pivot information arrays

for (j=0; j<nHPivs; j++) {

aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-

(j+1)];

aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];

}

aHPivHighs[0] = candPrc ;

aHPivIdxs[0] = candIdx;

nHPivs++;

}

} else {


// -- Bar and price info for candidate pivot

candIdx = curBar - aLLVBars[curBar];

candPrc = aLLV[curBar];

if (

lastLPL > candPrc AND

candIdx > lastHPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aLPivs[candIdx] = 1;

// ...and then rearrange s in the

// pivot information arrays

for (j=0; j<nLPivs; j++) {

aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];

aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];

}

aLPivLows[0] = candPrc;

aLPivIdxs[0] = candIdx;

nLPivs++;

}

}

// -- Dump inventory of high pivots for debugging



for (k=0; k<nHPivs; k++) {

_TRACE("High pivot no. " + k

+ " at barindex: " + aHPivIdxs[k] + ", "

+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],

DateTime(), 1), formatDateTime)

+ ", " + aHPivHighs[k]);

}

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

// -- OK, let's plot the pivots using arrows

PlotShapes(IIf(aHPivs==1, shapeSmallDownTriangle, shapeNone), colorRed, 0, High, Offset=-14);
PlotShapes(IIf(aLPivs==1, shapeSmallUpTriangle , shapeNone), colorBrightGreen, 0, Low, Offset=-13);

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


/* **********************************

Code to automatically identify pivots

********************************** */
// -- what will be our lookback range for the hh and ll?
farback=Param("How Far back to go",500,12,30,1);
nBars = Param("Number of bars", 8, 1, 30, 1);
// -- Create 0-initialized arrays the size of barcount
aHPivs = H - H;
aLPivs = L - L;
// -- More for use, not necessary for basic plotting
aHPivHighs = H - H;
aLPivLows = L - L;
aHPivIdxs = H - H;
aLPivIdxs = L - L;
nHPivs = 0;
nLPivs = 0;
lastHPIdx = 0;
lastLPIdx = 0;
lastHPH = 0;
lastLPL = 0;
curPivBarIdx = 0;
// -- looking back from the current bar, how many bars
// back were the hhv and llv values of the previous
// n bars, etc.?
aHHVBars = HHVBars(H, nBars);
aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);
aLLV = LLV(L, nBars);
// -- Would like to set this up so pivots are calculated back from
// last visible bar to make it easy to "go back" and see the pivots
// this code would find. However, the first instance of
// _Trace output will show a value of 0
aVisBars = Status("barvisible");
nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
_TRACE("Last visible bar: " + nLastVisBar);
// -- Initialize value of curTrend
curBar = (BarCount-1);
curTrend = "";
if (aLLVBars[curBar] <
aHHVBars[curBar]) {
curTrend = "D";
}
else {
curTrend = "U";
}
// -- Loop through bars. Search for
// entirely array-based approach
// in version
for (i=0; i<farback; i++) {
curBar = (BarCount - 1) - i;
// -- Have we identified a pivot? If trend is down...
if (aLLVBars[curBar] < aHHVBars[curBar]) {
// ... and had been up, this is a trend change
if (curTrend == "U") {
curTrend = "D";
// -- Capture pivot information
curPivBarIdx = curBar - aLLVBars[curBar];
aLPivs[curPivBarIdx] = 1;
aLPivLows[nLPivs] = L[curPivBarIdx];
aLPivIdxs[nLPivs] = curPivBarIdx;
nLPivs++;
}
// -- or current trend is up
} else {
if (curTrend == "D") {
curTrend = "U";
curPivBarIdx = curBar - aHHVBars[curBar];
aHPivs[curPivBarIdx] = 1;
aHPivHighs[nHPivs] = H[curPivBarIdx];
aHPivIdxs[nHPivs] = curPivBarIdx;
nHPivs++;
}
// -- If curTrend is up...else...
}
// -- loop through bars
}
// -- Basic attempt to add a pivot this logic may have missed
// -- OK, now I want to look at last two pivots. If the most
// recent low pivot is after the last high, I could
// still have a high pivot that I didn't catch
// -- Start at last bar
curBar = (BarCount-1);
candIdx = 0;
candPrc = 0;
lastLPIdx = aLPivIdxs[0];
lastLPL = aLPivLows[0];
lastHPIdx = aHPivIdxs[0];
lastHPH = aHPivHighs[0];
if (lastLPIdx > lastHPIdx) {
// -- Bar and price info for candidate pivot
candIdx = curBar - aHHVBars[curBar];
candPrc = aHHV[curBar];
if (
lastHPH < candPrc AND
candIdx > lastLPIdx AND
candIdx < curBar) {
// -- OK, we'll add this as a pivot...
aHPivs[candIdx] = 1;
// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nHPivs; j++) {
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-
(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];
}
aHPivHighs[0] = candPrc ;
aHPivIdxs[0] = candIdx;
nHPivs++;
}
} else {
// -- Bar and price info for candidate pivot
candIdx = curBar - aLLVBars[curBar];
candPrc = aLLV[curBar];
if (
lastLPL > candPrc AND
candIdx > lastHPIdx AND
candIdx < curBar) {
// -- OK, we'll add this as a pivot...
aLPivs[candIdx] = 1;
// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nLPivs; j++) {
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
}
aLPivLows[0] = candPrc;
aLPivIdxs[0] = candIdx;
nLPivs++;
}
}
// -- Dump inventory of high pivots for debugging
/*
for (k=0; k<nHPivs; k++) {
_TRACE("High pivot no. " + k
+ " at barindex: " + aHPivIdxs[k] + ", "
+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],
DateTime(), 1), formatDateTime)
+ ", " + aHPivHighs[k]);
}
*/
// -- OK, let's plot the pivots using arrows
PlotShapes(IIf(aHPivs==1, shapeHollowSmallDownTriangle, shapeNone), colorOrange, 0, High, Offset=-25);
PlotShapes(IIf(aLPivs==1, shapeHollowSmallUpTriangle , shapeNone), colorWhite, 0, Low, Offset=-23);

Sell = aHPivs == 1 ;
Buy = aLPivs == 1 ;
Filter=Buy OR Sell;
Sell=ExRem(Sell,Buy);
Buy=ExRem(Buy,Sell);





_SECTION_END();










_SECTION_BEGIN("td fractl line");
strength = Param("strength",1,1,15,1);
pr=PeakBars(RSI(14),strength)==0;

_SECTION_END();
_SECTION_BEGIN("td fractl line");
ps =TroughBars(RSI(14),strength)==0;

_SECTION_END();
_SECTION_BEGIN("price risistance");
rt=SelectedValue(ValueWhen(pr,H));
st=SelectedValue(ValueWhen(ps,L));


_SECTION_BEGIN("td fractl line");
pr=PeakBars(RSI(14),strength)==0;
pivothigh = Ref(pr,-1)<pr AND pr>Ref(pr,1);
y0=SelectedValue(ValueWhen(pivothigh,H,2));
y1=SelectedValue(ValueWhen(pivothigh,H,1));
x0=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,2));
x1=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,1));
linea=LineArray(x0,y0,x1,y1,1);

_SECTION_END();
_SECTION_BEGIN("td fractl line");
ps =TroughBars(RSI(14),strength)==0;
pivotlow = Ref(ps,-1)<ps AND ps>Ref(ps,1);
yt0=SelectedValue(ValueWhen(pivotlow,L,2));
yt1=SelectedValue(ValueWhen(pivotlow,L,1));
xt0=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,2));
xt1=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,1));
lineb=LineArray(xt0,yt0,xt1,yt1,1);



_SECTION_BEGIN("V");
_SECTION_END();


_SECTION_BEGIN("EMA Time Frame");
r= RSI(14);
pR=PeakBars(RSI(14),1)==0;
pivothigh = Ref(pR,-1)<pR AND pR>Ref(pR,1);
y0=SelectedValue(ValueWhen(pivothigh,RSI(14),2));
y1=SelectedValue(ValueWhen(pivothigh,RSI(14),1));
x0=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,2));
x1=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,1));
LineA=LineArray(x0,y0,x1,y1,1);
pS =TroughBars(RSI(14),1)==0;
pivotlow = Ref(pS,-1)<pS AND pS>Ref(pS,1);
yt0=SelectedValue(ValueWhen(pivotlow,RSI(14),2));
yt1=SelectedValue(ValueWhen(pivotlow,RSI(14),1));
xt0=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,2));
xt1=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,1));
LineB=LineArray(xt0,yt0,xt1,yt1,1);

_SECTION_BEGIN("DIV");
u00=LastValue(Peak(H,1,2));
u11=LastValue(Peak(H,1,1));
a00=BarCount - 1 - LastValue(PeakBars(H,1,2));
price_start1=Close[a00];
a11=BarCount - 1 - LastValue(PeakBars(H,1,1));
price_end1=Close[a11];
Line = LineArray(a00,u00,a11,u11, 0 );
LastPointSell = LineArray(a11-1,u11-1,a11,u11,0);

GG=u11<u00 AND price_end1>price_start1;
PlotShapes(shapeSmallCircle*GG ,colorDarkRed,0,Line,-2);




_SECTION_END();

_SECTION_BEGIN("DIV");
u0=LastValue(Trough(L,1,2));
u1=LastValue(Trough(L,1,1));
a0=BarCount - 1 - LastValue(TroughBars(L,1,2));
price_start=Close[a0];
a1=BarCount - 1 - LastValue(TroughBars(L,1,1));
price_end=Close[a1];
Line = LineArray(a0,u0,a1,u1, 0 );

TT=u1>u0 AND price_end<price_start;
LastPointBuy = LineArray(a1-1,u1-1,a1,u1,0);
PlotShapes(shapeSmallCircle*TT,colorCustom11,0,Line,-2);


_SECTION_END();

SetChartBkColor( ParamColor("background",colorDarkTeal));


SetChartOptions(0, chartShowDates | chartWrapTitle);

Type = ParamList("Average Type", "Wilders");
P = Param("Averaging Period", 20, 3, 100,1);
Q = Param("%Change", 1, 0.1, 10, 0.1);
BP = Param("BB Period", 20, 3, 100);
BW = Param("BB Width", 2, 0.5, 10, 0.5);
BBOption = ParamToggle("Plot BB", "No I Yes");

A=Param( "Swing", 20, 1, 100);
SL = Max(LLV(L, 5), Trough(L, Q, 1));

Tgt = 2 * H - SL;
MeanPrice = Prec((O + C) / 2, 2);

Part = 100 * (H - A) / (H - L);

BBTop = BBandTop(C, BP, BW);
BBBot = BBandBot(C, BP, BW);

res=HHV(H,A);
sup=LLV(L,A);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);

// line code
Plot(tsl, _DEFAULT_NAME(), ParamColor( "ColorD", colorRed ), styleStaircase|styleNoLabel|styleNoLine);

// arrows code
Buy=Cross(C,Ref(res,-1));
Sell=Cross(Ref(sup,-1),C);
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

Bought = Flip(Buy, Sell);
Sold = Flip(Sell, Buy);
NextTgt = ValueWhen(Buy, Tgt, 1);

for(i = 1; i < BarCount; i++)
{
if(Bought[i] AND NOT Buy[i])
{
SL[i] = Max(SL[i], SL[i - 1]);
if(C[i - 1] >= 0.9999 * NextTgt[i - 1]) NextTgt[i] = Tgt[i - 1];
NextTgt[i] = Max(NextTgt[i], NextTgt[i - 1]);
}
}
BuyDate = ValueWhen(Buy, Ref(DateTime(), 1), 1);
BuyPrice = ValueWhen(Buy, Ref(MeanPrice, 1), 1);
SellPrice = ValueWhen(Sell, Ref(MeanPrice, 1), 1);

TgtReached = IIf(Bought AND NOT Buy AND C >= 0.9999 * NextTgt, True, False);
SLHit = IIf(Bought AND NOT Buy AND C < SL, True, False);
SLHit = ExRem(SLHit, Buy);
Plot(IIf(Bought, NextTgt, Null), "Target", colorRed,styleNoLine|styleNoTitle|styleNoLabel);
Plot(SL, "Trail SL", colorGrey40, styleNoLine|styleNoTitle|styleNoLabel);
_SECTION_BEGIN(" ");
{ GfxSelectFont("Arial",13, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorDarkYellow);
GfxTextOut("TR="+WriteVal(NextTgt,format=1.2)+"",740,20);
GfxSetTextColor(colorBlue);
GfxTextOut("Trail="+WriteVal(SL,format=1.2)+"",850 ,20);
GfxSetTextColor(colorRed);
GfxTextOut(" SL="+WriteVal(tsl,format=1.2)+"",970,20);

}
_SECTION_END();
_SECTION_BEGIN(" Bullish sign & Bearish sign ");
SetChartOptions(0,chartShowArrows|chartShowDates);

rg=(H-L);
arg=Wilders(rg,30);

Vl=V<Ref(V,-1) AND V<Ref(V,-2);

mp=(H+L)/2;


_SECTION_BEGIN("VSA");

eftup=H>Ref(H,-1) AND L>Ref(L,-1) AND C>Ref(C,-1) AND C>=((H-L)*0.7+L) AND rg>arg AND V>Ref(V,-1);

eftdn=H<Ref(H,-1) AND L<Ref(L,-1) AND C<Ref(C,-1) AND C<=((H-L)*0.25+L) AND rg>arg AND V>Ref(V,-1);
_SECTION_END();

PlotShapes(shapeSmallCircle*eftup, colorDarkTeal, 0, mp, 0 );
PlotShapes(shapeSmallCircle*eftdn, colorBlack, 0, mp, 0 );

_SECTION_BEGIN("BB");
bb2top = BBandTop(Close,20,2.25);
bb1top = BBandTop(Close,20,1);
bb2bot = BBandBot(Close,20,2.25);
bb1bot = BBandBot(Close,20,1);

Plot (bb1top,"",IIf(bb1top > Ref(bb1top,-1) AND bb1bot < Ref(bb1bot,-1),colorYellow,colorYellow),32);
Plot (bb1bot,"",IIf(bb1top > Ref(bb1top,-1) AND bb1bot < Ref(bb1bot,-1),colorYellow,colorYellow),32);
Plot (bb2top,"",IIf(bb2top > Ref(bb2top,-1) AND bb2bot < Ref(bb2bot,-1),colorLightGrey,colorLightGrey),32);
Plot (bb2bot,"",IIf(bb2top > Ref(bb2top,-1) AND bb2bot < Ref(bb2bot,-1),colorLightGrey,colorLightGrey),32);
PlotOHLC(bb2top,bb2top,bb1top,bb1top,"",ColorRGB(56,63,118),styleCloud|styleNo Label);
PlotOHLC(bb1bot,bb1bot,bb2bot,bb1bot,"",ColorRGB(56,63,118),styleCloud|styleNo Label);


_SECTION_END();


_SECTION_BEGIN("EMA Time Frame");
r= RSI(14);
pR=PeakBars(RSI(14),1)==0;
pivothigh = Ref(pR,-1)<pR AND pR>Ref(pR,1);
y0=SelectedValue(ValueWhen(pivothigh,RSI(14),2));
y1=SelectedValue(ValueWhen(pivothigh,RSI(14),1));
x0=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,2));
x1=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,1));
LineA=LineArray(x0,y0,x1,y1,1);
pS =TroughBars(RSI(14),1)==0;
pivotlow = Ref(pS,-1)<pS AND pS>Ref(pS,1);
yt0=SelectedValue(ValueWhen(pivotlow,RSI(14),2));
yt1=SelectedValue(ValueWhen(pivotlow,RSI(14),1));
xt0=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,2));
xt1=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,1));
LineB=LineArray(xt0,yt0,xt1,yt1,1);

_SECTION_BEGIN("DIV");
u00=LastValue(Peak(H,1,2));
u11=LastValue(Peak(H,1,1));
a00=BarCount - 1 - LastValue(PeakBars(H,1,2));
price_start1=Close[a00];
a11=BarCount - 1 - LastValue(PeakBars(H,1,1));
price_end1=Close[a11];
Line = LineArray(a00,u00,a11,u11, 0 );
LastPointSell = LineArray(a11-1,u11-1,a11,u11,0);

GG=u11<u00 AND price_end1>price_start1;
PlotShapes(shapeSmallCircle*GG ,colorDarkRed,0,Line,-2);




_SECTION_END();

_SECTION_BEGIN("DIV");
u0=LastValue(Trough(L,1,2));
u1=LastValue(Trough(L,1,1));
a0=BarCount - 1 - LastValue(TroughBars(L,1,2));
price_start=Close[a0];
a1=BarCount - 1 - LastValue(TroughBars(L,1,1));
price_end=Close[a1];
Line = LineArray(a0,u0,a1,u1, 0 );

TT=u1>u0 AND price_end<price_start;
LastPointBuy = LineArray(a1-1,u1-1,a1,u1,0);
PlotShapes(shapeSmallCircle*TT,colorCustom11,0,Line,-2);

_SECTION_END();




_SECTION_BEGIN("zzt");
para = ParamToggle("plot zz0","off,on");
cbar = Param("cbar",4,2,50,1);
per = Param("per",5,1,30,1);
zz0 = Zig(C,per);
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );
tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
pu = tr + 0.01 * abs(tr)*per;
pd = pk - 0.01 * abs(pk)*per;
zzt = IIf(C>= pu AND zz0 > zz1, 1,
IIf(C<= pd AND zz0 < zz1, -1, 0 ) );
zzt= ValueWhen( zzt != 0, zzt );
colorp2= IIf((C>O)OR(C<O),colorWhite,colorYellow);
Plot(IIf(para,zz0,Null)," ",colorWhite,styleNoLine|styleNoTitle|styleNoLabel);
pr=PeakBars(High,3)==0;
ps =TroughBars(Low,3)==0;
rf=ValueWhen(pr,High);
sf=ValueWhen(ps,Low);
rf1 = IIf(rf AND BarsSince(pr) <=cbar,rf,Null);
sf1 = IIf(sf AND BarsSince(ps ) <=cbar,sf,Null);
Plot(rf1,"",colorOrange,styleDots | styleNoLine);
Plot(sf1,"",colorOrange,styleDots | styleNoLine);
Plot(rf,"",colorLightOrange,40+16|styleNoLabel);
Plot(sf,"",colorLightOrange,40+16|styleNoLabel);
PlotShapes(IIf(pr, shapeSmallSquare,shapeNone),colorWhite,0,H,10);
PlotShapes(shapeSmallCircle*pr,colorBlack,0,H,10);
PlotShapes(IIf(ps, shapeSmallSquare,shapeNone),colorWhite,0,L,-10);
PlotShapes(shapeSmallCircle*ps,colorBlack,0,L,-10);
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("text shift", -50,-100,100,10);

PlotText("RF=" + WriteVal(rf,fraction),
SelectedValue(BarIndex()+7)-(numbars/hts),SelectedValue(rf),colorCustom12);
PlotText("SF=" + WriteVal(sf,fraction),
SelectedValue(BarIndex()+7)-(numbars/hts),SelectedValue(sf),colorYellow);
_SECTION_END();


PlotShapes(IIf(ps, shapeSmallSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(ps, shapeSmallSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(ps, shapeUpArrow, shapeNone),colorBlack, 0,L, Offset=-45);
PlotShapes(IIf(pr, shapeSmallSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(pr, shapeSmallSquare, shapeNone),colorRed, 0,H, Offset=50);
PlotShapes(IIf(pr, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

_SECTION_END();



رد مع اقتباس
قديم 17-01-2017, 09:59 PM
  المشاركه #22

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

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

بالنسبة لتعديل المعادلة اخوى عادل

حمل المعادلة من ها الرابط بعد فك الضغط منه

http://up.top4top.net/downloadf-382k129l1-rar.html

هى عبارة عن حذف المسافة فى الخطأين



رد مع اقتباس
قديم 24-01-2017, 12:19 PM
  المشاركه #23

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

تاريخ التسجيل: Aug 2010
المشاركات: 4,040
نور قائد النمور غير متواجد حالياً  

سبحان الله وبحمده سبحان الله العظيم


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



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

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

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



07:41 AM