// Downloaded From https://www.WiseStockTrader.com PctVlt=(ATR(14)/C)*100;//PercentVolatility PK=IIf(PctVlt<0.5,Peak(Close,0.5,1), IIf( PctVlt>=0.5 AND PctVlt< 1.0 ,Peak(Close,0.70,1), IIf( PctVlt>=1.0 AND PctVlt< 1.5 ,Peak(Close,0.90,1), IIf( PctVlt>=1.5 AND PctVlt< 2.0 ,Peak(Close,1.10,1), IIf( PctVlt>=2.0 AND PctVlt< 2.5 ,Peak(Close,1.30,1), IIf( PctVlt>=2.5 AND PctVlt< 3.0 ,Peak(Close,1.50,1), IIf( PctVlt>=3.0 AND PctVlt< 3.5 ,Peak(Close,1.70,1), IIf( PctVlt>=3.5 AND PctVlt< 4.0 ,Peak(Close,2.00,1), Peak(Close,2.20,1) )))))))); TGH=IIf(PctVlt<0.5,Trough(Close,0.5,1), IIf( PctVlt>=0.5 AND PctVlt< 1.0 ,Trough(Close,0.75,1), IIf( PctVlt>=1.0 AND PctVlt< 1.5 ,Trough(Close,1.00,1), IIf( PctVlt>=1.5 AND PctVlt< 2.0 ,Trough(Close,1.25,1), IIf( PctVlt>=2.0 AND PctVlt< 2.5 ,Trough(Close,1.50,1), IIf( PctVlt>=2.5 AND PctVlt< 3.0 ,Trough(Close,1.75,1), IIf( PctVlt>=3.0 AND PctVlt< 3.5 ,Trough(Close,2.00,1), IIf( PctVlt>=3.5 AND PctVlt< 4.0 ,Trough(Close,2.25,1), Trough(Close,2.50,1) )))))))); Sens=IIf(PctVlt<0.5,0.5, IIf( PctVlt>=0.5 AND PctVlt< 1.0 ,0.75, IIf( PctVlt>=1.0 AND PctVlt< 1.5 ,1.00, IIf( PctVlt>=1.5 AND PctVlt< 2.0 ,1.25, IIf( PctVlt>=2.0 AND PctVlt< 2.5 ,1.50, IIf( PctVlt>=2.5 AND PctVlt< 3.0 ,1.75, IIf( PctVlt>=3.0 AND PctVlt< 3.5 ,2.00, IIf( PctVlt>=3.5 AND PctVlt< 4.0 ,2.25, 2.50 )))))))); Color=IIf(BarsSince(Cross(C,Ref(PK,-1)))= 084500 & TimeNum() <= 085959; isdRth = TimeNum() >= 084500 & TimeNum() <= 160000; aRthL = IIf(isRth, L, 1000000); aRthH = IIf(isdRth, H, Null); aRthLd = IIf(isdRth, L, 1000000); DayH = TimeFrameCompress( aRthH, inDaily, compressHigh ); DayH = TimeFrameExpand( DayH, inDaily, expandFirst ); DayL = TimeFrameCompress( aRthLd, inDaily, compressLow ); DayL = TimeFrameExpand( DayL, inDaily, expandFirst ); Bars = BarsSince(TimeNum() >= 94500 AND TimeNum() < 095959);//,BarIndex(),1); // AND DateNum()==LastValue(DateNum()); x0 = BarCount-LastValue(Bars); x1 = BarCount-1; DayHline=LineArray(x0,LastValue(DayH),x1,LastValue (DayH),0); DayLline=LineArray(x0,LastValue(DayL),x1,LastValue (DayL),0); DayHlineI = LastValue (DayHline,1); DayLlineI = LastValue (DayLline,1); Plot(DayHline,"DayH",colorYellow,styleBar|styleNoRescale|styleNoTitle); Plot(DayLline,"DayL",colorYellow,styleBar|styleNoRescale|styleNoTitle); PlotText(" Day Hi " , LastValue(BarIndex())-(numbars/Hts), DayHlineI +0.05, colorYellow); PlotText(" Day Lo " , LastValue(BarIndex())-(numbars/Hts), DayLlineI +0.05, colorYellow); } /////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////// //Support and resistance levels using RSI. //graham Kavanagh May 2003 //Load into Indicator Builder //Sensitivity of the levels can be changed with the variables //Can test different numbers live with the Param function ctrl-R with open pane RSIperiod = 5; // Param("RSI p",3,14,30,1); Percent = 5; // Param("ZIG %",8,9,15,1); EMAperiod = 5; //Param("EMA p",4,5,10,1); HHVperiod = 5; //Param("HHV p",3,5,10,1); NumLine = 1; //Param("Num Lines",3,1,20,1); Base = DEMA(RSI(RSIperiod),EMAperiod); for( i = 1; i <= numline; i++ ) { ResBase = LastValue(Peak(Base,Percent,i)); SupBase = LastValue(Trough(Base,Percent,i)); Plot(ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), "Resist Level", colorRed, styleDashed); Plot(ValueWhen( supbase==Base, LLV(L,HHVperiod) ), "Support Level", colorGreen, styleDashed); } Title = Name() + "; " + Date() + ": Support & Resistance Levels using RSI: " + /*EncodeColor(colorGreen)+ "Support Levels are Green; "+EncodeColor(colorRed)+ "Resistance Levels are Red: "+EncodeColor(colorBlack)+*/ "Num lines ="+WriteVal(numline,1) ; ///////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// ///// Trailing Stop Module ///// P6=Param("Trailing Stop Risk",2.5,2,3.5,0.1); P7=Param("Trailing Stop LookBack",14,5,25,1); P8=Param("Trailing Stop PrevLow Switch",0,0,1,1); PrevLow=IIf(P8==1, Ref(C,-TroughBars(C,5,1)) ,Null); Plot(PrevLow,"",colorRed); //Position sizing// MyTotalPort = Param("MyTotalPort",1000000,10000,10000000,100000) ; AcceptableRisk = Param("AcceptableRisk",0.5,0.1,3,0.1); BarsFromStart = BarsSince(Cross(C,Ref(PK,-1))AND Ref(Color,-1)==colorRed) ; InitialStopLoss =Ref( H - P6*ATR(P7),-BarsFromStart); PositionSizing = 0.01*AcceptableRisk*MyTotalPort/( C - InitialStopLoss ); Plot(IIf( HHV(H - P6*ATR(P7),BarsFromStart+1) even,triangularOdd,TriangularEven); Color=colorBrightGreen;//select Moving average line color tickercolor=colorBlack;//select price color Plot(finalMov_avg,"",IIf(C < finalmov_avg,colorRed,Color),styleDots|styleThick) ; //////////////////////////////////////////////////////////////////////////////////////////////// /* ********************************** Code to automatically identify pivots TRIANGLE ********************************** */ // -- what will be our lookback range for the hh and ll? farback=Param("How Far back to go",200,12,30,1); nBars = Param("Number of bars", 12, 1, 30, 1); // -- Create 0-initialized arrays the size of barcount aHPivs = H - H; aLPivs = L - L; // -- More for future 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 future version for (i=0; i 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 elements in the // pivot information arrays for (j=0; j candPrc AND candIdx > lastHPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aLPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j= y1; i++ ){ firstpointL++; y0=LastValue(Trough(L,percent,firstpointL)); } x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpointL)); x1=BarCount - 1 - LastValue(TroughBars(Ref(L,-1),percent,1)); LineL = LineArray( x0, y0, x1, y1, 1 ); Plot( LineL, "Support", colorGreen,styleLine | styleDots | styleNoTitle | styleNoRescale); yt0=LastValue(Peak(H,percent,firstpointH)); yt1=LastValue(Peak(Ref(H,-1),percent,1)); for(i = 1; i < BarCount AND yt0 <= yt1; i++ ) { firstpointH++; yt0=LastValue(Peak(H,percent,firstpointH)); } xt0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpointH)); xt1=BarCount - 1 - LastValue(PeakBars(Ref(H,-1),percent,1)); LineH = LineArray( xt0, yt0, xt1, yt1, 1 ); Plot( LineH, "Resistance", colorBrown,styleLine | styleDots | styleNoTitle | styleNoRescale); ATBuy = Cross(C,LineH); ATShort = Cross(LineL,C); PlotShapes(ATBuy * shapeUpTriangle , colorBlue,0,L); PlotShapes(ATShort * shapeDownTriangle , colorRed,0,H); _SECTION_END(); GraphXSpace = 10 ; //////////////////////////////////////////////////////////////////////////////////////////////////// /* Done by Rajandran R */ /* Author of bhavesh */ _SECTION_BEGIN("SuperTrend"); SetBarsRequired(100000,0); GraphXSpace = 15; SetChartOptions(0,chartShowArrows|chartShowDates); SetChartBkColor(ParamColor("bkcolor",colorBlack)); GfxSetBkMode(0); GfxSetOverlayMode(1); SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey))); 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); SetTradeDelays(1,1,1,1); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); Factor=Param("Factor",2,1,10,0.1); Pd=Param("ATR Periods",11,1,100,1); Up=(H+L)/2+(Factor*ATR(Pd)); Dn=(H+L)/2-(Factor*ATR(Pd)); iATR=ATR(Pd); TrendUp=TrendDown=Null; trend[0]=1; changeOfTrend=0; flag=flagh=0; for (i = 1; i Up[i-1]) { trend[i]=1; if (trend[i-1] == -1) changeOfTrend = 1; } else if (Close[i]0) { flag=1; } else { flag=0; } if (trend[i]>0 && trend[i-1]<0) { flagh=1; } else { flagh=0; } if (trend[i]>0 && Dn[i]Up[i-1]) { Up[i]=Up[i-1]; } if (flag==1) { Up[i]=(H[i]+L[i])/2+(Factor*iATR[i]);; } if (flagh==1) { Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);; } if (trend[i]==1) { TrendUp[i]=Dn[i]; if (changeOfTrend == 1) { TrendUp[i-1] = TrendDown[i-1]; changeOfTrend = 0; } } else if (trend[i]==-1) { TrendDown[i]=Up[i]; if (changeOfTrend == 1) { TrendDown[i-1] = TrendUp[i-1]; changeOfTrend = 0; } } } Plot(TrendUp,"Trend",colorGreen); Plot(TrendDown,"Down",colorRed); Buy = trend==1; Sell=trend==-1; Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); Short=Sell; Cover=Buy; BuyPrice=ValueWhen(Buy,C); SellPrice=ValueWhen(Sell,C); ShortPrice=ValueWhen(Short,C); CoverPrice=ValueWhen(Cover,C); Title = EncodeColor(colorRed)+ "Super Trend AFL code from AJMERA BHAVESH " + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorRed) + " - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+ "Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+ EncodeColor(colorGreen)+ WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+ WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorGreen)+ WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+ WriteIf(Buy , "Total Profit/Loss for the Last trade 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(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40); PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50); PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45); TrendSL=IIf(trend==1,TrendUp,TrendDown); for(i=BarCount-1;i>1;i--) { if(Buy[i] == 1) { entry = C[i]; sig = "BUY"; sl = TrendSL[i]; tar1 = entry + (entry * .0050); tar2 = entry + (entry * .0092); tar3 = entry + (entry * .0179); bars = i; i = 0; } if(Sell[i] == 1) { sig = "SELL"; entry = C[i]; sl = TrendSL[i]; tar1 = entry - (entry * .0050); tar2 = entry - (entry * .0112); tar3 = entry - (entry * .0212); bars = i; i = 0; } } Offset = 20; Clr = IIf(sig == "BUY", colorLime, colorRed); ssl = IIf(bars == BarCount-1, TrendSL[BarCount-1], Ref(TrendSL, -1)); sl = ssl[BarCount-1]; Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset); Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset); Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset); //Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset); //Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset); /* for (i=bars; i = (HCb[i-1] - LLb[i-1])) Buyrange[i] = HHb[i-1] - LCb[i-1]; else Buyrange[i] = HCb[i-1] - LLb[i-1]; if ((HHs[i-1] - LCs[i-1]) >= (HCs[i-1] - LLs[i-1])) Sellrange[i] = HHs[i-1] - LCs[i-1]; else Sellrange[i] = HCs[i-1] - LLs[i-1]; }; Band_TopSMOOTH=AMA( Ho+Buyrange, 0.5 ); Band_BotSMOOTH=AMA( Ho-Sellrange, 0.5 ); Band_MidSMOOTH=(Band_TopSMOOTH+Band_BotSMOOTH)/2; Band_Top=Ho+Buyrange; Band_Bot=Ho-Sellrange; Band_Mid=(Band_Top+Band_Bot)/2; BS = ParamToggle("bands smooth","No|Yes",1); BN = ParamToggle("bands normal","No|Yes",1); DUL = ParamToggle("upper/lower bands","No|Yes",0); //disable upper/lower bands if (BS AND DUL) Plot( Band_TopSMOOTH, " Band_TopSMOOTH ", IIf( Band_TopSMOOTH>Ref(Band_TopSMOOTH,-1), colorOrange, colorRed )); if (BS) Plot( Band_MidSMOOTH, " Band_MidSMOOTH ", IIf( Band_MidSMOOTH>Ref(Band_MidSMOOTH,-1), colorGreen, colorRed )); if (BS AND DUL) Plot( Band_BotSMOOTH, " Band_BotSMOOTH ", IIf( Band_BotSMOOTH>Ref(Band_BotSMOOTH,-1), colorDarkGreen, colorGreen )); if (BS) Plot( 1, "ribbon", IIf( Band_MidSMOOTH>Ref(Band_MidSMOOTH,-1), colorGreen, IIf( Band_MidSMOOTHRef(Band_Top,-1), colorOrange, colorRed )); if (BN) Plot( Band_Mid, " Band_Mid ", IIf( Band_Mid>Ref(Band_Mid,-1), colorGreen, colorRed )); if (BN AND DUL) Plot( Band_Bot, " Band_Bot ", IIf( Band_Bot>Ref(Band_Bot,-1), colorDarkGreen, colorGreen )); if (BN) Plot( 2, "ribbon", IIf( Band_Mid>Ref(Band_Mid,-1), colorGreen, IIf( Band_Mid