Lowest price within range

wwwwww

Hello
I wanted a code that has the lowest price with its day in the 200-day period

Thanks

LLV(low,200)

Post must be at least 20 characters... yes indeed.

1 Like

Hello
Thanks
I also wanted another code

Hello

low / high >o.5
high / low > 0.5
The lowest price is divided by the highest price and the result is more than 0.5

The highest price is divided by the lowest price and the result is greater than0.5

Both conditions must be met
Then display the white line

%D9%BE%D8%AE%D8%B4

1 Like

There's a code by Pottasch in the library called 'alternative zig' which plots a zig zag using highs/lows. Actually there's a few other codes which do this. I think one of them is called zig-hi zag-lo.

1 Like
// AFL code by Edward Pottasch, Feb 2013

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
SetChartBkGradientFill(ColorRGB(200,222,9),ColorRGB(200,229,9));



procedure alternate_proc(pk,tr,sumpk,sumtr)
{
global pkg;
global trg;

pkg=pk;trg=tr;
idxpk=0;
idxtr=0;
flgtr=0;
flgpk=0;

for(i=1;i<BarCount;i++)
{
	if(pk[i] AND sumpk[i]==1 AND !tr[i] AND flgpk==0)
	{
		idxpk=i;
		flgtr=0;
	}
	else if( (pk[i] AND sumpk[i]>1 AND !tr[i]) OR (pk[i] AND flgpk==1) )
	{
		if(H[i]>=H[idxpk])
		{
			pkg[idxpk]=0;
			idxpk=i;
			flgpk=0;
		}
		else if(H[i]<H[idxpk])
		{
			pkg[i]=0;
			flgpk=0;
		}
	}
	else if(tr[i] AND sumtr[i]==1 AND !pk[i] AND flgtr==0)
	{
		idxtr=i;
		flgpk=0;
	}
	else if( (tr[i] AND sumtr[i]>1 AND !pk[i]) OR (tr[i] AND flgtr==1) )
	{
		if(L[i]<=L[idxtr])
		{
			trg[idxtr]=0;
			idxtr=i;
			flgtr=0;
		}
		else if(L[i]>L[idxtr])
		{
			trg[i]=0;
			flgtr=0;
		}
	}
	else if(pk[i] AND tr[i])
	{
		if(sumpk[i-1]>sumtr[i-1])
		{
			pkg[i]=0;
			flgtr=1;
			idxtr=i;
		}
		else if(sumtr[i-1]>sumpk[i-1])
		{
			trg[i]=0;
			flgpk=1;
			idxpk=i;
		}
	}
}
}

//SetBarsRequired(sbrAll,sbrAll);
//RequestTimedRefresh(0.1,True); 
xx=BarIndex();x=xx;Lx=LastValue(x);
nbar=Param("N Pivot Bars",5,2,50,1); 
tf=Param("Time Frame (min)",5,1,1440,1);tfrm=in1Minute*tf;
CleanPivots=ParamToggle("Use Clean Pivots","Off|On",1);
PivotSymmetry=ParamToggle("Use Symmetric Pivots","Off|On",0);
dispLabels=ParamToggle("Display Labels","Off|On",1);

TimeFrameSet(tfrm); 
if(PivotSymmetry)
{
	fc=1;
	pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;
	tr=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;
}
else
{
	fc=2;
	pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;
	tr=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;
}

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);

sumpk=Sum(pk,BarsSince(tr));"sumpk: " +WriteVal(Sumpk);
sumtr=Sum(tr,BarsSince(pk));"sumtr: " +WriteVal(Sumtr);

if(CleanPivots)
{

	alternate_proc(pk,tr,sumpk,sumtr);
	pk=pkg;
	tr=trg;
	
	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);	
}
pkh=IIf(pk,H,Null);
trl=IIf(tr,L,Null);
TimeFrameRestore();
fact=Nz(Max(tfrm/60,Interval()/60)/(Interval()/60));
if(fact==0)fact=1;
Lkbk=Nz(tfrm/Interval());
if(Lkbk>1)
{
	pk=TimeFrameExpand(pk,tfrm,expandFirst);
	pkh=TimeFrameExpand(pkh,tfrm,expandFirst);
	pkhs=IIf(!IsEmpty(pkh),1,0);pkhs=pkhs-Ref(pkhs,-1);
	pk=pk AND H==pkh;
	cond1=Sum(pk,BarsSince(pkhs==1)+1)==1 AND pk;
	pk=pk AND cond1;
	
	tr=TimeFrameExpand(tr,tfrm,expandFirst);	
	trl=TimeFrameExpand(trl,tfrm,expandFirst);
	trls=IIf(!IsEmpty(trl),1,0);trls=trls-Ref(trls,-1);
	tr=tr AND L==trl;
	cond1=Sum(tr,BarsSince(trls==1)+1)==1 AND tr;
	tr=tr AND cond1;
	
	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);
}

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;

ll_h=IIf(ll,1,0);
hl_h=IIf(hl,2,0);
hh_h=IIf(hh,3,0);
lh_h=IIf(lh,4,0);
dt_h=IIf(dt,5,0);
db_h=IIf(db,6,0);

combi=ll_h+hl_h+lh_h+hh_h+dt_h+db_h;

t0=ValueWhen(combi,combi,0);
t1=ValueWhen(combi,combi,1);
t2=ValueWhen(combi,combi,2);
t3=ValueWhen(combi,combi,3);
t4=ValueWhen(combi,combi,4);
t5=ValueWhen(combi,combi,5);

//at pk
pAx=ValueWhen(pk,tx1);pAy=ValueWhen(pk,tl1);
pBx=ValueWhen(pk,px1);pBy=ValueWhen(pk,ph1);
// at tr
tAx=ValueWhen(tr,px1);tAy=ValueWhen(tr,ph1);
tBx=ValueWhen(tr,tx1);tBy=ValueWhen(tr,tl1);

GraphXSpace=5;SetChartBkColor(ColorRGB(0,0,0));SetChartOptions(0,chartShowDates);
SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorRed,colorLightGrey)));
Plot(C,"Price",IIf(C>O,colorDarkGreen,IIf(C<=O,colorDarkRed,colorLightGrey)),64,0,0,0,0);
Plot(pkh,"",colorWhite,styleThick,0,0,0,-1);
Plot(trl,"",colorWhite,styleThick,0,0,0,-1);
PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>nbar*fact,ColorRGB(0,100,0),colorWhite),0,L,-10);
PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>nbar*fact,ColorRGB(255,0,0),colorWhite),0,H,10);

qq=Interval()/60;
if(qq < 60){tf=" min";tt=qq;}
else if(qq >= 60 AND qq < 1440){tf=" hrs";tt=qq/60;}
else if(qq >= 1440){tf=" days";tt=(qq/60)/24;}
qq=Max(tfrm/60,Interval()/60);
if(qq < 60){tfa=" min";tta=qq;}
else if(qq >= 60 AND qq < 1440){tfa=" hrs";tta=qq/60;}
else if(qq >= 1440){tfa=" days";tta=(qq/60)/24;}

Title =Name() + 
"\nNbar: " + nbar + 
"\nChart TF: " + tt + tf + 
"\nTrend TF: " + tta + tfa;

abcdy_up=27;
abcdy_dn=15;
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 Nz(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 Nz(Value);
} 
function GfxConvertBarToPixelX(bar) 
{ 
	lvb=Status("lastvisiblebar"); 
	fvb=Status("firstvisiblebar"); 
	pxchartleft=Status("pxchartleft"); 
	pxchartwidth=Status("pxchartwidth"); 
	return Nz(pxchartleft+bar*pxchartwidth/(lvb-fvb+1)); 
} 
function GfxConvertValueToPixelY(value) 
{
	local Miny,Maxy,pxchartbottom,pxchartheight; 
	Miny=Status("axisminy");
	Maxy=Status("axismaxy");
	pxchartbottom=Status("pxchartbottom");
	pxchartheight=Status("pxchartheight");
	return Nz(pxchartbottom-floor(0.5+(Value-Miny)*pxchartheight/(Maxy-Miny))); 
} 
AllVisibleBars=GetVisibleBarCount();
fvb=Status("firstvisiblebar");
abcdy_up=GfxConvertPixelToValueY(abcdy_up);
abcdy_dn=GfxConvertPixelToValueY(abcdy_dn);

for(i=0;i<AllVisibleBars;i++) 
{
	if(ll[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1); 
		GfxSetTextColor(colorYellow);GfxTextOut("LL",GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-abcdy_dn)); 
		GfxSetTextColor(colorYellow);GfxTextOut(""+L[lvix],GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-2*abcdy_dn)); 
	}
	if(hl[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1); 
		GfxSetTextColor(colorYellow);GfxTextOut("HL",GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-abcdy_dn)); 
		GfxSetTextColor(colorYellow);GfxTextOut(""+L[lvix],GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-2*abcdy_dn)); 
	}	
	if(db[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1); 
		GfxSetTextColor(colorYellow);GfxTextOut("DB",GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-abcdy_dn)); 
		GfxSetTextColor(colorYellow);GfxTextOut(""+L[lvix],GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-2*abcdy_dn)); 
	}		
	if(hh[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1); 
		GfxSetTextColor(colorYellow);GfxTextOut("HH",GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+abcdy_up)); 
		GfxSetTextColor(colorYellow);GfxTextOut(""+H[lvix],GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+1.57*abcdy_up)); 
	}	
	if(lh[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1); 
		GfxSetTextColor(colorYellow);GfxTextOut("LH",GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+abcdy_up));
		GfxSetTextColor(colorYellow);GfxTextOut(""+H[lvix],GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+1.57*abcdy_up));
	}	
	if(dt[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1); 
		GfxSetTextColor(colorYellow);GfxTextOut("DT",GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+abcdy_up)); 
		GfxSetTextColor(colorYellow);GfxTextOut(""+H[lvix],GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+1.57*abcdy_up)); 
	}		
	if(pk[i+fvb])
	{
		lvix=i+fvb;
		Plot(LineArray(pAx[lvix],pAy[lvix],pBx[lvix],pBy[lvix],0,True ),"",ColorRGB(0,0,200),styleThick);
	}
	if(tr[i+fvb])
	{
		lvix=i+fvb;
		Plot(LineArray(tAx[lvix],tAy[lvix],tBx[lvix],tBy[lvix],0,True ),"",ColorRGB(200,0,0),styleThick);
	}	
}
_SECTION_END();
`> type or paste code here`

Hello
My request is different
Please look at the picture%D8%B5%D8%AF%D8%B1%D8%A7wwww

n pivot bars=15
2704/2032=1.33 Not drawn
Although more than
1780/1573=1.13
I want this if
high / low >1.3
Drawn line

aaaaaaaaaaaaaaaa

Hello
I want a code
if
high / low >1.3 = Drawn line
Shown in the image
The ziggag code does not work like this
2704/2032=1.33 Not drawn
Although more than
1780/1573=1.13

Thanks

@mbs, your initial request was relatively simple, and was answered.

Now your requests are for more advanced specific to your need/request.

As this forum is meant for people to get "help" (not a coding service), you will find that you will get the best response when you have put some effort in yourself.

As a "NEW" member of the forum, have you done your homework yet?



Like most things, you will learn more if you try it yourself first. So, show us YOUR code, or code that you are using (with reference to original coder), how you have modified it, and where it is not giving you what you are looking for. Then you might get some more specific help.

4 Likes

Hello
Thank you
What is the best AFL for support and resistance?

@mbs,

Best is one that you write yourself with YOUR understanding and interpretation of Support and Resistance.

6 Likes

Hello
Unfortunately, I can not write the codeaaaaaaaaaaaaaaaa
Thanks

@mbs,

If you are unwilling or unable to learn, then you may be best looking in the 3rd party area for coding services.

1 Like

Please give the site address
Thanks

1 Like

The type of set up you're after is stuff Pottasch has done a lot of work on. Have a search for ABCD patterns or Harmonic patterns.

1 Like

Hello
To determine resistance and support
Do you have a code that shows the exact resistance and support?
Even ZigZag can not do this
How to start this code
sadra

Hello
I want a code
if
high / low >1.3 = Drawn line color blue
and
high / low <1.3 = Drawn line color red
Shown in the image
The ziggag code does not work like this
2704/2032=1.33 Not drawn
Although more than
1780/1573=1.13
Thanks

That's what I want
sadra%201
It differs from the zigzag chart
Thanks

Hello
The following code is incorrect
But it's a bit like code
It is possible to solve it

888888

I want a code
if
high / low >1.3 = Drawn line color blue
and
high / low <1.3 = Drawn line color red
Shown in the image
The ziggag code does not work like this
2704/2032=1.33 Not drawn
Although more than
1780/1573=1.13
Thanks

Plot(C, "Close", colorBlack, styleCandle);

GfxSetCoordsMode( 1 );
bi = BarIndex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );

function GetTop()
{
    Top = H == HHV( H, 33 ) AND Ref( HHV( H, 22 ), 22 ) < H ;
    return Top;
}

function GetValley()
{
    Valley = L == (LLV( L, 33)) AND Ref( LLV( L, 22 ), 22 ) > L ;
    return Valley;
}


pk = GetTop();
tr = GetValley();


for( i = 0; i < 7; i++ )
{
    VarSet( "px" + i, ValueWhen( pk, bi, i ) );
    VarSet( "tx" + i, ValueWhen( tr, bi, i ) );
    VarSet( "ph" + i, ValueWhen( pk, H, i ) );
    VarSet( "tl" + i, ValueWhen( tr, L, i ) );
}


function drawBearishPattern( i, patternName )
{
    GfxSelectPen( ColorRGB( 255, 0, 0 ), 2, 0 );

    GfxLineTo( px1[i], ph1[i] );
    GfxLineTo( tx1[i], tl1[i] );

}


function drawBearishPatterns()
{

    for( i = lvb; i > fvb; i-- )
               
    drawBearishPattern( i, "ww" );
                        

}
drawBearishPatterns();



Hello
How can I specify every 10 days before
How to run :

for(i=1; i<4; i++)
Plot(C, "Close", colorBlack, styleCandle);
u=Ref(Low,-10);

Thanks

5555