tf = Param("Ref TF", 1440, 1, 100000, 1) ;
datamode = ParamToggle("Data Mode", "No|Yes", 0) ;
showintitle = ParamToggle("Show in Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;
displaynexttext = ParamToggle("Display Next Text", "No|Yes", 0) ;
Clrhigh = ParamColor("Color High", colorBrown) ;
Clrlow = ParamColor("Color Low", colorGreen) ;
Clrpvt = ParamColor("Color Pivot", colorViolet) ;
showproj = ParamToggle("Show Projection", "No|Yes", 1) ;
showpvt = ParamToggle("Show Pvt", "No|Yes", 1) ;
showsec = ParamToggle("Show Secondary", "No|Yes", 1) ;
shownext = ParamToggle("Show Next", "No|Yes", 0) ;
showbias = ParamToggle("Show Pvt Bias", "No|Yes", 0) ;
shownextpvtbias = ParamToggle("Show Next Pvt Lvls", "No|Yes", 0) ;
showext = ParamToggle("Show Extension", "No|Yes", 1) ;
extend = Param("Extend By", 10, 0, 200, 1) ;
showtradearr = ParamToggle("Show Trade Arrow", "No|Yes", 0) ;
useFilter = ParamToggle("Use Filter", "No|Yes", 1) ;
filhigh = ParamField("Filter High", 0) ;
fillow = ParamField("Filter Low", 0) ;
showbiaszone = ParamToggle("Show bias zone", "No|Yes", 1) ;
biaszonelayer = Param("Bias Zone Layer", -3, -5, 5, 1) ;
xst = BarCount - (extend) +1 ;
xed = BarCount -1 ;
showtext = ParamToggle("Show Text", "No|Yes", 1) ;
txtpos = BarCount + extend-5 ;
fil = Param("Text Filter", 1, 1, 10000, 1) ;
datamodestyle = styleNoRescale ;
if (NOT showintitle)
datamodestyle |= styleNoTitle ;
if (NOT showlabel)
datamodestyle |= styleNoLabel ;
if (datamode)
datamodestyle = styleNoDraw|styleNoTitle|styleNoLabel|styleNoRescale ;
tfs = tf * in1Minute ;
strtf = NumToStr(tf, 1.0) ;
TimeFrameSet(tfs) ;
Refp = IIf(C > O, H, IIf(C < O, L, C)) ;
x = (H+L+C+Refp) / 2 ;
range = H-L ;
tfh = H ;
tfo = O ;
tfc = C ;
tfl = L ;
projhigh = Ref(x, -1) - Ref(L, -1) ;
projlow = Ref(x, -1) - Ref(H, -1) ;
bc = (Ref(H, -1) + Ref(L, -1))/2 ;
tc = Ref(x,-1) - bc ;
nexth = x - L ;
nextl = x - H ;
nexth2 = x/2 + range ;
nextl2 = x/2 - range ;
nextbc = (H + L)/2 ;
nexttc = x - nextbc ;
Lastbar = BarIndex() == BarCount-1;
H2 = Ref(x,-1)/2+Ref(range, -1) ;
L2 = Ref(x, -1)/2-Ref(range, -1) ;
x0 = Ref(x,-1)/2 ;
TimeFrameRestore() ;
tfhe = TimeFrameExpand(tfh, tfs, expandFirst) ;
tfoe = TimeFrameExpand(tfo, tfs, expandFirst) ;
tfce = TimeFrameExpand(tfc, tfs, expandFirst) ;
tfle = TimeFrameExpand(tfl, tfs, expandFirst) ;
phe = TimeFrameExpand(projhigh, tfs, expandFirst) ;
ple = TimeFrameExpand(projlow, tfs, expandFirst) ;
bce = TimeFrameExpand(bc, tfs, expandFirst) ;
tce = TimeFrameExpand(tc, tfs, expandFirst) ;
H2e = TimeFrameExpand(H2, tfs, expandFirst) ;
L2e = TimeFrameExpand(L2, tfs, expandFirst) ;
x0e = TimeFrameExpand(x0, tfs, expandFirst) ;
Nullat = x0e != Ref(x0e, 1) ;
nexthe = TimeFrameExpand(nexth , tfs, expandFirst) ;
nextle = TimeFrameExpand(nextl , tfs, expandFirst) ;
nexth2e = TimeFrameExpand(nexth2 , tfs, expandFirst) ;
nextl2e = TimeFrameExpand(nextl2 , tfs, expandFirst) ;
nextbce = TimeFrameExpand(nextbc , tfs, expandFirst) ;
nexttce = TimeFrameExpand(nexttc , tfs, expandFirst) ;
nextpe = TimeFrameExpand(x/2, tfs, expandFirst) ;
if(shownextpvtbias)
{
Refnextp = IIf(C > tfoe, tfhe, IIf(C < tfoe, tfle, C)) ;
nextx = (tfhe+tfle+C+Refnextp) / 2 ;
Plot(nextx/2, "next pvt", colorViolet, styleDots|styleNoRescale) ;
}
Lastbare = TimeFrameExpand(Lastbar , tfs, expandFirst) ;
if (showproj)
{
Plot(IIf(nullat, Null, tce), strtf+" Proj TC", Clrhigh, styleDashed|datamodestyle ) ;
Plot(IIf(nullat, Null, bce), strtf+" Proj BC", Clrlow, styleDashed|datamodestyle) ;
Plot(IIf(nullat, Null, phe), strtf+" Proj High 1", Clrhigh, styleThick|styleDots|datamodestyle ) ;
Plot(IIf(nullat, Null, ple), strtf+" Proj Low 1", Clrlow, styleThick|styleDots|datamodestyle) ;
}
if(showext)
{
Hdlast = SelectedValue(phe) ;
Ldlast = SelectedValue(ple) ;
pvtdlast = SelectedValue(x0e) ;
nextpeLast = SelectedValue(nextpe) ;
Hplot = LineArray(xst, Hdlast, xed, Hdlast) ;
Plot(Hplot, "", Clrhigh, styleLine|styleDots|datamodestyle|styleNoLabel , 0,0,extend) ;
if (showtext)
PlotText(NumToStr(HdLast, 8.1), txtpos, HdLast+fil, Clrhigh) ;
LPlot = LineArray(xst, Ldlast, xed, Ldlast) ;
Plot(LPlot, "", Clrlow, styleLine|styleDots|datamodestyle|styleNoLabel , 0,0,extend) ;
if (showtext)
PlotText(NumToStr(LdLast, 8.1), txtpos, LdLast+fil, Clrlow) ;
CPlot = LineArray(xst, pvtdlast , xed, pvtdlast ) ;
Plot(CPlot, "", Clrpvt, styleLine|styleDots|datamodestyle|styleNoLabel , 0,0,extend) ;
if (showtext)
PlotText(NumToStr(pvtdLast, 8.1), txtpos, pvtdLast+fil, Clrpvt) ;
nextpPlot = LineArray(xst, nextpeLast , xed, nextpeLast ) ;
Plot(nextpPlot , "", Clrpvt, styleLine|styleDashed|datamodestyle|styleNoLabel , 0,0,extend) ;
if (showtext)
PlotText(NumToStr(nextpeLast , 8.1), txtpos, nextpeLast +fil, Clrpvt) ;
}
if (showsec)
{
Plot(IIf(nullat, Null, H2e), strtf+" Proj High 2", Clrhigh, styleThick|datamodestyle ) ;
if (showtext)
PlotText(NumToStr(SelectedValue(H2e), 8.1), txtpos, SelectedValue(H2e)+fil, Clrhigh) ;
Plot(IIf(nullat, Null, L2e), strtf+" Proj Low 2", Clrlow, styleThick|datamodestyle ) ;
if (showtext)
PlotText(NumToStr(SelectedValue(L2e), 8.1), txtpos, SelectedValue(L2e)+fil, Clrlow) ;
}
Clrbc = colorPink ;
Clrtc = colorLightBlue ;
doblend = True ;
Clrblend = colorWhite ;
if (doblend)
{
Clrbc = ColorBlend(Clrbc, Clrblend) ;
Clrtc = ColorBlend(Clrtc, Clrblend) ;
}
if (showpvt)
Plot(IIf(nullat, Null, x0e), strtf+" Pvt", Clrpvt, styleThick|styleDots|datamodestyle ) ;
showextzone = ParamToggle("Show Zone Extension", "No|Yes", 1) ;
extendzone = Param("Extend Zone", 15, 0, 100, 1) ;
extlayer = Param("Extend Layer", -1, -5, 5, 1) ;
Clr =IIf(bce < x0e, Clrbc, Clrtc) ;
if (showbiaszone)
PlotOHLC(tce, tce, bce, bce, "", Clr, styleCloud|datamodestyle,0,0,0,biaszonelayer ) ;
if (showextzone)
{
x0 = BarCount - (extendzone+1)+1 ;
x1 = BarCount -1 ;
Hdlast = SelectedValue(tce) ;
Ldlast = SelectedValue(bce) ;
Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
// Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
// Plot(LPlot, "VALext"+strnday, colorGreen, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", SelectedValue(Clr) , styleCloud|styleNoLabel|styleNoTitle|styleNoRescale, 0,0,extendzone ,extlayer ) ;
}
if (showbias)
{
Clr = IIf(C > x0e, colorBlue, colorRed) ;
Plot(2, "", Clr, styleArea|datamodestyle |styleOwnScale, 0, 100) ;
}
if (shownext)
{
Plot(IIf (Lastbare , nexthe, Null) , "", Clrhigh, styleThick|styleDashed|datamodestyle ) ;
Plot(IIf (Lastbare , nextle, Null), "", Clrlow, styleThick|styleDashed|datamodestyle ) ;
Plot(IIf (Lastbare , nextpe, Null), "", Clrpvt, styleThick|styleDashed|datamodestyle ) ;
}
if (displaynexttext)
{
fontsz = Param("Font Size", 12, 1, 100, 1) ;
GfxSelectFont( "Tahoma", fontsz , 100 );
GfxSetBkMode( 1 );
pxHeight = Status( "pxchartheight" ) ;
pxWidth = Status( "pxchartwidth");
dt_flag = 16 /*wordbreak*/;
textht = Param("Text Ht", 75, 1, 300,1) ;
textwidth = Param("Text Width", 200, 1, 300,1) ;
textgap = 40 ;
x = pxWidth - Param("from right edge", 200 , 0, 1000, 1) ;
y = Param("From Top", 100, 0, 1000, 1) ;
Clr = colorBrown ;
GfxSetTextColor( Clr );
GfxDrawText("Demark H2: "+NumToStr(SelectedValue(nexth2e), 1.1), x,y, x+textwidth , y+textht , dt_flag) ;
y+=fontsz+2 ;
GfxDrawText("Demark H1: "+NumToStr(SelectedValue(nexthe), 1.1), x,y, x+textwidth , y+textht , dt_flag) ;
y+=fontsz+2 ;
GfxDrawText("Zone High: "+NumToStr(Max(SelectedValue(nextbce), SelectedValue(nexttce)), 1.1), x,y, x+textwidth , y+textht , dt_flag) ;
y+=fontsz+2 ;
GfxDrawText("Demark Pvt: "+NumToStr(SelectedValue(nextpe), 1.1), x,y, x+textwidth , y+textht , dt_flag) ;
y+=fontsz+2 ;
GfxDrawText("Zone Low: "+NumToStr(Min(SelectedValue(nextbce), SelectedValue(nexttce)), 1.1), x,y, x+textwidth , y+textht , dt_flag) ;
y+=fontsz+2 ;
GfxDrawText("Demark L1: "+NumToStr(SelectedValue(nextle), 1.1), x,y, x+textwidth , y+textht , dt_flag) ;
y+=fontsz+2 ;
GfxDrawText("Demark L2: "+NumToStr(SelectedValue(nextl2e), 1.1), x,y, x+textwidth , y+textht , dt_flag) ;
y+=fontsz+2 ;
y+=fontsz+2 ;
GfxDrawText("Demark TC: "+NumToStr(SelectedValue(nexttce), 1.1), x,y, x+textwidth , y+textht , dt_flag) ;
}
if (showtradearr)
{
biaslevel = x0e ;
Buy = C > biaslevel AND IIf(usefilter, C>filhigh, True) ;
Short = C < biaslevel AND IIf(usefilter, C< fillow, True) ;
Sell = IIf(usefilter, C < fillow AND C > biaslevel, False) ;
Cover = IIf(usefilter, C > filhigh AND C < biaslevel, False) ;
Sell = ExRem(Sell, Short) ;
Cover = ExRem(Cover, Buy) ;
Buy = ExRem(Buy, Short OR Sell) ;
Short = ExRem(Short, Buy OR Cover) ;
PlotShapes(Buy*shapeUpArrow, colorBlue, 0, H, 12) ;
PlotShapes(Short*shapeDownArrow, colorRed, 0, L, 12) ;
PlotShapes(Cover*shapeUpArrow, colorBlack, 0, H, 12) ;
PlotShapes(Sell*shapeDownArrow, colorBlack, 0, L, 12) ;
}
showsr = ParamToggle("Show s/r", "No|Yes", 1) ;
showzone = ParamToggle("Show Zone", "No|Yes", 1) ;
if (showsr)
{
Hx = IIf(bce > x0e, bce, tce) ;
Lx = IIf(bce < x0e, bce, tce) ;
tr = IIf(H2e < C, Null, H2e) ;
tr = IIf(phe > C, phe, tr) ;
tr = IIf(Hx > C, Hx, tr) ;
tr = IIf(x0e > C, x0e, tr) ;
tr = IIf(Lx > C, Lx, tr) ;
tr = IIf(ple > C, ple, tr) ;
tr = IIf(L2e > C, L2e, tr) ;
ts = IIf(L2e > C, Null, L2e) ;
ts = IIf(ple < C, ple, ts) ;
ts = IIf(Lx < C, Lx, ts) ;
ts = IIf(x0e < C, x0e, ts) ;
ts = IIf(Hx < C, Hx, ts) ;
ts = IIf(phe < C, phe, ts) ;
ts = IIf(H2e < C, H2e, ts) ;
totfontsz = Param("Tot Bias Font Size", 16, 1, 100, 1) ;
GfxSelectFont( "Tahoma", totfontsz , 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( ParamColor("Tot Text Color", colorBlack) );
pxHeight = Status( "pxchartheight" ) ;
pxWidth = Status( "pxchartwidth");
dt_flag = 16 /*wordbreak*/;
tottextht = Param("Tot Text Ht", 25, 1, 300,1) ;
tottextwidth = Param("Tot Text Width", 200, 1, 300,1) ;
tottextgap = 40 ;
totx = pxWidth - Param("Tot Bias from right edge", 250 , 0, 1000, 1) ;
toty = Param("Tot Bias From Top", 70, 0, 1000, 1) ;
trs = SelectedValue(tr) ;
inzone = C >= Lx AND C <= Hx ;
zonetxt = "" ;
if (SelectedValue(inzone))
zonetxt = "In ZONE" ;
if (trs) // != Null)
{
GfxDrawText("TR: " + NumToStr(tr, 1.1), totx,toty, totx+tottextwidth , toty+tottextht , dt_flag) ;
}
tss = SelectedValue(ts) ;
if (tss)// != Null)
{
toty += tottextht ;
GfxDrawText("TS: " + NumToStr(ts, 1.1), totx,toty, totx+tottextwidth , toty+tottextht , dt_flag) ;
}
if (showzone)
{
toty += tottextht ;
GfxDrawText(zonetxt, totx,toty, totx+tottextwidth , toty+tottextht , dt_flag) ;
}
}