Hello, here's what I want to do (but can't get it right):

I want to scan for 30min bar buy/short signals, produced by my indicator, but I 
only want those signals that are confirmed by a signal given in the last 10 or 
15 min bar (the one that ends the same time as the 30min bars, or the one just 
before).

Here's the code (after the indicator code) that I thought should work on a scan 
set at 5min bars:

TimeFrameSet( 2*in5Minute ); 
GreenSq10 = firstallup OR Ref(firstallup, -1);
RedSq10 = firstalldown OR Ref(firstalldown, -1);

TimeFrameSet( in15Minute ); 
GreenSq15 = firstallup OR Ref(firstallup, -1);
RedSq15 = firstalldown OR Ref(firstalldown, -1);

TimeFrameSet( 2*in15Minute ); 
GreenSq30 = firstallup;
RedSq30 = firstalldown;

TimeFrameRestore();

GreenSq10 = TimeFrameExpand(GreenSq10, 2*in5Minute, expandLast );
RedSq10 = TimeFrameExpand(RedSq10, 2*in5Minute, expandLast );
GreenSq15 = TimeFrameExpand(GreenSq15, in15Minute, expandLast );
RedSq15 = TimeFrameExpand(RedSq15, in15Minute, expandLast );
GreenSq30 = TimeFrameExpand(GreenSq30, 2*in15Minute, expandLast );
RedSq30 = TimeFrameExpand(RedSq30, 2*in15Minute, expandLast );

Buy = GreenSq30 AND ( GreenSq10 OR GreenSq15);
Short = RedSq30 AND ( RedSq10 OR RedSq15);

There are two problems with this code:
1. I get wrong results, i.e. many results appear that have no signal at all. 
2. I get results at times other than ending xx:29 or xx:59. Instead I get 5 min 
bar results, like 10:04 etc. Most results are in clusters of 3-5 consecutive 5 
min bars (e.g. 13:09, 13:14 and 13:19) which isn't OK either.

Even when I leave out the confirming signals (so just Buy = GreenSq30;) I get 
wrong results.

When instead of doing a scan, I plot the signals in the indicator, I get 
undesired effects like (wrong) signals disappearing while scrolling.

Who can tell me how I should change the code?
Thanks.

Reply via email to