Stock Portfolio Organizer
The ultimate porfolio management solution.
Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
HOW TO RUN THIS FORMULA for Amibroker (AFL)
Copy & Paste Friendly
Back
_SECTION_BEGIN("DTSnew"); //------------------------------------------------------------------------- SetChartOptions(0,chartShowArrows|chartShowDates|chartWrapTitle); _N(Title = StrFormat("{{NAME}} - {{ INTERVAL}} ((DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); T=26; BHSda=funDTN_ML(funDTN_D((funDTN_MI(C,funDTN_M1(C,T))),funDTN_M1(C,T)),100); Graph0=BHSda; Graph0Style=2+4; Graph0BarColor=IIf(BHSda>0,5,4); GraphXSpace=5; SetChartOptions(0,chartShowArrows|chartShowDates); Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); Plot( O, "Open", ParamColor("Color", colorBlack ), styleNoDraw); Plot( H, "High", ParamColor("Color", colorBlack ), styleNoDraw); Plot( L, "Low", ParamColor("Color", colorBlack ),styleNoDraw); //-------------------------------------------------------------------------------------------------------------------- r1 = 12;//Param( "Fast avg", 12, 2, 200, 1 ); r2 = 26;//Param( "Slow avg", 26, 2, 200, 1 ); r3 = 9;//Param( "Signal avg", 9, 2, 200, 1 ); Z = 1;//Param("zig",1,0,10,0.1); Cond1 = funDTN_C3(funDTN_M2(r1,r2),funDTN_S1(r1,r2,r3)); Cond3 = funDTN_N(C,z)>funDTN_R5(funDTN_N(C,z),-4); Buy = Cond1 AND Cond3; Cond4 = funDTN_C3(funDTN_S1(r1,r2,r3),funDTN_M2(r1,r2)); Cond6 = funDTN_N(C,z)<funDTN_R5(funDTN_N(C,z),-4); Sell = Cond4 AND Cond6; Trigger = WriteIf(Buy, "Buy", "") + WriteIf(Sell, "Sell", ""); BSG = IIf(Buy, colorPaleGreen, IIf(Sell, colorRose, colorDefault)); BSFG = IIf(Buy, colorDarkGreen, IIf(Sell, colorDarkRed, colorDefault)); //------------------------------------------------------------------------------------------------ if((Status("action") == actionExplore) OR (Status("action") == actionScan)) Filter = Buy OR Sell; SetOption("NoDefaultColumns", True); AddTextColumn(Name(), "Symbol", 77, BSFG, BSG, 120); AddColumn(DateTime(), "Date", formatDateTime, BSFG, BSG, 100); AddColumn(TimeNum() ,"Time",1,BSFG, BSG, 100); AddColumn( Buy, "Buy", 1,BSFG, BSG, 50); AddColumn( Sell, "Sell", 1,BSFG, BSG, 50 ); AddColumn( O, "Open", 1.2,BSFG, BSG, 100 ); AddColumn( H, "High", 1.2,BSFG, BSG, 100 ); AddColumn( L, "Low", 1.2,BSFG, BSG, 100 ); AddColumn( C, "Close", 1.2,BSFG, BSG, 100 ); AddColumn(V, "Volume",1,BSFG, BSG, 100); AddColumn(funDTN_R5(V,-1),"P-Vol",1,BSFG, BSG, 100); AddColumn(funDTN_D(V,funDTN_ML(funDTN_R5(V,-1),100)),"Increase in Vol",1,BSFG, BSG, 100); GraphXSpace = 7; //--------------------------------------------------------------------------------------------------------- C13=20;//Param("fonts",20,10,30,1 ); C14=2.1;//Param("left-right",2.1,1.0,5.0,0.1 ); C15=12;//Param("up-down",12,1,20,1 ); Miny = Status("axisminy"); Maxy = Status("axismaxy"); lvb = Status("lastvisiblebar"); fvb = Status("firstvisiblebar"); pxwidth = Status("pxwidth"); pxheight = Status("pxheight"); GfxSetBkMode(transparent=1); GfxSetOverlayMode(1); GfxSelectFont("Tahoma", Status("pxheight")/C13 ); GfxSetTextAlign( 6 ); GfxSetTextColor( ColorRGB (217,217,213)); GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 ); GfxSelectFont("Tahoma", Status("pxheight")/C13*0.4 ); GfxSetTextColor( ColorRGB (103,103,103)); GfxSelectFont("Tahoma", Status("pxheight")/C13*0.45 ); GfxSetTextColor( colorWhite); GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0); //------------------------------------------------------------------------------------------------ SetChartBkGradientFill( ParamColor("BgTop", colorBlack),ParamColor("BgBottom", colorDarkGrey)); pShowtradeLines = ParamToggle("Show Trade Lines", "No|Yes", 1); Volmin=Param("Volume minimum",5000,0,10000000,50); Volmax=Param("Volume maximum",1000000,0,10000000,50); priceRL=Param("Price Range Min",150,1,20000,1); priceRH=Param("Price Range Max",3000,1,20000,1); BSPeChMi=-25;//Param("Percentage Change Min set", -25, -100, 100, 0.1); BSPeChMa=25;//Param("Percentage Change Max set", 25, -100, 100, 0.1); BSPerTkProf=0.80;//Param("Take Profit Percent Set",0.6,0.3,30,0.1); BSPerStLos=0.25;//Param("StopLoss Percent Set",0.25,0.2,5,0.1); Bars = 0; xpdh = 90; { BSPl_Rng = (TimeNum() >= 95500 AND TimeNum()<= 220500) AND (DateNum()==LastValue(DateNum())); BSFH_Rg = (TimeNum() >= 095500 AND TimeNum()<= 101500) AND (DateNum()==LastValue(DateNum())); BSFH_Prc =funDTN_ML( High , BSFH_Rg); BSFH_Mrk = funDTN_B(BSFH_Rg>0); Num_Bars = 72000 / Interval(1); TimeFrameSet(inDaily); TOP_ = Open; PDH_ = funDTN_R5(High,-1); PDL_ = funDTN_R5(Low,-1); PDO_ = funDTN_R5(Open,-1); PDC_ = funDTN_R5(Close,-1); PDM_ = funDTN_D(funDTN_P(PDH_,PDL_),2); TimeFrameRestore(); isAll = True; isRth = TimeNum() >= 095400 AND TimeNum() <= 101500; isdRth = TimeNum() >= 095400 AND TimeNum() <= 230000; aRthL = IIf(isRth, L, 1000000); aRthH = IIf(isdRth, H, Null); aRthLd =IIf(isdRth, L, 1000000); TOP = TimeFrameExpand(TOP_,inDaily,expandFirst); PDH = TimeFrameExpand(PDH_,inDaily,expandFirst); PDL = TimeFrameExpand(PDL_,inDaily,expandFirst); PDO = TimeFrameExpand(PDO_,inDaily,expandFirst); PDC = TimeFrameExpand(PDC_,inDaily,expandFirst); PDM = TimeFrameExpand(PDM_,inDaily,expandFirst); FHH = funDTN_R5(funDTN_H1(High*BSFH_Rg,Num_Bars),-BSFH_Mrk); FHL = TimeFrameCompress( aRthL, inDaily, compressLow ); FHL = TimeFrameExpand( FHL, inDaily, expandFirst ); DayH = TimeFrameCompress( aRthH, inDaily, compressHigh ); DayH = TimeFrameExpand( DayH, inDaily, expandFirst ); DayL = TimeFrameCompress( aRthLd, inDaily, compressLow ); DayL = TimeFrameExpand( DayL, inDaily, expandFirst ); FC1=funDTN_ML((PDH-PDL),0.433); FC2=funDTN_ML((PDH-PDL),0.7666); FC3=funDTN_ML((PDH-PDL),1.355); FC4=funDTN_MI(FHH,FHL); A=IIf((FC4<=FC1+PDH*0.005),FC1,0); B=IIf((FC4<=FC2+PDH*0.005 AND FC4>FC1+PDH*0.005),FC2,0); Cl=IIf((FC4<=FC3 AND FC4>FC2+PDH*0.005),FC3,0); AF=funDTN_P(funDTN_P(B,Cl),A); //f HaC =funDTN_D((funDTN_P(funDTN_P(funDTN_P(L,C),H),O)),4); HaO = funDTN_AM( funDTN_R5( HaC, -1 ), 0.5 ); HaH = funDTN_MX( H, funDTN_MX( HaC, HaO) ); HaL = funDTN_MN( L, funDTN_MN( HaC, HaO) ); BG3 = funDTN_H1(funDTN_L1(HaL,4)+funDTN_A1(4),8); BR3= funDTN_L1(funDTN_H1(HaH ,4)-funDTN_A1(4),8); co = IIf(Hac>BG3 ,colorBlue,IIf(Hac < BR3,colorRed,colorGrey50)); BuyPrice=funDTN_P(DayL,AF); BSByTP1=funDTN_P(BuyPrice,funDTN_ML(BuyPrice,funDTN_D(BSPerTkProf,100))); BSByTP2=(C>=BSByTP1); SellPrice=funDTN_MI(DayH,AF); BSSlTP1=funDTN_MI(SellPrice,(SellPrice*funDTN_D(BSPerTkProf,100))); BSSlTP2=(C<=BSSlTP1); BSPrCh=funDTN_ML(funDTN_D(funDTN_MI(C,TOP),TOP),100); Vol=(V>=Volmin AND V<=Volmax); Percentage=(BSPrCh>=BSPeChMi AND BSPrCh<=BSPeChMa); prc=(C>=priceRL AND C<=priceRH); BuyStop1=funDTN_MI(BuyPrice,funDTN_ML(BuyPrice,funDTN_D(BSPerStLos,100))); BuyStop2=IIf((BuyStop1<=SellPrice) AND SellPrice<=BuyPrice,SellPrice,BuyStop1); SellStop1=funDTN_P(SellPrice,funDTN_ML(SellPrice,funDTN_D(BSPerStLos,100))); SellStop2=IIf((SellStop1>=BuyPrice) AND SellPrice<=BuyPrice, BuyPrice,SellStop1); BuyStop=IIf((Buy AND NOT BSByTP2),BuyStop2,Null); BuyTP=IIf(Buy AND NOT BuyStop,BSByTP2,Null); Bars = funDTN_B(TimeNum() >= 95400 AND TimeNum() < 101400); x0 = BarCount-LastValue(Bars); x1 = BarCount-1; TOP_Line = LineArray(x0,LastValue(TOP),x1,LastValue(TOP),0); PDH_Line = LineArray(x0,LastValue(PDH),x1,LastValue(PDH),0); PDL_Line = LineArray(x0,LastValue(PDL),x1,LastValue(PDL),0); PDC_Line = LineArray(x0,LastValue(PDC),x1,LastValue(PDC),0); PDM_Line = LineArray(x0,LastValue(PDM),x1,LastValue(PDM),0); FHH_Line = LineArray(x0,LastValue(FHH),x1,LastValue(FHH),0); FHL_Line = LineArray(x0,LastValue(FHL),x1,LastValue(FHL),0); BuyPriceline=LineArray(x0,LastValue(BuyPrice),x1,LastValue(BuyPrice),0); BuyStopline=LineArray(x0,LastValue(BuyStop2),x1,LastValue(BuyStop2),0); BuyTPline=LineArray(x0,LastValue(BSByTP1),x1,LastValue(BSByTP1),0); SellPriceline=LineArray(x0,LastValue(SellPrice),x1,LastValue(SellPrice),0); SellStopline=LineArray(x0,LastValue(SellStop2),x1,LastValue(SellStop2),0); SellTPline=LineArray(x0,LastValue(BSSlTP1),x1,LastValue(BSSlTP1),0); DayHline=LineArray(x0,LastValue(DayH),x1,LastValue(DayH),0); DayLline=LineArray(x0,LastValue(DayL),x1,LastValue(DayL),0); Plot(IIf(pShowtradeLines,SellPriceline,Null),"",colorGrey40,styleLine|styleNoRescale); if( Status("action") == actionIndicator ) ( Title = EncodeColor(colorWhite)+ "DTNM" + " - " + Name() + " - " + EncodeColor(colorYellow)+ Interval(2) + EncodeColor(colorYellow) + " - " + Date() +" - "+ EncodeColor(colorYellow) + "Open = "+EncodeColor(colorWhite)+WriteVal(O,8.2) + EncodeColor(colorYellow) + ", High = "+EncodeColor(colorWhite)+ WriteVal(H,8.2)+ EncodeColor(colorYellow) + ", Low= "+EncodeColor(colorWhite)+ WriteVal(L,8.2)+ EncodeColor(colorYellow) + ", Close= "+EncodeColor(colorWhite)+ WriteVal(C,8.2)+ EncodeColor(colorYellow) + ", Vol= "+EncodeColor(colorWhite)+ WriteVal(V,1)+("\n") ); //--------------------------------new----------------------------------------- GfxSelectFont( "Tahoma", 9, 700 ); GfxSetBkMode( 1 ); GfxSetTextColor( colorWhite ); GfxSelectSolidBrush( colorGreen ); pxHeight = Status( "pxchartheight" ) ; Left = 1100; width = 310; x = 1.5; x2 = 205; y = pxHeight/1; GfxSelectPen( colorLightBlue, 2 ); GfxRoundRect( x, y - 125, x2, y , 7, 7 ) ; GfxTextOut( (" ...................................."),97,y-115); GfxSetTextAlign(0); x = 290; x2 = 500; } //------------------------------------------------------------------------------------------------------------------------- CHA= funDTN_D((funDTN_P(funDTN_P(funDTN_P(L,C),H),O)),4); OHA = funDTN_AM( funDTN_R5( CHA,-2 ), 0.5 ); HAH = funDTN_MX( H, funDTN_MX( CHA,OHA ) ); HAL = funDTN_MN( L, funDTN_MN( CHA,OHA ) ); BG2= funDTN_H1(funDTN_P(funDTN_L1(Low,4),funDTN_A1(4)),8); BR2= funDTN_L1(funDTN_MI(funDTN_H1(High,4),funDTN_A1(4)),8); k = Optimize("K",1.75,1,5,0.25); Per =Optimize("A",10,3,30,1); j=CHA; nm=funDTN_MI(H,L); rfsctor = funDTN_WA(nm, PER); revers = funDTN_ML(K ,rfsctor); Trend = 1; NW[0] = 0; Trend = funDTN_L(Trend,NW,j,revers); Plot(NW,"",IIf(Trend ==1,6,4),4); Buy=funDTN_C3(j,nw); Short=funDTN_C3(nw,j); Sell=funDTN_C3(nw,j); Cover=funDTN_C3(j,nw); Buy=funDTN_EN(Buy,Sell); Sell=funDTN_EN(Sell,Buy); Short=funDTN_EN(Short,Cover); Cover=funDTN_EN(Cover,Short); Long=funDTN_FL(Buy,Sell); Shrt=funDTN_FL(Sell,Buy ); dist=funDTN_ML(1.5,funDTN_A1(15)); Buy2show=0; Sell2show=0; for( i = 0; i < BarCount; i++ ) { if( Buy[i] ) { Buy2show=L[i]; } if( Sell[i] ) { Sell2show=H[ i ]; } } showsl = ParamToggle("Stop Loss Line", "Hide|Show", 0); no=21; res=HHV(H,no); sup=LLV(L,no); avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0)); avn=ValueWhen(avd!=0,avd,1); s5d=IIf(avn==1,sup,res); exitlong = Cross(s5d, C); PlotShapes(exitlong * shapeStar, colorRed,0,HAH,-10); PlotShapes(exitlong * shapeHollowCircle, colorPink,0,HAH,-20); exitshort = Cross(C, s5d); PlotShapes(exitshort * shapeStar, colorGreen,0,HAL,-12); PlotShapes(exitshort * shapeHollowCircle, colorPink,0,HAL,-24); //Short = Sell; //Cover = Buy; //Buy = ExRem(Buy,Sell); //Sell = ExRem(Sell,Buy); //Short = ExRem(Short, Cover); //Cover = ExRem(Cover, Short); AlertIf(Sell,"SOUND C:\\Windows\\Media\\ringin.wav","Sell@" + WriteVal( H,1.2) ,2); AlertIf(Buy,"SOUND C:\\Windows\\Media\\ringin.wav","Buy@" + WriteVal( O,1.2),1); //----------------------new ------------------------------- /*entry =0; sig = ""; tar1 = 0; tar2 = 0; sl = 0; bars = 0; Datetim = ""; for(i=(BarCount-1);i>10 ;i--) { j = i; if(Buy[i] == 1) { entry = H[j]; sig = "BUY"; bars = i; i = 0; //Datetim="" + ValueWhen(Buy,Day(),1) + "/" + ValueWhen(Buy,Month(),1) + "/" + ValueWhen(Buy,Year(),1) + " " + ValueWhen(Buy,Hour(),1) + ":" + ValueWhen(Buy,Minute(),1); //Datetim="" + ValueWhen(Cover,Day(),1) + "/" + ValueWhen(Cover,Month(),1) + "/" + ValueWhen(Cover,Year(),1) + " " + ValueWhen(Cover,Hour(),1) + ":" + ValueWhen(Cover,Minute(),1); Datetim="" + ValueWhen(Buy,Day(),1)+ "/" + ValueWhen(Buy,Month(),1) + "/" + ValueWhen(Buy ,Year(),1) + " " + ValueWhen(Buy,Hour(),1) + ":" + ValueWhen(Buy,Minute(),1); } if(Sell[i] == 1); { sig = "SELL"; entry =L[i]; bars = i; i = 0; //Datetim="" + ValueWhen(Sell OR shrt,Day(),1) + "/" + ValueWhen(Sell OR shrt,Month(),1) + "/" + ValueWhen(Sell OR shrt,Year(),1) + " " + ValueWhen(Sell OR shrt,Hour(),1) + ":" + ValueWhen(Sell OR shrt,Minute(),1); //Datetim="" + ValueWhen(Sell,Day(),1) + "/" + ValueWhen(Sell,Month(),1) + "/" + ValueWhen(Sell,Year(),1) + " " + ValueWhen(Sell,Hour(),1) + ":" + ValueWhen(Sell,Minute(),1); } }*/ Buy1_sell0 = -1; /*for(i=1;i<BarCount;i++) { if(Buy[i] == 1) Buy1_sell0[i] = 1; else if(Short[i] == 1) Buy1_sell0[i] = 0; else Buy1_sell0[i] = Buy1_sell0[i - 1]; }*/ sig = ""; if ( sig =="BUY OR Short") { Datetim="" + ValueWhen(Buy,Day(),1) + "/" + ValueWhen(Buy,Month(),1) + "/" + ValueWhen(Buy,Year(),1) + " " + ValueWhen(Buy,Hour(),1) + ":" + ValueWhen(Buy,Minute(),1); // Datetim="" + ValueWhen(Cover,Day(),1) + "/" + ValueWhen(Cover,Month(),1) + "/" + ValueWhen(Cover,Year(),1) + " " + ValueWhen(Cover,Hour(),1) + ":" + ValueWhen(Cover,Minute(),1); } else { Datetim="" + ValueWhen(Short,Day(),1) + "/" + ValueWhen(Short,Month(),1) + "/" + ValueWhen(Short,Year(),1) + " " + ValueWhen(Short,Hour(),1) + ":" + ValueWhen(Short,Minute(),1); //Datetim="" + ValueWhen(Sell,Day(),1) + "/" + ValueWhen(Sell,Month(),1) + "/" + ValueWhen(Sell,Year(),1) + " " + ValueWhen(Sell,Hour(),1) + ":" + ValueWhen(Sell,Minute(),1); } GfxSelectFont( "Tahoma", 9, 700 ); GfxSetOverlayMode( mode = 0 ); GfxSetBkMode( 1 ); GfxSetTextColor( colorWhite ); GfxSelectSolidBrush( colorBlue ); pxHeight = Status( "pxchartheight" ) ; Left = 1100; width = 310; x = 1.5; x2 = 205; y = pxHeight/1; GfxSelectPen( colorLightBlue, 2 ); GfxRoundRect( x, y - 125, x2, y , 7, 7 ) ; GfxTextOut( ("DAY TRADING SYSTEM"),35,y-120); GfxTextOut( (" ...................................."),25,y-115); GfxSetTextAlign(0); GfxTextOut( ("Last Signal"), 5, y-100) ; //GfxTextOut( (": " + Datetim), 80, y-100) ; strBuyDatetime = "" +ValueWhen(Buy,Day(),1) + "/" + ValueWhen(Buy,Month(),1) + "/" + ValueWhen(Buy,Year(),1) + " " + ValueWhen(Buy,Hour(),1) + ":" + ValueWhen(Buy,Minute(),1); strSellDatetime = "" + ValueWhen(Short,Day(),1) + "/" + ValueWhen(Short,Month(),1) + "/" + ValueWhen(Short,Year(),1) + " " + ValueWhen(Short,Hour(),1) + ":" + ValueWhen(Short,Minute(),1); GfxTextOut( WriteIf(Buy OR Long , strBuyDatetime ,strSellDatetime ), 80, y-100) ; bf=funDTN_MI(H,B); SF=funDTN_MI(O,L); GfxSetTextColor( colorYellow); GfxTextOut( WriteIf(Buy OR Long , "BUY Signal @ = "+WriteVal(Buy2show,1),""), 20, y-85); GfxSetTextColor( colorRed ); GfxTextOut( WriteIf(Sell OR shrt , "SELL Signal @ = "+WriteVal(Sell2show,1),""),20, y-85); GfxSetTextColor( colorWhite ); GfxTextOut( WriteIf( Long AND NOT Buy, "Current P/L = "+WriteVal(C-Buy2show,1.2 ),""),20, y-17); GfxTextOut( WriteIf( shrt AND NOT Sell, "Current P/L = "+WriteVal(Sell2show-C,1.2 ),""),20, y-17); GfxTextOut( WriteIf(Buy OR Long , "Target_1 = "+WriteVal(BuyPrice,1),""), 22, y-51); GfxTextOut( WriteIf( Long AND NOT Buy, "Target_1 = "+WriteVal(BuyPrice,1),""), 22, y-51); GfxTextOut( WriteIf(Buy OR Long , "Target_2 = "+WriteVal(BSByTP1,1),""), 22, y-34); GfxTextOut( WriteIf( Long AND NOT Buy, "Target_2 = "+WriteVal(BSByTP1,1),""), 22, y-34); GfxTextOut( WriteIf(Sell OR shrt , "Target_1 = "+WriteVal(SellPrice,1),""), 22, y-51); GfxTextOut( WriteIf( shrt AND NOT Sell, "Target_1 = "+WriteVal(SellPrice,1),""), 22, y-51); GfxTextOut( WriteIf(Sell OR shrt , "Target_2 = "+WriteVal(BSSlTP1,1),""), 22, y-34); GfxTextOut( WriteIf( shrt AND NOT Sell, "Target_2 = "+WriteVal(BSSlTP1,1),""), 22, y-34); x = 290; x2 = 500; //----------------------------------------------------------------------------------------------------- GfxTextOut( WriteIf(nw, " Trailing SL : "+WriteVal(nw,1),""),10, y-68); GfxTextOut( WriteIf(Cover AND NOT Buy ," Trailing SL : "+WriteVal(nw,1 ),""),10, y-68); GfxTextOut( WriteIf(nw, " Trailing SL : "+WriteVal(nw,1),""), 10, y-68); GfxTextOut( WriteIf( Short AND NOT Sell," Trailing SL : "+WriteVal(nw,1 ),""),10, y-68); PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,HAL,-40); PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,HAH,-40); //----------------------------------------------------------------------------- GfxSetOverlayMode( mode = 0 ); GfxSelectPen( colorPink, 1 ); GfxSelectSolidBrush( colorBlack ); GfxRoundRect(730,60, 850, 90, 16, 20 ); GfxSetBkMode(1); GfxSelectFont( "Tahoma", 12, 700, False ); //GfxSetTextColor( colorBrown ); GfxSetTextAlign(0); //GfxTextOut( WriteIf(BuyPrice, "Long Target 1: "+WriteVal(BuyPrice,1.2),""),15, 73); //GfxSetTextColor( colorLightBlue ); //GfxTextOut( WriteIf(BSByTP1 , "Long Target 2: "+WriteVal(BSByTP1,1.2),""), 15, 92); //GfxSetTextColor( colorRed ); //GfxTextOut( WriteIf(SellPrice, "Short Target 1: "+WriteVal(SellPrice,1.2),""), 15, 111); Daily_Trend_UP = BuyPrice > C; Daily_Trend_DOWN = BuyPrice < C; for (i =0 ; i < BarCount; i++) { if( Daily_Trend_UP[i] ) { GfxSetTextColor( colorGreen ); GfxTextOut( WriteIf(Daily_Trend_UP , "Trend UP" ,""), 740, 65); } if( Daily_Trend_DOWN[i] ) { GfxSetTextColor( colorRed ); GfxTextOut( WriteIf(Daily_Trend_DOWN , "Trend Down" ,""), 740, 65); } } //Trend_UP_Text = WriteIf(Daily_Trend_UP, "Trend UP", ""); //Trend_DOWN_Text = WriteIf(Daily_Trend_DOWN, "Trend DOWN", ""); //----------------------------------------------------------------------------------- fibs = ParamToggle("Plot Fibs","Off|On",1); pctH = 0.325;//Param ("Pivot Hi %", 0.325,0.001,2.0,0.002); HiLB = 1;//Param ("Up LookBack",1,1,BarCount-1,1); pctL = 0.325;//Param ("Pivot Lo %", 0.325,0.001,2.0,0.002); LoLB = 1;//Param ("Down LookBack",1,1,BarCount-1,1); Back = 1;//Param ("Extend Left = 2",1,1,500,1); Fwd = 0;//Param("Plot Forward", 0, 0, 500, 1); text = ParamToggle("Plot Text","Off|On",1); hts = -14;//Param ("Text Shift", -14,-50,50,0.10); style = ParamStyle("Line Style",styleLine,styleNoLabel); x =BarIndex(); pRp = PeakBars( H, pctH, 1) == 0; yRp0 = LastValue(ValueWhen( pRp, H, HiLB)); xRp0 = LastValue(ValueWhen( pRp, x, HiLB)); pSp = TroughBars( L, pctL, 1) == 0; ySp0 = LastValue(ValueWhen( pSp, L, LoLB)); xSp0 = LastValue(ValueWhen( pSp, x, LoLB)); Delta = yRp0 - ySp0; function LFI(ret) { retval = (Delta * ret); LFIVal = IIf(ret < 1.0 AND xSp0 < xRp0, yRp0 - retval, IIf(ret < 1.0 AND xSp0 > xRp0, ySp0 + retval,IIf(ret > 1.0 AND xSp0 < xRp0, yRp0 - retval, IIf(ret > 1.0 AND xSp0 > xRp0, ySp0 + retval, Null)))); return LFIVal; } xo=Min(xSp0,xRp0)-Back; x1=BarCount-1; ////////////////////////////////////////////////////////////////// r236 = LFI(0.236); r236I = LastValue (r236,1); r382 = LFI(0.382); r382I = LastValue (r382,1); r050 = LFI(0.50); r050I = LastValue (r050,1); r618 = LFI(0.618); r618I = LastValue (r618,1); r786 = LFI(0.786); r786I = LastValue (r786,1); e127 = LFI(1.27); e127I = LastValue (e127,1); e162 = LFI(1.62); e162I = LastValue (e162,1); e200 = LFI(2.00); e200I = LastValue (e200,1); e262 = LFI(2.62); e262I = LastValue (e262,1); e424 = LFI(4.24); e424I = LastValue (e424,1); ////////////////////////////////////////////////////////////////// p00 = IIf(xSp0 > xRp0,ySp0,yRp0); p00I = LastValue (p00,1); p100 = IIf(xSp0 < xRp0,ySp0,yRp0); p100I = LastValue (p100,1); color00 =IIf(xSp0 > xRp0,colorLime,colorRed); color100 =IIf(xSp0 < xRp0,colorLime,colorRed); ////////////////////////////////////////////////////////////////// numbars = LastValue(funDTN_C(Status("barvisible"))); fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2); ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// if(text==1) { PlotText(" 0% = " + WriteVal(p00,1), LastValue(BarIndex())-(numbars/hts), p00I + 0.05, color00); PlotText("23% = " + WriteVal(r236,1), LastValue(BarIndex())-(numbars/hts), r236I + 0.05, color00); PlotText("38% = " + WriteVal(r382,1), LastValue(BarIndex())-(numbars/hts), r382I + 0.05, color00); PlotText("50% = " + WriteVal(r050,1), LastValue(BarIndex())-(numbars/hts), r050I + 0.05, color00); PlotText("62% = " + WriteVal(r618,1), LastValue(BarIndex())-(numbars/hts), r618I + 0.05, color00); PlotText("78% = " + WriteVal(r786,1), LastValue(BarIndex())-(numbars/hts), r786I + 0.05, color00); PlotText("100% = " + WriteVal(p100,1), LastValue(BarIndex())-(numbars/hts),p100I + 0.05, color00); PlotText("127% = " + WriteVal(e127,1), LastValue(BarIndex())-(numbars/hts),e127I + 0.05, color00); PlotText("162% = " + WriteVal(e162,1), LastValue(BarIndex())-(numbars/hts),e162I + 0.05, color00); PlotText("200% = " + WriteVal(e200,1), LastValue(BarIndex())-(numbars/hts),e200I + 0.05, color00); PlotText("262% = " + WriteVal(e262,1), LastValue(BarIndex())-(numbars/hts),e262I + 0.05, color00); PlotText("424% = " + WriteVal(e424,1), LastValue(BarIndex())-(numbars/hts),e424I + 0.05, color00); } //////////////////////////////////////////////////////////////////////////// YH = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high YL = TimeFrameGetPrice("L", inDaily, -1); // low YC = TimeFrameGetPrice("C", inDaily, -1); // close YO = TimeFrameGetPrice("O", inDaily); // current day open //Normal Pivot PP = (YH + YL + YC) / 3; R1 = (2 * PP) - YL; R2 = PP + (YH - YL); R3 = YH + 2*(PP-YL); S1 = (2 * PP) - YH; S2 = PP - (YH - YL); S3 = YL - 2*(YH - PP) ; // ----------------------------------------------------------------------------------- _SECTION_END();