Simple Coding Help - No Promise.

Happy_Singh ji and Seniors , iam totally naive, pls help me : how 2 get Intraday cumulative Volume value instead of Differential volume either thru Afl / RTD scripts or thru NEST/ AMI/ RTD settings ? Thank u all.
And how to call for opening value of a Volume bar in afl Like Open Price in a Price bar ?
Thank u
shiraj
 

bpr

Well-Known Member
Hello guys I just started learning AFL 2 days ago.
I am facing this issue where the for loop is working only 100 times and stops.

Is this a limitation of Plotgrid() function or for loop has some issues?

Thanks for your help.

Code:
	for(i =10 ; i < 10000 ; i=i+10)
	{
		PlotGrid( i, GRID_COLOR, 8, 1, True );
	}
any idea abt this...
 

Nehal_s143

Well-Known Member
Amit Sir I am trying to find reversal points, which will fire signal near bottom or near top and not after a happening of movement.

Nifty yesterday made low of 8271, and reversal signal came at 8297 at 1.00pm

Will post afl after adding support and resistance for old data, so that can we can verify signals on old data

I dont say at all signals we will get reversal, but sure at all reversal we will get signal.

Filtering wrong signal will be next step.


This system will try to catch all major reversal, except the V shape recover/fall
 
Last edited:

Nehal_s143

Well-Known Member
Hi Nehal pls share or advice the AFL. Thanks.
:)
Need to add support and resisate level on old data, and also need to add condition plot buy only if new support is formed or plot sell only if new resistance is formed, I tried to add this condition seeing CASoni sir afl but could not add properly.

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 Earth");
tf=Param("Time Frame (min)",10,1,10,1);tfrm=in1Minute*tf;
TimeFrameSet(tfrm);

VarT2	= ( High + Low + Close * 2 ) / 4;
BT2		= (EMA((VarT2 - LLV(VarT2,15))/(HHV(Low, 15) - LLV(VarT2, 15)), 2)) * 38;
BotT2	= (((-1)) * (EMA( (VarT2- LLV(VarT2,15) ) / (HHV(Low, 15)-LLV(VarT2, 15)), 2) + 0.01)) * 38;
Var2T2	= ((Close-LLV(Low, 10))/(HHV(High, 10)-LLV(Low, 10))) * 100;
Var3T2	= EMA(Var2T2, 10);
Var4T2	= EMA(Var3T2, 10);
Var5T2	= 3 * Var3T2 - 2 * Var4T2;
Var6T2	= EMA(Var5T2, 5);
BridgeT2 = EMA(Var6T2, 1);

TimeFrameRestore() ;

BridgeT2f = TimeFrameExpand(BridgeT2, tfrm);

myc2ef=IIf(BridgeT2f > Ref(BridgeT2f, -2),colorBlue,
       IIf(BridgeT2f < Ref(BridgeT2f, -2),colorRed,31));

Plot(6, "ribbon", myc2ef, styleOwnScale | styleArea|styleNoLabel, 0.1, 100);

_SECTION_END();

_SECTION_BEGIN("Earth-2");
VAR2=(High+Low+(Close)*(2))/(4);
B = ((EMA((VAR2-LLV(VAR2,15))/(HHV(Low,15)-LLV(VAR2,15)),2))*(38));
bot1 = ((((-1))*(EMA((VAR2-LLV(VAR2,15))/(HHV(Low,15)-LLV(VAR2,15)),2))+0.01)*(38));
VAR22=((Close-LLV(Low,10))/(HHV(High,10)-LLV(Low,10)))*(100);
VAR33=EMA(VAR22,10);
VAR44=EMA(VAR33,10);
VAR55=(3)*(VAR33)-(2)*(VAR44);
VAR66=EMA(VAR55,5);
BridgeT = (EMA(VAR66,1));

myc=IIf(BridgeT > Ref(BridgeT, -1),colorBlue,
    IIf(BridgeT < Ref(BridgeT, -1),colorRed,31));


_SECTION_END();


_SECTION_BEGIN("supp");
("Price");
RSIperiod = 15; // Param("RSI p",3,14,30,1);
Percent = 5; // Param("ZIG %",8,9,15,1);
EMAperiod = 5; //Param("EMA p",4,5,10,1);
HHVperiod = 8; //Param("HHV p",3,5,10,1);
NumLine = 2; //Param("Num Lines",3,1,20,1);

Base = DEMA(RSI(RSIperiod),EMAperiod);

GraphXSpace=0.5;


for( i = 1; i <= numline; i++ )
{
ResBase = LastValue(Peak(Base,Percent,i));
SupBase = LastValue(Trough(Base,Percent,i));
Plot(ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), "Resist Level", colorRed, styleLine);
Plot(ValueWhen( supbase==Base, LLV(L,HHVperiod) ), "Support Level", colorGreen, styleLine);
}

_SECTION_END(); 

/*
BuySetupValue	=	ValueWhen( ResBase==Base, HHV(H,HHVperiod) );
SellsetupValue=	ValueWhen( supbase==Base, LLV(L,HHVperiod) );
Buysetup =  ResBase;
Sellsetup 	=  SupBase;
Lg 	= 	Flip(Buysetup,Sellsetup);
st 	= 	Flip(Sellsetup,Buysetup);

Buy  =(Lg AND Cross(C,BuySetupValue)); 
Sell =sellsetup;
Short=(st AND Cross(SellsetupValue,C));
Cover= Buysetup;
*/



Buy =   C>O AND (BridgeT > Ref(BridgeT, -1)) AND (BridgeT2f > Ref(BridgeT2f, -2));
Sell =  (BridgeT2f < Ref(BridgeT2f, -2));
Short = C<O AND (BridgeT < Ref(BridgeT, -1)) AND (BridgeT2f < Ref(BridgeT2f, -2));
Cover = (BridgeT2f > Ref(BridgeT2f, -2));

Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);

PlotShapes(Buy*shapeUpArrow,colorBlue,0,L,-42);
//PlotShapes(Sell*shapeHollowSmallDownTriangle,colorPink,0,L,-51);
PlotShapes(Short*shapeDownArrow,colorRed,0,H,-42);
//PlotShapes(Cover*shapeHollowSmallUpTriangle,colorSkyblue,0,H,-51);
 
I Had asked for some help but the code might be a little complicated and nobody could helped. I tried the whole week with every possible loop combination with no success.
I ripped the code code appart and left only a part of it to make it simple if anyone might be able to help me.
What I would like to do is how to loop the code to plot only the last n trendlines, and I will adapt it later to the rest of the code.
Code:
Plot(C,"Price",1,64,0,0,0,0);
_SECTION_BEGIN("Trendlines Multitimeframe");
// Amibroker AFL code by Edward Pottasch, 6/8/2011
// Using fractals to create automatic trendlines
// Using option to show multiple timeframes

xx=BarIndex();x=xx;Lx=LastValue(x);
nbar=Param("N Pivot Bars",3,2,50,1); 

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

y0=ValueWhen(tr,trl,0); 
y1=ValueWhen(tr,trl,1);
x0=ValueWhen(tr,xx,0);
x1=ValueWhen(tr,xx,1);

aa=(Y0-Y1)/(X0-X1);
ls1=aa*(xx-X1)+Y1;
dls1=ls1-Ref(ls1,-1);

y0=ValueWhen(pk,pkh,0); 
y1=ValueWhen(pk,pkh,1);
x0=ValueWhen(pk,xx,0);
x1=ValueWhen(pk,xx,1);

aa=(Y0-Y1)/(X0-X1);
hs1=aa*(xx-X1)+Y1;
dhs1=hs1-Ref(hs1,-1);

    dd=0.0;
    Vh=dd*(ValueWhen(pk,C)-ValueWhen(pk,Ref(C,-1)))/ValueWhen(pk,C);
    Vl=dd*(ValueWhen(tr,C)-ValueWhen(tr,Ref(C,-1)))/ValueWhen(tr,C);
   
    ls1=IIf(dls1>=Vl,ls1,Null);
    hs1=IIf(dhs1<=Vh,hs1,Null);
    

Plot(ls1,"\nLower Trendline",colorBrightGreen,styleLine|styleNoRescale,0,0,0,-1);

Plot(hs1,"\nUpper Trendline",colorRed,styleLine|styleNoRescale,0,0,0,-1);

_SECTION_END();
 

Similar threads