_SECTION_BEGIN("Price"); SetBarsRequired(100000,0); GraphXSpace = 15; SetChartOptions(0,chartShowArrows|chartShowDates); SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0))); GfxSetBkMode(0); GfxSetOverlayMode(1); SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey))); //SetTradeDelays(1,1,1,1); SetPositionSize(100,spsShares); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); _SECTION_END(); DayO = SelectedValue(TimeFrameGetPrice("O", inDaily));// current day open DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close DayC2= TimeFrameGetPrice("C", inDaily, -2); DayC2I = LastValue (DayC2,1); // Two days before Close DayC3= TimeFrameGetPrice("C", inDaily, -3); DayC3I = LastValue (DayC3,1); // Three days before Close DayC4= TimeFrameGetPrice("C", inDaily, -4); DayC4I = LastValue (DayC4,1); // Four days before Close DayC5= TimeFrameGetPrice("C", inDaily, -5); DayC5I = LastValue (DayC5,1); // Five days before Close DayC6= TimeFrameGetPrice("C", inDaily, -6); DayC6I = LastValue (DayC6,1); // Six days before Close DayC7= TimeFrameGetPrice("C", inDaily, -7); DayC7I = LastValue (DayC7,1); // Seven days before Close DayC8= TimeFrameGetPrice("C", inDaily, -8); DayC8I = LastValue (DayC8,1); // Eight days before Close DayC9= TimeFrameGetPrice("C", inDaily, -9); DayC9I = LastValue (DayC9,1); // Nine days before Close DayC10= TimeFrameGetPrice("C", inDaily, -10); DayC10I = LastValue (DayC10,1); // Ten days before Close nl1= ln(DayC10/DayC9); nl1sqr= (nl1)^2; nl2= ln(DayC9/DayC8); nl2sqr= (nl2)^2; nl3= ln(DayC8/DayC7); nl3sqr= (nl3)^2; nl4= ln(DayC7/DayC6); nl4sqr= (nl4)^2; nl5= ln(DayC6/DayC5); nl5sqr= (nl5)^2; nl6= ln(DayC5/DayC4); nl6sqr= (nl6)^2; nl7= ln(DayC4/DayC3); nl7sqr= (nl7)^2; nl8= ln(DayC3/DayC2); nl8sqr= (nl8)^2; nl9= ln(DayC2/DayC); nl9sqr= (nl9)^2; TenDayLnAverage= (nl1+ nl2+ nl3+ nl4+ nl5+ nl6+ nl7+ nl8+ nl9)/9; TenDayLnSQuareAverage= (nl1sqr+ nl2sqr+ nl3sqr+ nl4sqr+ nl5sqr+ nl6sqr+ nl7sqr+ nl8sqr+ nl9sqr)/9; Varance= ((TenDayLnSQuareAverage)-(TenDayLnAverage))^2; DailyVolatility= (sqrt(Varance))*100; DailyReturn= (DayC)*(DailyVolatility)/100; Buy= C>((DayC)+((.382)*(DailyReturn))); Sell= C<((DayC)-((.382)*(DailyReturn))); 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); 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); SetPositionSize(300,spsShares); ApplyStop(0,1,10,1); //-----------end-------------- Long=Flip(Buy,Sell); Shrt=Flip(Sell,Buy); BuyPrice=ValueWhen(Buy,C); SellPrice=ValueWhen(Sell,C); Edc=( WriteIf (Buy AND Ref(shrt,-1), " BUY at "+C+" ","")+ WriteIf (Sell AND Ref(Long,-1), " SEll at "+C+" ","") ); _SECTION_END(); trendup = IIf(C>((DayC)+((.382)*(DailyReturn))), colorBlue, colorWhite); trendcolor = IIf(C<((DayC)-((.382)*(DailyReturn))), colorRed, trendup); Plot( C, "Close", trendcolor, styleCandle | styleThick ); numbars = LastValue(Cum(Status("barvisible"))); hts = -33.5; // Volatility Levels // DC = DayC; DCI = LastValue (DC,1); // Yesterday Close BY = ((DayC)+((.382)*(DailyReturn))); BYI = LastValue (BY,1); // Buy Entry Line BT1 = ((DayC)+((.618)*(DailyReturn))); BT1I = LastValue (BT1,1); // Buy Target Line 1 BT2 = ((DayC)+((.786)*(DailyReturn))); BT2I = LastValue (BT2,1); // Buy Target Line 2 BT3 = ((DayC)+(DailyReturn)); BT3I = LastValue (BT3,1); // Buy Target Line 3 SH = ((DayC)-((.382)*(DailyReturn))); SHI = LastValue (SH,1); // Sell Entry Line ST1 = ((DayC)-((.618)*(DailyReturn))); ST1I = LastValue (ST1,1); // Sell Target Line 1 ST2 = ((DayC)-((.786)*(DailyReturn))); ST2I = LastValue (ST2,1); // Sell Target Line 2 ST3 = ((DayC)-(DailyReturn)); ST3I = LastValue (ST3,1); // Sell Target Line 3 vvl = ParamToggle("Trend Levels","Hide|Show",1); if(vvl==1) { Plot(BY, "BY",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle); Plot(SH, "SH",colorRed,styleDots|styleNoLine|styleNoRescale|styleNoTitle); PlotText(" Buy " , LastValue(BarIndex())-(numbars/Hts), BYI, colorLime); PlotText(" Sell " , LastValue(BarIndex())-(numbars/Hts), SHI, colorRed); } _SECTION_BEGIN("Background text"); C11=ParamColor("up panel",colorBlack ); C12=ParamColor("dn panel",colorBlack ); C13=Param("fonts",20,10,30,1 ); C14=Param("left-right",2.1,1.0,5.0,0.1 ); C15=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( 0 ); GfxSetOverlayMode(1); GfxGradientRect(0,0,pxwidth, pxheight, C11, C12 ); GfxSelectFont("Tahoma", Status("pxheight")/C13 ); GfxSetTextColor(colorBrown); GfxSetTextAlign( 6 ); GfxTextOut( "LTP "+WriteVal(C,1.2), Status("pxwidth")/C14, Status("pxheight")/C15); GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 ); GfxSetTextColor(colorBrown); GfxTextOut( " Murali Krishna", Status("pxwidth")/C14, Status("pxheight")/C15*4 ); GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0); GfxSetTextColor(colorYellow); GfxTextOut(""+edc+"", Status("pxwidth")/1.15, Status("pxheight")/C15*0.3 );