// Downloaded From https://www.WiseStockTrader.com //////////begin///////// box1=0; box2=0; SetBarsRequired(10000,10000); procedure fillDarvas(start,end,swap,top, bottom ) { for ( j = start; j < end; j++) { if( box1[j] == swap) box1[j]= top ; else box1[j]= bottom; if(box2[j] == swap) box2[j]= bottom ; else box2[j]= top; } } BoxArr1 = 0; BoxArr2 = 0; StateArray = 0; DBuy = 0; DSell = 0; TopArray = 0; BotArray = 0; tick=0; BoxTop = High[0]; BoxBot = Low[0]; swap=0; state = 0; BoxStart = 0; for (i=0; i(BoxTop*(1+tick/100))) { fillDarvas(BoxStart,i,swap,BoxTop,BoxBot); state = 1; swap = !swap; BoxTop = High[i]; BoxStart = i; } } else { if (High[i]BoxBot)) { state++; } else { state=3; } if (state==3) BoxBot=Low[i]; } else { state=1; BoxTop=High[i]; } } StateArray[i] = state; } fillDarvas(BoxStart,BarCount,swap,BoxTop,BoxBot); Buyrule=H>Ref(box1,-1) AND H>Ref(box2,-1) AND Ref(statearray,-1)==5; Sellrule=Lbox2,box1,box2); Sellrule2 = (((topvalue-Close)*100/topvalue) > lossopt) AND (statearray == statopt); Sell = Sellrule OR Sellrule2; Short = Sell; Cover = Buy; _SECTION_BEGIN("PANEL 25 MURREY MATH"); ParamShowLevel=ParamList("Show harmonic levels", "1/8|1/4|1/2", 1 ); ParamShowLabel=ParamStyle("Show harmonic labels", styleNoLabel, styleNoLabel); if(Status("action") ==1) //indicator { LastVisibleIndex = LastValue(Status("lastvisiblebarindex")); if (LastVisibleIndex > BarCount -1) //to avoid errors is case of cursor is behind the last bar LastVisibleIndex = BarCount-1; TotalVisibleBars = LastVisibleIndex - LastValue(Status("firstvisiblebarindex")) + 1; } else { LastVisibleIndex = BarCount -1; TotalVisibleBars = BarCount; } HHScreen = HHV(High, TotalVisibleBars); LLScreen = LLV(Low, TotalVisibleBars); PRScreen = HHScreen[LastVisibleIndex] - LLScreen[LastVisibleIndex]; //Price range PriceRangeVisible = PRScreen * 1.1; MiddleVisible = (HHScreen[LastVisibleIndex] + LLScreen[LastVisibleIndex]) /2; HighestVisible= MiddleVisible + PriceRangeVisible / 2; LowestVisible = MiddleVisible - PriceRangeVisible / 2; SquareBase = 0.1953125; if (HighestVisible > 0.390625) { SquareBase = 1.5625; } if (HighestVisible > 1.5625) { SquareBase = 3.125; } if (HighestVisible > 3.125) { SquareBase = 6.25; } if (HighestVisible > 6.25) { SquareBase = 12.5; } if (HighestVisible > 25) { SquareBase = 100; } if (HighestVisible > 250) { SquareBase = 1000; } if (HighestVisible > 2500) { SquareBase = 10000; } if (HighestVisible > 25000) { SquareBase = 100000; } ShowLevel = 1; PriceStep = SquareBase / 8; while ( PriceRangeVisible / 4 <= PriceStep AND ShowLevel < 4) { PriceStep = PriceStep / 8; ShowLevel++; } //Lowest,highest harmonic value to show on the panel LowerValue = floor(LowestVisible / PriceStep) * PriceStep; HigherValue = ceil(HighestVisible / PriceStep) * PriceStep; Octave1PriceStep = SquareBase / 8; Octave2PriceStep = SquareBase / 64 ; Octave3PriceStep = SquareBase / 512; Harmonic = LowerValue; //iterate from low to high values while( Harmonic <= HigherValue ) { style = styleDashed; // 1/8, 3/8, 5/8, 7/8 lines of any level color = colorBlue; //1/8, 7/8 if ((Harmonic / PriceStep) % 8 == 1 OR (Harmonic / PriceStep) % 8 == 7) color = colorBlue; // 3/8, 5/8 if (ParamShowLevel != "1/8") style = styleNoLine; if ((Harmonic / PriceStep) % 2 == 0) // 1/4, 3/4 lines of any level { style = styleLine; color = colorBlack; if (ParamShowLevel == "1/2") style = styleNoLine; } if ((Harmonic / PriceStep) % 4 == 0) // 1/2 line of any level { style = styleDots; color = colorViolet; } if ((Harmonic / PriceStep) % 8 == 0) // 1/1 line of Baby level { color = colorDarkYellow; style = styleDots; if ((Harmonic / Octave3PriceStep) % 64 == 0) // 1/1 line of Minor level { style = styleDots; // 1/1 /Level Minor } } if (style != styleNoLine) //if there is a line to plot... (avoid printing unused labels) { style = style + ParamShowLabel; Plot( Harmonic, "", color, style); } Harmonic = Harmonic + PriceStep; } _SECTION_END(); _SECTION_BEGIN("NICK MA Swing"); SetBarsRequired(200,0); GraphXSpace = 5; SetChartOptions(0,chartShowArrows|chartShowDates); k = Optimize("K",Param("K",1,0.25,5,0.25),0.25,5,0.25); Per= Optimize("atr",Param("atr",4,3,20,1),3,20,1); HACLOSE=(O+H+L+C)/4; HaOpen = AMA( Ref( HaClose, -1 ), 0.5 ); HaHigh = Max( H, Max( HaClose, HaOpen ) ); HaLow = Min( L, Min( HaClose, HaOpen ) ); j=Haclose; //======================================================================================================================= //=========================Indicator============================================================================================== f=ATR(14); rfsctor = WMA(H-L, Per); revers = k * rfsctor; Trend = 1; NW[0] = 0; for(i = 1; i < BarCount; i++) { if(Trend[i-1] == 1) { if(j[i] < NW[i-1]) { Trend[i] = -1; NW[i] = j[i] + Revers[i]; } else { Trend[i] = 1; if((j[i] - Revers[i]) > NW[i-1]) { NW[i] = j[i] - Revers[i]; } else { NW[i] = NW[i-1]; } } } if(Trend[i-1] == -1) { if(j[i] > NW[i-1]) { Trend[i] = 1; NW[i] = j[i] - Revers[i]; } else { Trend[i] = -1; if((j[i] + Revers[i]) < NW[i-1]) { NW[i] = j[i] + Revers[i]; } else { NW[i] = NW[i-1]; } } } } //===============system================ Buy=Cover=Cross(j,nw); Sell=Short=Cross(nw,j); SellPrice=ValueWhen(Sell,C,1); BuyPrice=ValueWhen(Buy,C,1); Long=Flip(Buy,Sell); Shrt=Flip(Sell,Buy ); _SECTION_END(); //=================TITLE================================================================================================ _SECTION_BEGIN("Title"); if( Status("action") == actionIndicator ) ( EncodeColor(colorLime)+ WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+ WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorWhite)+ WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+ WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+ WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+ WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+ WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+ WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"","")); PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40); PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50); PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40); PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50); PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45); _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], colorBrightGreen ); if ( price == 1 ) { p = StrRight( NumToStr( L[b], 4.1 ), rightfig ); PlotText( "\n\n" + p, b - 2 , L[b] , colorBrightGreen ); } } 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(); GraphXSpace = xspace; //ELLIOT Fractals _SECTION_BEGIN("Price"); SetChartOptions(0,chartShowArrows|chartShowDates); Plot( C, "Close", ParamColor("Color", colorBlack ), styleCandle | ParamStyle("Style") | GetPriceStyle() ); _SECTION_END(); _SECTION_BEGIN("ELLIOTT Fractals"); /* The basic definition of an 'up' fractal is a bar high that is both higher than the two bars immediately preceding it and higher than the two bars immediately following it. The lows of the bars are NOT considered in determining the up fractal progression. If two bars in the progression have equal highs followed by two consecutive bars with lower highs, then a total of six bars rather than the usual five bars will make up the progression. The first High becomes the counting fractal. Reverse for 'down' fractals. The 5 bar formation works best on Daily or longer time frame charts.For intraday data charts we often use 9 bar, 13 bar and 21 bar formations for fractal counting */ Up5BarFractal = Ref(H,-2) < H AND Ref(H,-1) < H AND Ref(H,1) < H AND Ref(H,2) < H; Up6BarFractal = Ref(H,-2) < H AND Ref(H,-1) < H AND (H == Ref(H,1)) AND Ref(H,2) < H AND Ref(H,3) < H; Down5BarFractal = Ref(L,-2) > L AND Ref(L,-1) > L AND Ref(L,1) > L AND Ref(L,2) > L; Down6BarFractal = Ref(L,-2) > L AND Ref(L,-1) > L AND (L == Ref(L,1)) AND Ref(L,2) > L AND Ref(L,3) > L; //TODO: More filtering: Show only troughs that are around atrough in trix(9). Up = (Up5BarFractal OR Up6BarFractal); Down = (Down5BarFractal OR Down6BarFractal); //Removing false fractals: DownSignal = Flip(Ref(Up,-1), Ref(Down,-1)); UpSignal = Flip(Ref(Down,-1), Ref(Up,-1)); LastHigh[0] = H[0]; LastLow[0] = L[0]; LastLowIndex = 0; LastHighIndex = 0; Valid = 0; for (i=1; i < BarCount; i++) { LastHigh[i] = LastHigh[i-1]; LastLow[i] = LastLow[i-1]; if (Up[i]) { Valid[i] = True; if (DownSignal[i]) { //Sequence of 2 Up Fractals. Validate only the higher one. Valid[i] = H[i] >= H[LastHighIndex]; Valid[LastHighIndex] = H[LastHighIndex] > H[i]; } LastHigh[i] = Max(H[i], H[LastHighIndex ]); LastHighIndex = i; } if (Down[i]) { Valid[i] = True; if (UpSignal[i]) { //Sequence of 2 Down Fractals. Validate only the lower one. Valid[i] = L[i] <= L[LastLowIndex]; Valid[LastLowIndex] = L[LastLowIndex] < L[i]; } LastLow[i] = Min(L[i], L[LastLowIndex]); LastLowIndex = i; } } TrixN = Trix(9); TroughLow = Ref(TrixN, -3) > TrixN AND Ref(TrixN, -2) > TrixN AND Ref(TrixN, -1) > TrixN AND Ref(TrixN, 1) > TrixN AND Ref(TrixN, 2) > TrixN AND Ref(TrixN, 3) > TrixN; TroughHigh = Ref(TrixN, -3) < TrixN AND Ref(TrixN, -2) < TrixN AND Ref(TrixN, -1) < TrixN AND Ref(TrixN, 1) < TrixN AND Ref(TrixN, 2) < TrixN AND Ref(TrixN, 3) < TrixN; //TroughLow = Ref(TrixN, -2) > TrixN AND Ref(TrixN, -1) > TrixN AND Ref(TrixN, 1) > TrixN AND Ref(TrixN, 2) > TrixN; //TroughHigh = Ref(TrixN, -2) < TrixN AND Ref(TrixN, -1) < TrixN AND Ref(TrixN, 1) < TrixN AND Ref(TrixN, 2) < TrixN; ZeroValid = Cross(TrixN, 0) OR Cross(0, TrixN) OR Ref(Cross(TrixN, 0),1) OR Ref(Cross(0, TrixN),1); ValidLow = TroughLow OR Ref(TroughLow, 1) OR Ref(TroughLow, 2) OR Ref(TroughLow, 3) OR Ref(TroughLow, 4);// OR Ref(TroughLow, 5)); ValidHigh = TroughHigh OR Ref(TroughHigh, 1) OR Ref(TroughHigh, 2) OR Ref(TroughHigh, 3) OR Ref(TroughHigh, 4);// OR Ref(TroughHigh, 5)); //Plot(LastHigh-10 ,"LastHigh", colorBlue, styleLine); //Plot(LastLow-10 ,"LastLow ", colorRed, styleLine); //Plot(Valid*5 + 10 ,"LastLow ", colorGreen, styleLine | styleThick); //PlotShapes( IIf(Down AND Valid,shapeSmallUpTriangle,0) ,colorGreen, 0, L,-12); //PlotShapes( IIf(Up AND Valid,shapeSmallDownTriangle,0) ,colorRed, 0, H,-12); Maxi = Up AND (ValidHigh OR ZeroValid); Mini = Down AND (ValidLow OR ZeroValid); PlotShapes( IIf(Down AND (ValidLow OR ZeroValid),shapeSmallUpTriangle,0) ,colorBrightGreen, 0, L,-12); PlotShapes( IIf(Up AND (ValidHigh OR ZeroValid),shapeSmallDownTriangle,0) ,colorRed, 0, H,-12); AlertIf(Down AND (ValidLow OR ZeroValid), "SOUND C:\\Windows\\Media\\Chord.wav", "Audio alert", 2); AlertIf(Up AND (ValidHigh OR ZeroValid), "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2); //Plot(UpSignal*3+5,"UpSignal", colorBlue, styleLine| styleThick); //Plot(DownSignal*3 ,"DownSignal", colorRed, styleLine| styleThick); /* LastMaxi = 0; LastMini = 0; ElliotLines = 0; State = 0; for (i=1; i < BarCount; i++) { State[i] = State[i-1]; if (Maxi[i]) { State[i] = 1;//down } if (Mini[i]) { State[i] = 2; } } PlotShapes(IIf(State > 0, shapeSmallCircle, 0), IIf(State == 1, colorRed, colorBlue), 0, IIf(State == 1, H, L), -5); */ //Line = LineArray( x0, y0, x1, y1, 1 ); //Plot( Line, "Trend line", colorBlue ); /* Wave B Usually 50% of Wave A Should not exceed 75% of Wave A Wave C either 1 x Wave A or 1.62 x Wave A or 2.62 x Wave A */ function CorrectiveRatios(StartPrice, A, B, C, RatioDelta, Delta) { ALength = abs(startPrice - A); BLength = abs(A-B); CLength = abs(B-C); Ratio1 = BLength / CLength ; Cond1 = Ration1 >= 0.5 - RatioDelta AND ratio1 <= 0.75 + RatioDelta; Cond2 = abs(Clength - ALength) < Delta OR abs(Clength - 1.62 * ALength) < Delta OR abs(CLength - 2.62 * ALength) < Delta; return Cond1 AND Cond2; } function ImpulseRules(StartPrice, One, Two, Three, Four, Five) { //Wave 2 should be beneath wave 1 start: Cond1 = Two > StartPrice AND Two < One; //Wave 4 - the same: Cond2 = Four > Two AND Four < Three; //Wave 5 should be <= wave 3 Cond3 = abs(Three-Two) >= abs(Five - Four); //Wave 1 should be smaller than wave five, making wave 3 the biggest: Cond4 = abs(StartPrice - One) < abs(Five - Four); return Cond1 AND Cond2 AND Cond3 AND Cond4; } _SECTION_END(); _SECTION_BEGIN("Marva Mid R-Line Signal"); x = Cum(1); lastx = LastValue( x ); Daysback = 10; aa = LastValue( LinRegIntercept( Close, Daysback) ); bb = LastValue( LinRegSlope( Close, Daysback ) ); y = Aa + bb * ( x - (Lastx - DaysBack) ); //Plot( Close, "Close", colorRose, styleCandle ); per1=Param ("per1", 0.325,0.1,50,0.10); perc=per1; x1=BarIndex();xx=SelectedValue(x); t1=SelectedValue(ValueWhen(PeakBars(C,perc)==0,x)) ; H1=SelectedValue(ValueWhen(PeakBars(C,perc)==0,C)) ; t11=SelectedValue(ValueWhen(TroughBars(C,perc)==0, x)); H11=SelectedValue(ValueWhen(TroughBars(C,perc)==0, C)); g=t1>t11; shape=IIf(g,shapeHollowDownTriangle*(x==t1),shapeHollowUpTriangle*(x ==t11)); Color=IIf(g,colorRed,colorBrightGreen); PlotShapes(shape,color); _SECTION_END(); _SECTION_BEGIN("A24"); //Shortavg=Param("Short average",13,5,25,2); Longavg=Param("Long average",13,5,80,2); TrendAvg=Param("Trender average",21,5,100,3); Dix = Param ("Directional Index",14,5,25,1); Oversold = Param ( "Oversold", 50, 20, 70, 5 ); Overbot = Param ("Overbot", 50, 50, 100, 5 ); ADXThreshold = Param ("ADXThreshold",15,5,25,1); //MACD// FAST = Param("FAST",12,0,100,1); SLOW = Param("SLOW",26,0,100,1); SIG = Param("SIG",5,0,100,1); MACDLine = MACD(FAST,SLOW); MACDSignal = Signal(FAST,SLOW,SIG); //Trendscore// TrendScore = IIf(C>=Ref(C,-13),1,-1)+ IIf(C>=Ref(C,-14),1,-1)+ IIf(C>=Ref(C,-15),1,-1)+ IIf(C>=Ref(C,-16),1,-1)+ IIf(C>=Ref(C,-17),1,-1)+ IIf(C>=Ref(C,-18),1,-1)+ IIf(C>=Ref(C,-19),1,-1)+ IIf(C>=Ref(C,-20),1,-1)+ IIf(C>=Ref(C,-21),1,-1)+ IIf(C>=Ref(C,-22),1,-1); /////////////////AROON//////////////////// Period = 14; LLVBarsSince = LLVBars(L, Period) + 1; HHVBarsSince = HHVBars(H, Period) + 1; AroonDn = 100 * (Period - LLVBarsSince) / (Period - 1); AroonUp = 100 * (Period - HHVBarsSince) / (Period - 1); ///Buy and cover// Buy = Cross(C, EMA(C,Longavg)) //AND (C>=EMA(C,TrendAvg)) AND (ADX (Dix) > ADXThreshold) AND PDI(Dix)>MDI(Dix) //AND MACDLine>MACDSignal; AND (RSI(14)>Oversold); //AND AroonUp>30; Cover = C>EMA(C,Longavg) AND RSI(14)>Oversold; //Short AND Sell// Short = Cross(EMA(C,Longavg), C) //AND (C<=EMA(C,TrendAvg)) AND (ADX (Dix) > ADXThreshold) AND PDI(Dix)>MDI(Dix) //AND MACDLine30; Sell = C5; // AND trendscore>5 _SECTION_END();