# Need afl code for my formula

#### bluesquare123

##### Member
DEAR FRIENDS AND EXPERTS .. PLZ CODE ME FOR GIVEN FORMULA AND CONDITIONS ...

---------------------------------------------------------------------------------------------------------------------------------------------------------

YESTERDAY OHLC = O1,H1,L1,C1
DAY BEFORE YESTERDAY OHLC = O2,H2,L2,C2

A=H2-O2
B=O2-L2

Q=(H1+H2)/2
R=(L1+L2)/2
S=(C1+C2)/2
T=(Q+R)/2
U=(Q-R)

BW=S+(U*55/100)
BH=BW+15
BS=S+(U*12.5)/100

KM=S-(U*35)/100
KN=KM-20
KS=S+(U*12.5)/100

GM=S+(U*15)/100
GT=GM+12
GS=S-(U*12.5)/100

ER=S-(U*60)/100
ES=ER-15
ET=S-(U*12.5)/100

IF A VALUE IS GREATER THAN B VALUE ( A > B ) THEN PLOT FOLLOWING LINES

PLOT BLUE LINE FOR BW

PLOT GREEN LINE FOR BH

PLOT BLACK LINE FOR BS ..

PLOT RED LINE FOR KM

PLOT PINK LINE FOR KN

PLOT GREY LINE FOR KS

IF A IS LESSER THAN or EQUAL TO B ( A<=B ) THEN PLOT FOLLOWING LINES

PLOT BLUE DOTED LINE FOR GM

PLOT GREEN DOTED LINE FOR GT

PLOT BLACK DOTED LINE FOR GS ..

PLOT RED DOTED LINE FOR ER

PLOT PINK DOTED LINE FOR ES

PLOT GREY DOTED LINE FOR ET

#### boarders

##### Well-Known Member
HERE IS THE CODE, PLS EXPLAIN HOW TO USE IT...

O1 = Ref(O,-1);
h1 = Ref(H,-1);
l1 = Ref(L,-1);
c1 = Ref(C,-1);

O2 = Ref(O,-2);
h2 = Ref(H,-2);
l2 = Ref(L,-2);
c2 = Ref(C,-2);

A=H2-O2;
B=O2-L2;

Q=(H1+H2)/2;
R=(L1+L2)/2;
S=(C1+C2)/2;
T=(Q+R)/2;
U=(Q-R);

BW=S+(U*55/100);
BH=BW+15;
BS=S+((U*12.5)/100);

KM=S-((U*35)/100);
KN=KM-20;
KS=S+((U*12.5)/100);

GM=S+((U*15)/1000);
GT=GM+12;
GS=S-((U*12.5)/100);

ER=S-((U*60)/100);
ES=ER-15;
ET=S-((U*12.5)/100);
PlotOHLC(O,H,L,C,"",IIf(O>C,colorRed,colorGreen),styleCandle);

Plot(IIf(a>b,bw,Null),"BW",colorBlue,styleLine|styleStaircase|styleNoRescale);
Plot(IIf(a>b,bh,Null),"BH",colorGreen,styleLine|styleStaircase|styleNoRescale);
Plot(IIf(a>b,bS,Null),"BS",colorBlack,styleLine|styleStaircase|styleNoRescale);
Plot(IIf(a>b,KM,Null),"KM",colorRed,styleLine|styleStaircase|styleStaircase|styleNoRescale);
Plot(IIf(a>b,KN,Null),"KN",colorPink,styleLine|styleStaircase|styleNoRescale);
Plot(IIf(a>b,KS,Null),"KS",colorGrey40,styleLine|styleStaircase|styleNoRescale);

Plot(IIf(a<=b,GM,Null),"GM",colorBlue,styleDashed|styleStaircase|styleNoRescale);
Plot(IIf(a<=b,GT,Null),"GT",colorGreen,styleDashed|styleStaircase|styleNoRescale);
Plot(IIf(a<=b,GS,Null),"GM",colorBlack,styleDashed|styleStaircase|styleNoRescale);
Plot(IIf(a<=b,ER,Null),"ER",colorRed,styleDashed|styleStaircase|styleNoRescale);
Plot(IIf(a<=b,ES,Null),"ES",colorPink,styleDashed|styleStaircase|styleNoRescale);
Plot(IIf(a<=b,ET,Null),"ET",colorGrey40,styleDashed|styleStaircase|styleNoRescale);

Last edited:

#### boarders

##### Well-Known Member
pls check and remove spaces before applying indicator

#### bluesquare123

##### Member
HERE IS THE CODE, PLS EXPLAIN HOW TO USE IT...

O1 = Ref(O,-1);
h1 = Ref(H,-1);
l1 = Ref(L,-1);
c1 = Ref(C,-1);

O2 = Ref(O,-2);
h2 = Ref(H,-2);
l2 = Ref(L,-2);
c2 = Ref(C,-2);

A=H2-O2;
B=O2-L2;

Q=(H1+H2)/2;
R=(L1+L2)/2;
S=(C1+C2)/2;
T=(Q+R)/2;
U=(Q-R);

BW=S+(U*55/100);
BH=BW+15;
BS=S+((U*12.5)/100);

KM=S-((U*35)/100);
KN=KM-20;
KS=S+((U*12.5)/100);

GM=S+((U*15)/1000);
GT=GM+12;
GS=S-((U*12.5)/100);

ER=S-((U*60)/100);
ES=ER-15;
ET=S-((U*12.5)/100);
PlotOHLC(O,H,L,C,"",IIf(O>C,colorRed,colorGreen),styleCandle);

Plot(IIf(a>b,bw,Null),"BW",colorBlue,styleLine|styleStaircase|styleNoRescale);
Plot(IIf(a>b,bh,Null),"BH",colorGreen,styleLine|styleStaircase|styleNoRescale);
Plot(IIf(a>b,bS,Null),"BS",colorBlack,styleLine|styleStaircase|styleNoRescale);
Plot(IIf(a>b,KM,Null),"KM",colorRed,styleLine|styleStaircase|styleStaircase|styleNoRescale);
Plot(IIf(a>b,KN,Null),"KN",colorPink,styleLine|styleStaircase|styleNoRescale);
Plot(IIf(a>b,KS,Null),"KS",colorGrey40,styleLine|styleStaircase|styleNoRescale);

Plot(IIf(a<=b,GM,Null),"GM",colorBlue,styleDashed|styleStaircase|styleNoRescale);
Plot(IIf(a<=b,GT,Null),"GT",colorGreen,styleDashed|styleStaircase|styleNoRescale);
Plot(IIf(a<=b,GS,Null),"GM",colorBlack,styleDashed|styleStaircase|styleNoRescale);
Plot(IIf(a<=b,ER,Null),"ER",colorRed,styleDashed|styleStaircase|styleNoRescale);
Plot(IIf(a<=b,ES,Null),"ES",colorPink,styleDashed|styleStaircase|styleNoRescale);
Plot(IIf(a<=b,ET,Null),"ET",colorGrey40,styleDashed|styleStaircase|styleNoRescale);

Thanks for coding sir .. but line plotting for each and every candle like staircase ... straight line has to be ploted sir .. plz correct it ..

#### boarders

##### Well-Known Member

also pls advise whether you want only the last situation to be plotted as straight lines

#### bluesquare123

##### Member

also pls advise whether you want only the last situation to be plotted as straight lines
Sure ll explain once im cleared sir ...

line should come like the pic attached sir ...

##### Active Member
Mr BlueSquare,

You keep saying that you will explain later but you don't turn up after that ....

I coded your last MT4 Indicator and you never explained to me how to trade based on that ..

Sure ll explain once im cleared sir ...

line should come like the pic attached sir ...

#### boarders

##### Well-Known Member
Mr BlueSquare,

You keep saying that you will explain later but you don't turn up after that ....

I coded your last MT4 Indicator and you never explained to me how to trade based on that ..

I also suspected as much....Thats why I didnt follow up on this....I also suspect he has not revealed his exact trading logic or level values.

#### bluesquare123

##### Member
Mr BlueSquare,

You keep saying that you will explain later but you don't turn up after that ....

I coded your last MT4 Indicator and you never explained to me how to trade based on that ..

i keep saying that i ll explain later because im not clear with the concept and i need to troubleshoot it ... i dont want to guide followers in wrong ways .. once i clered there is nothing to help others ...

secondly last time u codded me for mt4 but that code was not working and i intimated to u in forum plz check out once ... and that work stops there itself and nobody helped there fore ..

sorry if i hurt u sir ...

#### bluesquare123

##### Member
I also suspected as much....Thats why I didnt follow up on this....I also suspect he has not revealed his exact trading logic or level values.
Mr.boarders ...

As i told before i ll explain the concept and i dont want to guide anybody in wrong way before i get cleared in trouble shoot .......

Nothing is there to hide any logic or levels ... even im working with levels sir ... there is lot of changes in levels for different scripts .... constant values ll not help in all scripts .. it differs to each scripts ... i need time to back-test .. once its ok for me then i ll post here ..

Rest up to u guys ..

Thanks for ur help sir ...