Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
WmWaster wrote:a Bullish Harami occurred within the previous 5 days OR
I would use the Alert function here in lieu of BarsSince(). I just think its a little neater and easier to read. It will have the same result:
Alert(BullHarami(),5) OR
WmWaster wrote:at least 2 black candles occurred within the previous 5 days, being one lower than the other
Use the Sum() function as a simple method to count how many time an event ocurred. When things get more complicated, using Sum() may not help so yuo need some more sophisticated tools in your toolbox.
We are using the ValueWhen() function to compare the values of the LOW on the last and next-to-last time there was a black bar in the last five days. If there were more than two black bars in the last five days then we make sure that each LOW is lower than the previous.
Sum(Black(),5)>=2 AND Sum(ValueWhen(1,Black(),L)<ValueWhen(2,Black(),L),5)>=2 AND
WmWaster wrote:no white candle breaks through the high of the first black candle within the previous 5 days
All of the other criteria are relatively simple, except this one! You need a counter function to locate the first Black bar in the last five days. Thankfully Roy has this work for us:
{Our thanks go to Roy Larsen}
a:=Black(); {signal to count}
b:=BarsSince(Black())>5; {signal to reset}
i:=Cum(a+b>-1)=1;
f:=BarsSince(i OR a)<BarsSince(i OR b);
g:=Cum(a OR Cross(a,0.5))-ValueWhen(1,i OR (f AND Alert(f=0,2)) OR (f=0 AND Alert(f,2)),Cum(a OR Cross(a,0.5)));
counter:=If(f,g+1,g);
Now the High of the first Black bar is:
hi:=ValueWhen(1,counter=1,H);
Now we need this to be the highest value in the five days:
HHV(H,5)<=hi AND
WmWaster wrote:a big white candle was showed today
So .... put all that together:
--8<--------------------------------------------
{Our thanks go to Roy Larsen}
a:=Black(); {signal to count}
b:=BarsSince(Black())>5; {signal to reset}
i:=Cum(a+b>-1)=1;
f:=BarsSince(i OR a)<BarsSince(i OR b);
g:=Cum(a OR Cross(a,0.5))-ValueWhen(1,i OR (f AND Alert(f=0,2)) OR (f=0 AND Alert(f,2)),Cum(a OR Cross(a,0.5)));
counter:=If(f,g+1,g);
hi:=ValueWhen(1,counter=1,H);
Alert(BullHarami(),5) OR
Sum(Black(),5)>=2 AND Sum(ValueWhen(1,Black(),L)<ValueWhen(2,Black(),L),5)>=2 AND
HHV(H,5)<=hi AND
BigWhite()
--8<--------------------------------------------
You might need to throw in some brackets around the functions to make sure the Boolean logic is correct:
(x OR y) AND z,
or
x OR (y AND z).... etc
Not a bad first attempt.... but my recommendation to you is, before you get too complicated in your trading systems, start very simply. There is nothing to be gained from piling indicator on indicator on indicator anyway, so keeping things very simple is often the best trading plan anyway!
Hope this helps.
Let me know if this works like it should. If it doesn't, a picture is worth a thousand words on where it is not performing.
wabbit :D
P.S. With the exception of Roy's little tricks, the rest of the information was gleaned from the MS Users Manual, which I have sitting next to me whenever I am at the computer.
|