Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Valid Supply-Demand zone for Amibroker (AFL)
casoni
about 11 years ago
Amibroker (AFL)

Rating:
3 / 5 (Votes 14)
Tags:
amibroker, support, resistance, zig zag

Hello,
here i present valid supply-demand zones.
very basic idea.
as we all know..we need confirmation , for peak or bottom
to get fixed , i.e use wait till price rises/falls to certail percentage,
percentage to get peak/bottom valid.
here i have used valid peak/bottom..coded by tomasz, to plot zones,
zone [ cloud ] will plot only after peak/bottom is confirmed.
pls check and give your valuable feedback.
thank you

Screenshots

Similar Indicators / Formulas

Intraday Trades
Submitted by vishalsbharati almost 13 years ago
price support resistance
Submitted by icemanc over 13 years ago
Support & Resistance
Submitted by shyam242 over 13 years ago
Support/Resistance Modified
Submitted by dkeleher over 13 years ago
Automatic Support and Resistance with Channel
Submitted by kaiji almost 15 years ago

Indicator / Formula

Copy & Paste Friendly
SetChartOptions(0,chartShowArrows|chartShowDates);
bk=ParamColor( "Bk col",ColorRGB(85,90,60)); 
SetChartBkColor(bk);

amount = Param("Sensitivity", 0.5, 0.1, 2, 0.1 );

array = C ;
zz0 = Zig( array, amount );
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );

tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
PU = tr + 0.01 * abs(tr)*amount;
PD = pk - 0.01 * abs(pk)*amount;

ZZT = IIf( array >= PU AND zz0 > zz1, 1,
       IIf( array <= PD AND zz0 < zz1, -1, 0 ) );

ZZT = ValueWhen( ZZT != 0, ZZT );

Buy_Valid_=zzt>0;
Sell_Valid_=zzt<0;
Buy_Valid = ExRem(Buy_Valid_,Sell_Valid_);
Sell_Valid = ExRem(Sell_Valid_,Buy_Valid_);
Plot(Ref(Buy_valid,0),"",ColorRGB(0,0,100),styleHistogram|styleDashed|styleOwnScale|styleNoLabel,0,0,0,-1);
Plot(Ref(Sell_valid,0),"",ColorRGB(100,0,0),styleHistogram|styleDashed|styleOwnScale|styleNoLabel,0,0,0,-1);

Candlecol=IIf(BarsSince(Buy_Valid)<BarsSince(Sell_Valid) AND BarsSince(Buy_Valid)!=0,5,
          IIf(BarsSince(Buy_Valid)>BarsSince(Sell_Valid) AND BarsSince(Sell_Valid)!=0,4,1));
cc1=IIf(Buy_valid,colorYellow,IIf(Sell_valid,colorBlack,Candlecol));
SetBarFillColor(Cc1);
Plot(C,"Cas-S_D-Zone",Cc1,64,0,0,0,0);

pk=BarsSince(Buy_Valid)<BarsSince(Sell_Valid) ;//AND BarsSince(Buy_Valid)!=0;//Zz>Ref(zz,-1);
tr=BarsSince(Buy_Valid)>BarsSince(Sell_Valid) ;//AND BarsSince(Sell_Valid)!=0;//Zz<Ref(zz,-1);

Ll=LowestSince(sell_valid,L,1);
hH=HighestSince(Buy_Valid,H,1);
Llm=LowestSince(sell_valid,Min(O,C),1);
hHm=HighestSince(Buy_Valid,Max(O,C),1);

xx=Cum(1);
NoLines = Param("No of Lines",5,1,10,1);

Col2=ParamColor( "Res Color", colorRed );
Col1=ParamColor( "Sup Color", colorGreen );

for( i = 1; i < NoLines+1 ; i++ )
{
scol=ColorBlend(Col1,2,0.1*i);
rcol=ColorBlend(Col2,2,0.1*i);

px1 = LastValue(ValueWhen(Buy_valid,Cum(1),i)) ;
py1 = LastValue(ValueWhen(Buy_valid,Ll,i)) ;
pz1 = LineArray(px1, py1, (BarCount-1), py1);
Plot(pz1,"",scol,32);

tx1 = LastValue(ValueWhen(sell_valid,Cum(1),i)) ;
ty1 = LastValue(ValueWhen(sell_valid,Hh,i)) ;
tz1 = LineArray(tx1, ty1, (BarCount-1), ty1);
Plot(tz1,"",rcol,32);

px1m = LastValue(ValueWhen(Buy_valid,Cum(1),i)) ;
py1m = LastValue(ValueWhen(Buy_valid,Llm,i)) ;
pz1m = LineArray(px1m, py1m, (BarCount-1), py1m);
PlotOHLC(pz1,pz1,pz1m,pz1m,"",scol,styleCloud|styleNoLabel,0,0,0,-i-nolines);

tx1m = LastValue(ValueWhen(sell_valid,Cum(1),i)) ;
ty1m = LastValue(ValueWhen(sell_valid,Hhm,i)) ;
tz1m = LineArray(tx1m, ty1m, (BarCount-1), ty1m);
PlotOHLC(tz1,tz1,tz1m,tz1m,"",rcol,styleCloud|styleNoLabel,0,0,0,-i-nolines);
}

for( j = 0; j < BarCount; j++ ) 
{ 
if( Buy_valid [j])  PlotText( "Tr\n"+Ll[ j ], j, Ll[j], colorPaleGreen ); 
if( Sell_valid[j] ) PlotText( "Pk\n"+Hh[ j ], j, Hh[j], colorRose); 
} 

21 comments

1. anandnst

Looks good ..thanx you for sharing casoni !

2. paponmukta

Can u pls explain how to use it?

3. soundar

sir chart plain no signal message for scol= colorblend

4. Alok

Dear Casoni,

This is a cool AFl, but can you tell us how to use this afl like entry and exit?

Any set of rules to use this?

Thanks

5. nareshpriya

exotic stuff. run tick bar repaly in ur amibroker to see how it works.great job casoni. thx a ton

6. casoni

Thank you nareshpriya , alok.

add below code for buy-sell-short-cover.
this are basic

//--------- BUY - SELL... CODE --------------
BuySetupValue	=	ValueWhen(Buy_valid,H,1);
SellsetupValue=	ValueWhen(Sell_valid,L,1);
Buysetup =  Buy_valid;
Sellsetup 	=  Sell_valid;
Lg 	= 	Flip(Buysetup,Sellsetup);
st 	= 	Flip(Sellsetup,Buysetup);
Buy	=	(Lg AND Cross(C,BuySetupValue)) ; Cover= Buysetup;
Short=	( st AND Cross(SellsetupValue,C)) ;Sell=sellsetup;
Buy= 	ExRem(Buy,Sell);
Sell= 	ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
PlotShapes(IIf(Buy,shapeUpTriangle,shapeNone),7,0,L,-15);  
PlotShapes(IIf(Short,shapeDownTriangle,shapeNone),7,0,H,-15);  
PlotShapes(IIf(Cover,shapeSmallUpTriangle,shapeNone),9,0,L,-15);  
PlotShapes(IIf(Sell,shapeSmallDownTriangle,shapeNone),9,0,H,-15);

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

you can add position when price is above last resistance or support
i.e more buy when price has crossed resistance
short more when price crosses support .
ps- above condition had not been added to buy-sell …. code

7. saifyarsiwala

Thank you Casoni.
Great Stuff.

I have only to add:
As I understand the demand zone becomes valid only if it crosses previous supply zone and same with the supply zone.
This AFL is slightly different.
Where can I find the color coding of the candles and thier significance?
Thanks for the excellent AFL.
Saify

8. amitrandive

Thanks Casoni !!!

9. iwan

Thank’s Mr. Casoni, this AFL’v ability to guidance whenever loss my choice.

10. soundar

sir syntex error chart not working kindly help me

11. ford7k

Hi casoni

Can you code mt4 code waddah attar explosion in amibroker,please!
MACD BASED great system
which so far not available in Amibroker,but available in MT4

WADDAH ATTAR EXPLOSION-Call it as WAE
LINK
http://codebase.mql4.com/1000
It is already there on tradestation.
-—————————————————————-
how to add these following to macd histogram code?

Using these settings on 1 hr:
Sensitivity 150
Dead Zone 30
Explosion Power 15
Trend Power 31
-—————————————————-
here is base code for macd histogram
you can try and add other lines as per waddah attar explosion
please try
thanks
ford
-——————————
_SECTION_BEGIN(“MACD normalized”);
SetChartBkColor(64);
sma = Param(“short EMA periods”,20,1,21);

lma = Param (“long EMA periods”,40, 2, 2520);

tsp = Param (“MACD trigger signal periods”,9,1,21);

np = Param (“normalizing periods (1=none)”, 50,1, 2520);

x = Param (“use Open=1 High=2 Low=3 Close=4 Volume=5 P=6”,4,1,6);

x = IIf (x1,Open, IIf (x2,High, IIf (x3,Low, IIf (x5, Volume, IIf (x==6,C,C)))));

sh = EMA;

lon = EMA;

ratio = Min(sh,lon)/Max(sh,lon);

Mac = (IIf (sh>lon,2-ratio,ratio)-1)*100;

MacNorm = (Mac-LLV) /(HHV-LLV+.000001)*100;

MacNorm = IIf (np <2,Mac,MacNorm);

Trigger = EMA (MacNorm, tsp);

Hist = MacNorm-trigger;
Histcolor=IIf(Hist>0,colorGreen,IIf(-Hist>0,colorRed,colorGrey50));

dynamic_color = IIf( MAcNorm < trigger, colorRed, colorBrightGreen );
Plot(MAcNorm,“macd”,dynamic_Color,styleHistogram,styleThick);

12. casoni

Hello Ford7,
as far as i remember WADDAH ATTAR .. is based on combination of Bollinger band and Macd
sorry i am no good in converting mt4 codes. to convert those you need to have good knowledge of Loops
ask at traderji – Kelvin hand or trash can help

13. bond662546

sir pls help

showing error 30 ,syntax error , scol= colorblend

kindly help

14. algotrader01

Even though zig looks in the future its a good afl to determine the demand supply zones ! Thanks ! If someone an code a multi timeframe version of the above code it will be great

15. Shantala

Really useful

16. passion2trade

tnks for the afl, can u pl give the color coding of the candles ….

17. vikas1moon

In trader who’s success rate is above 40% is considered good it apply on big institution also, and this indicator results are above 60% use this indicator along with EMA crossover for better results….
thanks author for this awesome afl if anyone able to make better than this my good wishes with him/her.

18. FinFreedom1965

Hello Ford7,

Thanks for assisting every one not just here but in TJ as well.
I see (yeah after all these years) Trash had coded a few modified versions upto 1.5. But strangely all I get is a blank screen (Ami 5.6). Any insight would greatly help.

Cheers

KK

19. Samson

Word of caution , this indicator uses “Zig” check replay in amibroker and use.

20. Mohamed AMARRAGY

Good Code

Thank you

21. saimoorthi

I am wondering why everyone praising this indicator but the bitter truth is it’s heavily repainted. I used this one on EOD, trust me it’s disappearing like anything. Unfortunately, this can’t be used.

Leave Comment

Please login here to leave a comment.

Back