plz solve the problem

#25
You see, Just this statement, "...but it is not working in Version 5.6 either.",
how to expect for help. No description in details.

No you only. There are a lot of people doing the same thing here.

your problem may not see on my side.
I see no detail, i don't bother, same as other people.




If cannot work on your Ver 5.6, I assume then it will not work for the original link
http://wisestocktrader.com/indicators/3761-trend-line-breakout


Code:
SetChartOptions(0, chartShowArrows | chartShowDates);
SetChartBkColor(ParamColor("Outer Panel", colorBlack));
SetChartBkGradientFill(ParamColor("Upper Chart", colorDarkGrey), ParamColor("Lower Chart", colorDarkGrey));
GraphXSpace = Param("GraphXSpace", 10, 0, 100, 1);

colorHighliter = IIf(C >= O, ColorRGB(0, 128, 0), ColorRGB(128, 0, 0));

//Demand Point
colorDemandPoint = ParamColor("Demand Line", ColorRGB(0, 128, 255));
DemandPoint = (Ref(L, -1) < Ref(L, -2)) & (L < Ref(L, -1)) & (L < Ref(L, 1)) & (Ref(L, 1) < Ref(L, 2));

//Supply Point
colorSupplyPoint = ParamColor("Supply Line", ColorRGB(255, 128, 0));
SupplyPoint = (Ref(H, -1) > Ref(H, -2)) & (H > Ref(H, -1)) & (H > Ref(H, 1)) & (Ref(H, 1) > Ref(H, 2));

CountTrendBars = 0;
//CurrentBar = BarCount - 1;
dx0 = dx1 = dy0 = dy1 = 0;
sx0 = sx1 = sy0 = sy1 = 0;


//-- Modified by KelvinHand -----------
function VisiBarsPerChart()
{
    lvb=Status("lastvisiblebar");
    fvb=Status("firstvisiblebar");
    return Min(lvb-fvb,BarCount-fvb);
}


nBars=1.5*VisiBarsPerChart();
if (nBars <BarCount)
 iLimit = (BarCount-1) - nBars;
else
 iLimit = 0;

//------------------------------------

  
for (i = BarCount-1; i>iLimit; i--) {
	if (DemandPoint[i]) {
		if (dx1 == 0 & dy1 == 0) {
			dx1 = i;
			dy1 = L[i];
		} else {
			dx0 = i;
			dy0 = L[i];
		}
		if (dx0 != 0 & dx1 != 0 & dy0 != 0 & dy1 != 0) {
			if (dy0 < dy1) {
				a = (-dy0 + dy1) / (-dx0 + dx1);
				b = dy0 - dx0 * a;
				for (j = dx1; j < BarCount; j++) {
					if (j != dx1) {
						y2 = a * j + b;
						if (C[j] < y2) {
							dy1 = y2;
							dx1 = j;
							colorHighliter[j] = ColorRGB(128, 0, 128);
							CountTrendBars[j] = dx1 - dx0 - 1;
							break;
						}
					}
				}
				if (dy1 != y2) {
					dy1 = y2;
					dx1 = BarCount - 1;
				}
				Plot(LineArray(dx0, dy0, dx1, dy1, 0), "", colorDemandPoint, styleThick);
			}
			dx1 = dx0;
			dy1 = dy0;
			dx0 = dy0 = 0;
		}	
	}
	if (SupplyPoint[i]) {
		if (sx1 == 0 & sy1 == 0) {
			sx1 = i;
			sy1 = H[i];
		} else {
			sx0 = i;
			sy0 = H[i];
		}
		if (sx0 != 0 & sx1 != 0 & sy0 != 0 & sy1 != 0) {
			if (sy0 > sy1) {
				a = (-sy0 + sy1) / (-sx0 + sx1);
				b = sy0 - sx0 * a;
				for (j = sx1; j < BarCount; j++) {
					if (j != sx1) {
						y2 = a * j + b;
						if (C[j] > y2) {
							sy1 = y2;
							sx1 = j;
							colorHighliter[j] = ColorRGB(128, 128, 0);
							CountTrendBars[j] = sx1 - sx0 - 1;
							break;
						}
					}
				}
				if (sy1 != y2) {
					sy1 = y2;
					sx1 = BarCount - 1;
				}
				Plot(LineArray(sx0, sy0, sx1, sy1, 0), "", colorSupplyPoint, styleThick);

			}
			sx1 = sx0;
			sy1 = sy0;
			sx0 = sy0 = 0;
		}	
	}	
}

//Stop Loss & Targets
for (i = BarCount-1; i>iLimit; i--) {
	if (colorHighliter[i] == ColorRGB(128, 0, 128)) {
		StopLoss = 0;
		for (j = i - CountTrendBars[i]; j <= i; j++) {
			StopLoss = Max(H[j], StopLoss);
		}
		if (i - (BarCount - 1) != 0) {
			t1 = C[i] - (StopLoss - C[i]);
			t2 = C[i] - ((StopLoss - C[i]) * 1.272);
			t3 = C[i] - ((StopLoss - C[i]) * 1.618);
			Plot(LineArray(i, StopLoss + 0.01, BarCount - 1, StopLoss + 0.01, 0), "", colorRed, styleDots | styleNoLabel);
			Plot(LineArray(i, C[i], BarCount - 1, C[i], 0), "", colorYellow, styleDots);
			Plot(LineArray(i, t1, BarCount - 1, t1, 0), "", colorRed, styleDots | styleNoLabel);
			Plot(LineArray(i, t2, BarCount - 1, t2, 0), "", colorRed, styleDots | styleNoLabel);
			Plot(LineArray(i, t3, BarCount - 1, t3, 0), "", colorRed, styleDots | styleNoLabel);
			PlotText("Stop Loss\n@" + WriteVal(StopLoss + 0.01, 1.2), BarCount, StopLoss + 0.01, colorWhite);
			PlotText("T1 @" + WriteVal(t1, 1.2), BarCount, t1, colorWhite);
			PlotText("T2 @" + WriteVal(t2, 1.2), BarCount, t2, colorWhite);
			PlotText("T3 @" + WriteVal(t3, 1.2), BarCount, t3, colorWhite);
		}
		break;
	}
	if (colorHighliter[i] == ColorRGB(128, 128, 0)) {
		StopLoss = 9999;
		for (j = i - CountTrendBars[i]; j <= i; j++) {
			StopLoss = Min(L[j], StopLoss);
		}
		if (i - (BarCount - 1) != 0) {
			t1 = C[i] + (C[i] - StopLoss);
			t2 = C[i] + ((C[i] - StopLoss) * 1.272);
			t3 = C[i] + ((C[i] - StopLoss) * 1.618);
			Plot(LineArray(i, StopLoss - 0.01, BarCount - 1, StopLoss - 0.01, 0), "", colorRed, styleDots | styleNoLabel);
			Plot(LineArray(i, C[i], BarCount - 1, C[i], 0), "", colorYellow, styleDots);
			Plot(LineArray(i, t1, BarCount - 1, t1, 0), "", colorBrightGreen, styleDots | styleNoLabel);
			Plot(LineArray(i, t2, BarCount - 1, t2, 0), "", colorBrightGreen, styleDots | styleNoLabel);
			Plot(LineArray(i, t3, BarCount - 1, t3, 0), "", colorBrightGreen, styleDots | styleNoLabel);
			PlotText("Stop Loss\n@" + WriteVal(StopLoss - 0.01, 1.2), BarCount, StopLoss - 0.01, colorWhite);
			PlotText("T1 @" + WriteVal(t1, 1.2), BarCount, t1, colorWhite);
			PlotText("T2 @" + WriteVal(t2, 1.2), BarCount, t2, colorWhite);
			PlotText("T3 @" + WriteVal(t3, 1.2), BarCount, t3, colorWhite);
		}		
		break;
	}
}

//Price
SetBarFillColor(colorHighliter);
Plot(C, "Close", IIf(colorHighliter == ColorRGB(128, 0, 128), ColorRGB(255, 0, 255), IIf(colorHighliter == ColorRGB(128, 128, 0), colorYellow, IIf(C > O, colorBrightGreen, IIf(C < O, colorRed, colorWhite)))), styleCandle);

//Volume
/*colorVolume = ParamColor("Volume Area", ColorRGB(0, 0, 0));
Plot(Volume, "", colorVolume, styleArea | styleOwnScale | styleNoLabel, Null, Null, 0, 0, 1);*/

Title = Name() + " - {{INTERVAL}} - {{DATE}} - Open = " + NumToStr(O, 1.2) + ", High = " + NumToStr(H, 1.2) + ", Low = " + NumToStr(L, 1.2) + ", Close = " + NumToStr(C, 1.2) + " (" + WriteVal(ROC(C, 1), 1.2) + "%)"; /*, Volume = " + WriteVal(Volume, 1.2);*/


Hello Kelvinhand,

In above code..Buy-Sell arrows and Exploration code is missing.

Once u add it.. it would be really good one to pick stocks.

If u could add fresh mejanta candle (all scripts) and yellow candle (all scripts) exploration ..it would be gr8.

Thanx you
 

KelvinHand

Well-Known Member
#26
Hello Kelvinhand,

In above code..Buy-Sell arrows and Exploration code is missing.

Once u add it.. it would be really good one to pick stocks.

If u could add fresh mejanta candle (all scripts) and yellow candle (all scripts) exploration ..it would be gr8.

Thanx you

So simple only. You already described how to do it. Then see the help guide for plotshapes(). The good answer is in 1st comment.
3-4 statements only and use IIF().

Sometime is not difficult for non programmer. Just monkey see monkey do WILL work. Just that you don't want to dirty you hand.
 
Last edited:
#28
pls plot the daily tf signals on 5 min chart


_SECTION_BEGIN("Tops-Bottoms-2-3's");
xx=BarIndex();x=xx;Lx=LastValue(x);
nbar=3;
fc=2;
frat=3;
t=H>Ref(HHV(H,frat),-1) AND Ref(HHV(H,frat),frat)<H;
PHighPrice0=ValueWhen(t,H);
b=L<Ref(LLV(L,frat),-1) AND Ref(LLV(L,frat),frat)>L;
PLowPrice0=ValueWhen(b,L);
p=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;
d=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;
pk=t OR p; tr=b OR d;

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
px3=ValueWhen(pk,x,3); tx3=ValueWhen(tr,x,3);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
ph3=ValueWhen(pk,H,3); tl3=ValueWhen(tr,L,3);

Disp2=ParamToggle("Display 2-3's Labels","Show|Hide",1);

Disp3=ParamToggle("Color Labels Behind 2-3's","Show|Hide",1);
if(Disp3){
PlotShapes(shapeSquare*tr,IIf(Lx-ValueWhen(tr,x)>nbar,colorLime,colorCustom1),0,L,-10);
PlotShapes(shapeSquare*pk,IIf(Lx-ValueWhen(pk,x)>nbar,ColorRGB(255,160,122),colorCustom1),0,H,10);}

dxhm=14; dxlm=10;dxh=3;dxl=2;dyhm=5;
dylm=3;dyh=5;dyl=15;hm=30;lm=30;
function GetVisibleBarCount()
{
lvb=Status("lastvisiblebar");
fvb=Status("firstvisiblebar");
return Min(lvb-fvb,BarCount-fvb);
}
function GfxConvertPixelsToBarX(Pixels)
{
lvb=Status("lastvisiblebar");
fvb=Status("firstvisiblebar");
pxchartleft=Status("pxchartleft");
pxchartwidth=Status("pxchartwidth");
fac=pxchartwidth/Pixels;
bar=(lvb-fvb)/fac;
return bar;
}
function GfxConvertPixelToValueY(Pixels)
{
local Miny,Maxy,pxchartbottom,pxchartheight;
Miny=Status("axisminy");
Maxy=Status("axismaxy");
pxchartbottom=Status("pxchartbottom");
pxchartheight=Status("pxchartheight");
fac=pxchartheight/Pixels;
Value=(Maxy-Miny)/fac;
return Value;}

if(Disp2)
{
ll=tr AND tl1<tl2; hl=tr AND tl1>tl2; hh=pk AND ph1>ph2;
lh=pk AND ph1<ph2; dt=pk AND ph1==ph2; db=tr AND tl1==tl2;

miny=Status("axisminy");
maxy=Status("axismaxy");
AllVisibleBars=GetVisibleBarCount();
fvb=Status("firstvisiblebar");
LowMargin=Miny+GfxConvertPixelToValueY(lm);
HighMargin=Maxy-GfxConvertPixelToValueY(hm);
dyllm=GfxConvertPixelToValueY(dylm);
dyhhm=GfxConvertPixelToValueY(dyhm);
dyll=GfxConvertPixelToValueY(dyl);
dyhh=GfxConvertPixelToValueY(dyh);
dxllm=GfxConvertPixelsToBarX(dxlm);
dxhhm=GfxConvertPixelsToBarX(dxhm);
dxll=GfxConvertPixelsToBarX(dxl);
dxhh=GfxConvertPixelsToBarX(dxh);

for(i=0;i<AllVisibleBars;i++)
{
if(ll[i+fvb] AND L[i+fvb]>LowMargin) PlotText("Buy",i+fvb+dxll,L[i+fvb]-dyll,colorBlack);
if(ll[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("Buy",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorBlack);
if(hl[i+fvb] AND L[i+fvb]>LowMargin) PlotText("Buy",i+fvb+dxll,L[i+fvb]-dyll,colorBlack);
if(hl[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("Buy",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorBlack);
if(db[i+fvb] AND L[i+fvb]>LowMargin) PlotText("Buy",i+fvb+dxll,L[i+fvb]-dyll,colorBlack);
if(db[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("Buy",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorBlack);
if(hh[i+fvb] AND H[i+fvb]<HighMargin) PlotText("Sell",i+fvb+dxhh,H[i+fvb]+dyhh,colorBlack);
if(hh[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("Sell",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorBlack);
if(lh[i+fvb] AND H[i+fvb]<HighMargin) PlotText("Sell",i+fvb+dxhh,H[i+fvb]+dyhh,colorBlack);
if(lh[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("Sell",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorBlack);
if(dt[i+fvb] AND H[i+fvb]<HighMargin) PlotText("Sell",i+fvb+dxhh,H[i+fvb]+dyhh,colorBlack);
if(dt[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("Sell",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorBlack);
}}

_SECTION_END();
 

Similar threads