Simple Coding Help - No Promise.

cellclinic

Well-Known Member
Hello Friends :)

I need one more help to make an afl ... requirements are based on rsi are as follows ...

Buy when rsi closed above 61.10 level
Sell when rsi closed below 38.20 level
If possible ... if rsi is above 50 buy zone if below 50 sell zone ...

Thanks :)
 
pratap's ema cross over pivots.

Code:
_SECTION_BEGIN("Visual Pivots");
// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email][email protected][/email]
//

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

SetChartBkColor( ParamColor("BKGrnd", ColorRGB( 190, 190, 190 ) ) ); 


Plot( C, "Close", ParamColor("Candle Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 



ro = ParamField("Open", 0) ;
rh = ParamField("High", 1) ;
rl = ParamField("Low", 2) ;
rc = ParamField("Close", 3) ;


P = (rH+rL+rC)/3 ;
p1 = Param("Fast", 1, 1, 100, 1) ;
p2 = Param("Slow", 3, 1, 100, 1) ;
usebpvts = ParamToggle("Use Body Pvts", "No|Yes", 0) ;
isemapvts = ParamToggle("Pvt Type", "H-L|EMA", 1) ;

ismph = H-H ;
ismpl = L-L ;
bph = Max(rO,rC);
bpl = Min(rO,rC);

if (isemapvts)
{
EMA1 = EMA(P, p1) ;
EMA2 = EMA(P, p2) ;

upcross = Cross(EMA1, EMA2) ;
downcross = Cross(EMA2, EMA1) ;

//bph = Max(O,C);
//bpl = Min(O,C);
bi = BarIndex() ;

mphbar = HighestSinceBars(upcross, rH) ;
mplbar = LowestSinceBars(downcross, rL) ;

mphbi = ValueWhen(downcross, bi, 0) - ValueWhen(downcross, mphbar, 0) ;
ismph = mphbi == bi ;

mplbi = ValueWhen(upCross, bi, 0) - ValueWhen(upCross, mplbar, 0) ;
ismpl = mplbi == bi ;

ismph = IIf(downCross AND mphbar == 0, True, ismph) ;
ismpl = IIf(upcross AND mplbar == 0, True, ismpl) ;

bmphbar = HighestSinceBars(upcross, bph) ;
bmplbar = LowestSinceBars(downcross, bpl) ;

bmphbi = ValueWhen(downcross, bi, 0) - ValueWhen(downcross, bmphbar, 0) ;
isbmph = bmphbi == bi ;

bmplbi = ValueWhen(upCross, bi, 0) - ValueWhen(upCross, bmplbar, 0) ;
isbmpl = bmplbi == bi ;

isbmph = IIf(downCross AND bmphbar == 0, True, isbmph) ;
isbmpl = IIf(upcross AND bmplbar == 0, True, isbmpl) ;
}
else
{
	isbmph = ismph = rH > Ref(rH, -1) AND rH > Ref(rH, 1) ;
	isbmpl = ismpl = rL < Ref(rL, -1) AND rL < Ref(rL, 1) ;

}

showminor = ParamToggle("Show Minor Pvts", "No|Yes", 1) ;

issquare = ParamToggle("Pvt style", "Circle|Square", 0) ;
Clrmph = ParamColor("MPH Color", colorGreen) ;
Clrmpl = ParamColor("MPL Color", colorBrown) ;

pvtmarker = IIf(issquare, shapeSmallSquare, shapeSmallCircle) ;

if (showminor)
{
if (usebpvts)
{
	PlotShapes(isbmph*pvtmarker , Clrmph , 0, rH, 12) ;
	PlotShapes(isbmpl*pvtmarker , Clrmpl, 0, rL, -12) ;
}
else
{
	PlotShapes(ismph*pvtmarker , Clrmph , 0, rH, 12) ;
	PlotShapes(ismpl*pvtmarker , Clrmpl, 0, rL, -12) ;
}
}

showminorlvls = ParamToggle("Show Minor Levels", "No|Yes", 1) ;

mph = ValueWhen(ismph, rH) ;
mpl = ValueWhen(ismpl, rL) ;

if (showminorlvls)
{
	x = LineArray(0, SelectedValue(mph), (BarCount-1), SelectedValue(mph));

	Plot(x, "", colorGold, styleDashed);

	x = LineArray(0, SelectedValue(mpl), (BarCount-1), SelectedValue(mpl));

	Plot(x, "", colorGold, styleDashed);
}

showminortrend = ParamToggle("Show Minor Trend", "No|Yes", 0) ;
if (showminortrend)
{
	// initialize minor levels
	mph = ValueWhen(ismph, rH) ;
	mpl = ValueWhen(ismpl, rL) ;
	mbph = ValueWhen(isbmph, bph) ;
	mbpl = ValueWhen(isbmpl, bpl) ;

	// minor trend
	mut = rH > mph OR (rC > mbph) OR (ismph AND rH > Ref(mph, -1));
	mdt = rL < mpl OR (rC < mbpl) OR (ismpl AND rL < Ref(mpl, -1));
	mdt = Flip(mdt, mut) ;
	mut = Flip(mut, mdt) ;
	//mutst = ExRem(mut, mdt) ;
	//mdtst = ExRem(mdt, mut) ;
	
	Clr = IIf(mut, colorBlue, colorRed) ;
	PlotOHLC(rO,rH,rL,rC, "", Clr, styleCandle|styleNoLabel);
	Plot(4, "", Clr, styleArea|styleOwnScale, 0, 100, 0, -1) ;

}


tffactor = Param("TF Factor", 3, 1, 100, 1)  ;
showhigher = ParamToggle("Show Higher", "No|Yes", 0) ;

if (showhigher)
{
tfs = tffactor *Interval() ;

TimeFrameSet(tfs) ;

if (isemapvts)
{
Ptf = (H+L+C)/3 ;
EMA1tf = EMA(Ptf, p1) ;
EMA2tf = EMA(Ptf, p2) ;

upcrosstf = Cross(EMA1tf, EMA2tf) ;
downcrosstf = Cross(EMA2tf, EMA1tf) ;
bphtf = Max(O,C) ;
bpltf = Min(O,C) ;

if (usebpvts)
{
	Refhtf = bphtf ;
	Refltf = bpltf ;
}
else
{
	Refhtf = H ;
	Refltf = L ;
}

mphbartf = HighestSinceBars(upcrosstf, Refhtf) ;
mplbartf = LowestSinceBars(downcrosstf, Refltf) ;

bitf = BarIndex() ;
mphbitf = ValueWhen(downcrosstf, bitf, 0) - ValueWhen(downcrosstf, mphbartf, 0) ;
ismphtf = mphbitf == bitf ;

mplbitf = ValueWhen(upCrosstf, bitf, 0) - ValueWhen(upCrosstf, mplbartf, 0) ;
ismpltf = mplbitf == bitf ;

ismphtf = IIf(downCrosstf AND mphbartf == 0, True, ismphtf) ;
ismpltf = IIf(upcrosstf AND mplbartf == 0, True, ismpltf) ;
}
else
{
	ismphtf = H > Ref(H, -1) AND H > Ref(H, 1) ;
	ismpltf = L < Ref(L, -1) AND L < Ref(L, 1) ;
}

if (showminortrend)
{
	// initialize minor levels
	mphtf = ValueWhen(ismphtf, H) ;
	mpltf = ValueWhen(ismpltf, L) ;
	mbphtf = ValueWhen(ismphtf, bphtf) ;
	mbpltf = ValueWhen(ismpltf, bpltf) ;

	// minor trend
	muttf = H > mphtf OR (C > mbphtf) OR (ismphtf AND H > Ref(mphtf, -1));
	mdttf = L < mpltf OR (C < mbpltf) OR (ismpltf AND L < Ref(mpltf, -1));
	mdttf = Flip(mdttf, muttf) ;
	muttf = Flip(muttf, mdttf) ;
	//mutst = ExRem(mut, mdt) ;
	//mdtst = ExRem(mdt, mut) ;
	
	Clrtf = IIf(muttf, colorBlue, colorRed) ;
//	PlotOHLC(rO,rH,rL,rC, "", Clr, styleCandle|styleNoLabel);
	Clrtfe = TimeFrameExpand(Clrtf, tfs, expandLast) ;
	Plot(2, "", Clrtfe, styleArea|styleOwnScale, 0, 100) ;


}



ismphtfe = TimeFrameExpand(ismphtf, tfs, expandFirst) ;
ismpltfe = TimeFrameExpand(ismpltf, tfs, expandFirst) ;

He=TimeFrameExpand(H, tfs, expandFirst) ;
Le=TimeFrameExpand(L, tfs, expandFirst) ;

TimeFrameRestore() ;

ishtfmph = IIf(ismph == ismphtfe, 1, 0) ;
ishtfmpl = IIf(ismpl == ismpltfe, 1, 0) ;


PlotShapes(ismphtfe *shapeSmallSquare, Clrmph , 0, He, 12) ;
PlotShapes(ismpltfe *shapeSmallSquare, Clrmpl, 0, Le, -12) ;

showhtflvls = ParamToggle("Show HTF levels", "No|Yes", 1) ;
Clrhtflvl = colorPaleGreen ;

//Plot(2, "", IIf(ismph , colorBlue, IIf(ismpl, colorRed, colorGrey40)), styleArea|styleOwnScale, 0, 100) ;
//Plot(4, "", IIf(ishtfmph , colorBlue, IIf(ishtfmpl , colorRed, colorGrey40)), styleArea|styleOwnScale, 0, 100) ;
if (showhtflvls )
{
	mphhtf = ValueWhen(ismphtfe , He, 1) ;
	mplhtf = ValueWhen(ismpltfe , Le, 1) ;
	x = LineArray(0, SelectedValue(mphhtf), (BarCount-1), SelectedValue(mphhtf));

	Plot(x, "", Clrhtflvl , styleDashed);

	x = LineArray(0, SelectedValue(mplhtf), (BarCount-1), SelectedValue(mplhtf));

	Plot(x, "", Clrhtflvl , styleDashed);
}


//Plot(2, "", IIf(ismphtfe , colorRed, IIf(ismpltfe , colorBlue, colorGrey40)), styleArea|styleOwnScale, 0, 100) ;
//Plot(4, "", IIf(ismph, colorRed, IIf(ismpl , colorBlue, colorGrey40)), styleArea|styleOwnScale, 0, 100) ;
}
_SECTION_END();

Based on fractals
Code:
_SECTION_BEGIN("fractals hh hl ll lh");
// Fractals
// AFL code by Edward Pottasch, Apr 2013
RequestTimedRefresh(0.1,True); 
xx=BarIndex();x=xx;Lx=LastValue(x);
rightStrength=Param("Fractal Pivot Right side Strength",5,2,50,1); 
leftStrength=Param("Fractal Pivot Left side Strength",5,2,50,1); 
tf=Param("Time Frame (min)",3,1,1440,1);tfrm=in1Minute*tf;
CleanPivots=ParamToggle("Clean Pivots ","Off|On",0);
Cttop=Param("Code Title Top",15,1,250,1); 
Ctspac=Param("Code Title Spacing",15,1,250,1);
dispLabels=ParamToggle("Display Labels","Off|On",1);
LabelColor=ParamColor("Label Color",colorBlack);
GfxSetTextColor(ParamColor("Code Title Color",colorBlack));
backGroundColor=ParamColor("Chart Background Color",colorLightGrey);

TimeFrameSet(tfrm); 
pk=H>Ref(HHV(H,leftStrength),-1) AND Ref(HHV(H,rightStrength),rightStrength)<=H;
tr=L<Ref(LLV(L,leftStrength),-1) AND Ref(LLV(L,rightStrength),rightStrength)>=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);
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);

if(CleanPivots)
{
	pk=IIf((ph0>=ph1 AND tx0>px0 AND px0!=px1) 
	OR (ph1<ph2 AND px2>tx1)
	OR (ph0>=ph1 AND tx0<px0 AND tx0==tx1 AND px0!=px1)
	,False,pk);
	tr=IIf((tl0<=tl1 AND px0>tx0 AND tx0!=tx1) 
	OR (tl1>tl2 AND tx2>px1)
	OR (tl0<=tl1 AND px0<tx0 AND px0==px1 AND tx0!=tx1)
	,False,tr);
	
	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);
	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);	
}

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

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;

GraphXSpace=5;SetChartBkColor(backGroundColor);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,"",colorRed,styleThick,0,0,0,-1);
Plot(trl,"",colorBrightGreen,styleThick,0,0,0,-1);
PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>=rightStrength*fact,ColorRGB(0,100,0),colorWhite),0,L,-10);
PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>=rightStrength*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;}

GfxSetOverlayMode(0);
GfxSetBkMode(1);
GfxSelectFont("Tahoma",11,200);
GfxTextOut("Right Strenght: "+rightStrength,5,Cttop);
GfxTextOut("Left Strenght: "+leftStrength,5,Cttop+Ctspac);
GfxTextOut("Chart Timeframe: "+tt+""+tf,5,Cttop+Ctspac*2);
GfxTextOut("Pivot Timeframe: "+tta+""+tfa,5,Cttop+Ctspac*3);

abcdy_up=27;
abcdy_dn=15;
function GetVisibleBarCount() 
{
	lvb=Status("lastvisiblebar");
	fvb=Status("firstvisiblebar");
	return Min(lvb-fvb,BarCount-fvb);
} 
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++) 
{
	GfxSelectFont("Tahoma",8,500);GfxSetBkMode(1); 
	if(ll[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;
		GfxSetTextColor(LabelColor);GfxTextOut("LL",
		GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-abcdy_dn)); 
	}
	if(hl[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;
		GfxSetTextColor(LabelColor);GfxTextOut("HL",
		GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-abcdy_dn)); 
	}	
	if(db[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;
		GfxSetTextColor(LabelColor);GfxTextOut("DB",
		GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-abcdy_dn)); 
	}		
	if(hh[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;
		GfxSetTextColor(LabelColor);GfxTextOut("HH",
		GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+abcdy_up)); 
	}	
	if(lh[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;
		GfxSetTextColor(LabelColor);GfxTextOut("LH",
		GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+abcdy_up)); 
	}	
	if(dt[i+fvb] AND dispLabels)
	{
		lvix=i+fvb;
		GfxSetTextColor(LabelColor);GfxTextOut("DT",
		GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+abcdy_up)); 
	}
}
_SECTION_END();
 

trash

Well-Known Member
Dear Trash,

3 years ago, people ask "where can I get it ?" but did not reply.
Do you willing to share this advance method of your here ?

I think not, So giving this guy a simple solution, nothing wrong.
Just because a video or pic is visible publicly doesn't always mean that the its content is directed to the general public at the same time. It's the same thing as if you would meet a friend on a public place showing him some video or picture and at same time some strangers comes along looking over shoulders and asking "What is that? I wanna get that?". You would possibly say "Get lost and mind your own business" or something.


OK I got it. You are playing with the Amibroker COM Window Object.
It seen to me is one of the Tomasz Janeczko's task list long time ago.

If not release out, then the stability is not assure.
As for last sentence ... No, the reason is that AB are afraid of the fact that it would cause additional support traffic for T.J. & co because people would not understand how to use it despite of being explained in the help. Just look at this forum and others. 90% sheer awkwardness and unwillingness to gain knowledge by reading/studying what has already been written and evolving from it but instead constantly staying dependent sheep being reliant on others because it's so much more comfortable. Many times I wonder how such people are able to find buy and sell buttons. I guess they just dream about their existences because of being blind or even incompetent in reality.
 

Nehal_s143

Well-Known Member
I am using below afl, buy sell is cross of stop loss line, problem is signal is not fired on cross of stop loss, but signal is fired on back candle after few candles are formed...

please help to fire signal at time of crossing SL and not at back candle

Code:
_SECTION_BEGIN("Price");
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("10min ST");
tf=10;
tfrm=in1Minute*tf;
TimeFrameSet(tfrm);

Factorstt=Param("Factor",3,1,10,0.1);

Pdstt=Param("ATR Periods",10,1,100,1);


Upstt=(H+L)/2+(Factorstt*ATR(Pdstt));

Dnstt=(H+L)/2-(Factorstt*ATR(Pdstt));

iATRstt=ATR(Pdstt);

TrendUpstt=TrendDownstt=Null;

trendstt[0]=1;

changeOfTrendstt=0;

flagstt=flaghstt=0;



for (i = 1; i <BarCount-1; i++) {

      TrendUpstt[i] = Null;

      TrendDownstt[i] = Null;

     

      trendstt[i]=1;

   

      

      if (Close[i]>Upstt[i-1]) {

         trendstt[i]=1;

         if (trendstt[i-1] == -1) changeOfTrendstt = 1;

         

      }

      else if (Close[i]<Dnstt[i-1]) {

         trendstt[i]=-1;

         if (trendstt[i-1] == 1) changeOfTrendstt = 1;

      }

      else if (trendstt[i-1]==1) {

         trendstt[i]=1;

         changeOfTrendstt = 0;       

      }

      else if (trendstt[i-1]==-1) {

         trendstt[i]=-1;

         changeOfTrendstt = 0;

      }



      if (trendstt[i]<0 && trendstt[i-1]>0) {

         flagstt=1;

      }

      else {

         flagstt=0;

      }

      

      if (trendstt[i]>0 && trendstt[i-1]<0) {

         flaghstt=1;

      }

      else {

         flaghstt=0;

      }

      

      if (trendstt[i]>0 && Dnstt[i]<Dnstt[i-1]){

         Dnstt[i]=Dnstt[i-1];

		}

      

      if (trendstt[i]<0 && Upstt[i]>Upstt[i-1])

        { Upstt[i]=Upstt[i-1];

		}

      

      if (flagstt==1)

       {  Upstt[i]=(H[i]+L[i])/2+(Factorstt*iATRstt[i]);;

        } 

      if (flaghstt==1)

        { Dnstt[i]=(H[i]+L[i])/2-(Factorstt*iATRstt[i]);;

         }

      if (trendstt[i]==1) {

         TrendUpstt[i]=Dnstt[i];

         if (changeOfTrendstt == 1) {

            TrendUpstt[i-1] = TrendDownstt[i-1];

            changeOfTrendstt = 0;

         }

      }

      else if (trendstt[i]==-1) {

         TrendDownstt[i]=Upstt[i];

         if (changeOfTrendstt == 1) {

            TrendDownstt[i-1] = TrendUpstt[i-1];

            changeOfTrendstt = 0;

         }

      }

   } 

TimeFrameRestore();


TrendUpft = TimeFrameExpand( TrendUpstt, tfrm);
TrendDownft = TimeFrameExpand( TrendDownstt, tfrm);


Plot(TrendUpft,"Trend",colorGreen);
Plot(TrendDownft,"Down",colorRed);

B10m=TrendUpft;
S10m=TrendDownft;

_SECTION_END();

Buy      =(C>O AND B10m);
ExitLong =S10m;
Sell     =(C<O AND S10m);
ExitShort=B10m;

Buy=ExRem(Buy,ExitLong);
Sell=ExRem(Sell,ExitShort);
ExitLong=ExRem(ExitLong,Buy);
ExitShort=ExRem(ExitShort,Sell);


BuyPrice=ValueWhen(Buy,C);
ExitLongPrice=ValueWhen(ExitLong,C);
SellPrice=ValueWhen(Sell,C);
ExitShortPrice=ValueWhen(ExitShort,C);

PlotShapes(Buy*shapeUpArrow,colorBlue,0,L,-33);
//PlotShapes(ExitLong*shapeHollowSmallDownTriangle,colorPink,0,L,-51);
PlotShapes(Sell*shapeDownArrow,colorRed,0,H,-33);
//PlotShapes(ExitShort*shapeHollowSmallUpTriangle,colorSkyblue,0,H,-51);
 
If anybody using premium/discount for trading analysis.




Code:
spot = Foreign( "NIFTY", "C" );
fut= Foreign( "NIFTY_F1", "C" );

Plot( fut , "NIFTYFUT", colorBlue );
Plot( spot, "NIFTYSPOT", colorBlack );

_N( Title = "{{NAME}} - Premium Discount : {{VALUES}}" );
Bro I used it today but didn't understand how to catch trades on this...........
 
Originally Posted by vikas1moon View Post
Hello Seniors,

Can someone provide an afl which is based on price action HH and HL or LH and LL and their breakouts in consolidation.

which gives buy and sell signals should be compatible on 5min and higher time frames charts.

My regards
Vk2u
Anyone with answer...
 
hi , can anyone help me and convert this Tradestation code to ami ?
i need this very much thanks and appreciate that.

Code:
inputs:
 	
ADX_Bars(6);

vars:
TR(0),DI_Diff(0), DI_Sum(0),ma(0),pdm(0),mdm(0),pdi(0),mdi(0), DI_Factor(0), VI(0), diff(0), HHV(0), LLV(0),WeightDM(ADX_Bars),
WeightDI(ADX_Bars), WeightDX(ADX_Bars),ChandeEMA(ADX_Bars),out(0),j(0); 

   MA=Close;    
   PDM=0;
   MDM=0;
   PDI=0;
   MDI=0;
   Out=0;
 
   PDM=0;
   MDM=0;
   if(Close>Close[1]) then PDM=Close-Close[1] else MDM=Close[1]-Close;//This array is not displayed.

   PDM=((WeightDM-1)*PDM[1] + PDM)/WeightDM;//ema.
   MDM=((WeightDM-1)*MDM[1] + MDM)/WeightDM;//ema.

   TR=PDM+MDM;

   if (TR>0) then begin
   	PDI=PDM/TR;
   MDI=MDM/TR; end else begin
   PDI=0;
   MDI=0;
   end;

   PDI=((WeightDI-1)*PDI[1] + PDI)/WeightDI;//ema.
   MDI=((WeightDI-1)*MDI[1] + MDI)/WeightDI;//ema.
   DI_Diff=PDI-MDI;  
   if (DI_Diff<0) then  DI_Diff= -DI_Diff;//Only positive momentum signals are used.
   DI_Sum=PDI+MDI;
   DI_Factor=0;//Zero case, DI_Diff will also be zero when DI_Sum is zero.
   if (DI_Sum>0) then Out=DI_Diff/DI_Sum else Out=0;

   Out=((WeightDX-1)*Out[1] + Out)/WeightDX;

   if (Out>Out[1]) then begin 
   	HHV=Out;
	LLV=Out[1]; end else begin
   HHV=Out[1];
   LLV=Out;
   end;
   
	
      
for j = 1 to adx_bars-1 begin	
   if(Out[j+1]>HHV)then HHV=Out[j+1];
   if(Out[j+1]<LLV) then LLV=Out[j+1];
   end;

   


   diff = HHV - LLV;
   VI=0;
   if (diff>0) then  VI=(Out-LLV)/diff;
   
          
   MA=((ChandeEMA-VI)*MA[1]+VI*Close)/ChandeEMA;//Chande VMA formula with ema built in.

    
  Plot1(ma,"ADXVMA");
[/QUOTE]
 

Similar threads