//by trash
function CDL( array, doy )
{
Lastdoy = doy == LastValue( doy );
Dayline = array * Lastdoy;
return IIf( Dayline, Dayline, Null );
}
ext = Param("Extend Last Price Line to the Right", 10, 1, 50, 1);
Linemode = ParamList("Choose Line length", "Shortest|Current Day|Full Length");
Linecol = ParamColor("Bid Price Line Color", colorRed);
Askcol = ParamColor("Ask Price Line Color", colorBlue);
Line0 = GetRTData("Bid");
Lineask = GetRTData("Ask");
FinishL0 = EndValue( BarIndex() - ext);
Shortest = LineArray(FinishL0, Line0, FinishL0 - ext, Line0, 1);
ShortAsk = LineArray(FinishL0, Lineask, FinishL0 - ext, Lineask, 1);
priceline = CDL( Line0, DayOfYear() );
Linestyle = styleDashed|styleNoRescale|styleNoLabel;
if(Linemode == "Shortest")
{
Plot(Shortest, "", Linecol, Linestyle, 0, 0, ext);
Plot(ShortAsk, "", Askcol, Linestyle, 0, 0, ext);
}
else if (Linemode == "Current Day")
{
Plot(Shortest, "", Linecol, Linestyle, 0, 0, ext);
Plot(ShortAsk, "", Askcol, Linestyle, 0, 0, ext);
Plot(priceline, "", Linecol, Linestyle);
}
else if (Linemode == "Full Length")
{
Plot(ShortAsk, "", Askcol, Linestyle, 0, 0, ext);
Plot(Line0, "", Linecol, Linestyle, 0, 0, ext);
}
PlotText( "Bid " + WriteVal(Line0, 1.4), BarCount+ext+2, LastValue(Line0)- TickSize, Linecol);
PlotText( "Ask " + WriteVal(Lineask, 1.4), BarCount+ext+2, LastValue(Lineask)+ 0.01 * TickSize, Askcol );