Chaitanya,
not exactly sure if I have understood your system
but here is my interpretation below. When in a long term uptrend the price moves
down 5 consecutive bars and then closes green including a higher high is set
then buy the next bar at the open, similar story for short,
Ed
per =220;
// use map for the trend
indicator map = MA(C,per); dmap = map -
Ref(map,-1);
// number of downbars tt = NumDownBars = BarsSince( C >= Ref(C,-1));
// number of up bars ss = NumUpBars = BarsSince( C <= Ref(C,-1));
// buy constraint: down 5 bars in a row, then
last bar high greater than previous high, trend is up bc1 = Ref(tt >= 5,-1)
AND H > Ref(H,-1) AND C > Ref(C,-1) AND dmap > 0;
Buy = bc1; Buy = Ref(Buy,-1);
BuyPrice =
O;
sc1 = Ref(ss >= 5,-1)
AND L < Ref(L,-1) AND C < Ref(C,-1) AND dmap < 0; Short = sc1;
Short =
Ref(Short,-1); ShortPrice = O;
SetChartOptions(0,
chartShowDates); GraphXSpace = 5; Plot(C,"C",1,64);
PlotShapes(IIf(Buy,shapeUpArrow,0),colorWhite, layer = 0,
yposition = BuyPrice, offset = 0 ); PlotShapes(IIf(Short,shapeHollowDownArrow,0),colorLightBlue, layer = 0,
yposition = ShortPrice, offset = 0
);
----- Original Message -----
Sent: Thursday, June 28, 2007 12:08
AM
Subject: [amibroker] How to wait for the
Top or Bottom of the previous bar to be taken out?
Hello all,
How can i code something like this (presented in Oliver
Valez presentations):
For short setup:
1. Wait for 3
bars to close green (above yesterdays closes for 5 days). 2. Now
basically sell (short) when the next bar closes below the Low of the
previous bar.
reverse for long setup.
I can check for 5 bars to
close green using
BuySignal = (C > Ref(C,-1)) AND (Ref(C,-1) >
Ref(C,-2)) AND (Ref(C,- 2) > Ref(C,-3));
Buy =
BuySignal;
But how do i make it wait for the previous bars low to be
taken out before going short.
Additionally: use the setup in the
direction of the prevailing trend or some other filter on top of this
setup
thanks Chaitanya.
__._,_.___
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
SPONSORED LINKS
__,_._,___
|