Multiple Time Frame Help

singhboy

Active Member
#1
Hi , I use this afl on Hourly chart for exploration.
A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );
BB= (A-B< .03*C AND Close<400) OR (A-B< .015*C AND Close>400);
Filter= BB AND V>10000;
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");
AddColumn(DateTime(), "Date", formatDateTime);
AddColumn(C, "CMP", 1.2);

Now I want this afl to explore stocks on Hourly timeframe but by selecting periodicity as 5-15 mint timeframe or any other timeframe lower than hourly. I made this afl for this but it doesn't work. Please modify it

A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );
TimeFrameSet(inHourly);
Bollinger1= A-B<.03*C AND Volume >10000;
TimeFrameRestore();
Bollinger2= TimeFrameExpand(Bollinger1,inHourly);
Filter= Bollinger2 ;
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");

AddColumn(C, "CMP", 1.2);
AddColumn(Bollinger2,"Bollinger2",1.2);

Anant bro, if u read this thread please please help me
 

pkgmtnl

Well-Known Member
#2
Hi , I use this afl on Hourly chart for exploration.
A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );
BB= (A-B< .03*C AND Close<400) OR (A-B< .015*C AND Close>400);
Filter= BB AND V>10000;
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");
AddColumn(DateTime(), "Date", formatDateTime);
AddColumn(C, "CMP", 1.2);

Now I want this afl to explore stocks on Hourly timeframe but by selecting periodicity as 5-15 mint timeframe or any other timeframe lower than hourly. I made this afl for this but it doesn't work. Please modify it

A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );
TimeFrameSet(inHourly);
Bollinger1= A-B<.03*C AND Volume >10000;
TimeFrameRestore();
Bollinger2= TimeFrameExpand(Bollinger1,inHourly);
Filter= Bollinger2 ;
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");

AddColumn(C, "CMP", 1.2);
AddColumn(Bollinger2,"Bollinger2",1.2);

Anant bro, if u read this thread please please help me
Try now;
TimeFrameSet(inhourly);
A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );

Bollinger1= A-B<.03*C AND Volume >10000;
//TimeFrameRestore();
//Bollinger2= TimeFrameExpand(Bollinger1,inHourly);
Filter= Bollinger1 ;
TimeFrameRestore();
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");

AddColumn(C, "CMP", 1.2);
AddColumn(Bollinger1,"Bollinger1",1.2);
 

singhboy

Active Member
#3
Oh thanks pkgmtnl bro, I made a simple one so complex hahah. I will try n come back if any prob thnx again.
TimeFrameSet(inHourly);
A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );

Bollinger1= A-B<.03*C AND Volume >10000;
TimeFrameRestore();

Filter= Bollinger1 ;

SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");

AddColumn(C, "CMP", 1.2);
AddColumn(Bollinger1,"Bollinger1",1.2);
 

singhboy

Active Member
#4
Ok yaar now do me one more favor. I want to combine may exploration afls in one afl so that when i run exploration, every afl included in this single afl will explore stocks on their own conditions n parameters. Here is an example, pls tell if this is possible n if yes then pls modify as the afl below doesnt work as required
_SECTION_BEGIN("bollinger");
TimeFrameSet(inHourly);
A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );

Bollinger1= (A-B< .02*C AND Close<400) OR (A-B< .015*C AND Close>400);

Filter= Bollinger1 AND V>10000 ;
TimeFrameRestore();
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");

AddColumn(C, "CMP", 1.2);
AddColumn(Bollinger1,"Bollinger1",1.2);
_SECTION_END();

_SECTION_BEGIN("5 day high low");
TimeFrameSet(inDaily);
H = HHV(H, 4) ;
L= LLV(L,4) ;




High1= (Ref(H,-1)-C<.01*H AND Ref(H,-1)-C>.005 AND H< Ref(H,-1) AND C<400) OR (Ref(H,-1)-C<.005*H AND Ref(H,-1)-C>0.005 AND C>400) ;
Low1= (C-Ref(L,-1)<.01*L AND C-Ref(L,-1)>.005 AND L>Ref(L,-1) AND C<400) OR (C-Ref(L,-1)<.005*H AND C-Ref(L,-1)>0.005 AND C>400);

Filter= V>30000 AND (High1 OR Low1) ;
TimeFrameRestore();

SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");
AddColumn(DateTime(), "Date", formatDateTime);
AddColumn(C, "CMP", 1.2);
AddColumn(High1, "high1", 1.2);
AddColumn(low1, "low1", 1.2);
_SECTION_END();
 

pkgmtnl

Well-Known Member
#5
Ok yaar now do me one more favor. I want to combine may exploration afls in one afl so that when i run exploration, every afl included in this single afl will explore stocks on their own conditions n parameters. Here is an example, pls tell if this is possible n if yes then pls modify as the afl below doesnt work as required
_SECTION_BEGIN("bollinger");
TimeFrameSet(inHourly);
A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );

Bollinger1= (A-B< .02*C AND Close<400) OR (A-B< .015*C AND Close>400);

Filter= Bollinger1 AND V>10000 ;
TimeFrameRestore();
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");

AddColumn(C, "CMP", 1.2);
AddColumn(Bollinger1,"Bollinger1",1.2);
_SECTION_END();

_SECTION_BEGIN("5 day high low");
TimeFrameSet(inDaily);
H = HHV(H, 4) ;
L= LLV(L,4) ;




High1= (Ref(H,-1)-C<.01*H AND Ref(H,-1)-C>.005 AND H< Ref(H,-1) AND C<400) OR (Ref(H,-1)-C<.005*H AND Ref(H,-1)-C>0.005 AND C>400) ;
Low1= (C-Ref(L,-1)<.01*L AND C-Ref(L,-1)>.005 AND L>Ref(L,-1) AND C<400) OR (C-Ref(L,-1)<.005*H AND C-Ref(L,-1)>0.005 AND C>400);

Filter= V>30000 AND (High1 OR Low1) ;
TimeFrameRestore();

SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");
AddColumn(DateTime(), "Date", formatDateTime);
AddColumn(C, "CMP", 1.2);
AddColumn(High1, "high1", 1.2);
AddColumn(low1, "low1", 1.2);
_SECTION_END();
I think it will work for only one set of BUy/SELL to Filter, any senior to comment , can it work this way?
 

colion

Active Member
#6
Hi , I use this afl on Hourly chart for exploration.
A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );
BB= (A-B< .03*C AND Close<400) OR (A-B< .015*C AND Close>400);
Filter= BB AND V>10000;
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");
AddColumn(DateTime(), "Date", formatDateTime);
AddColumn(C, "CMP", 1.2);

Now I want this afl to explore stocks on Hourly timeframe but by selecting periodicity as 5-15 mint timeframe or any other timeframe lower than hourly. I made this afl for this but it doesn't work. Please modify it

A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );
TimeFrameSet(inHourly);
Bollinger1= A-B<.03*C AND Volume >10000;
TimeFrameRestore();
Bollinger2= TimeFrameExpand(Bollinger1,inHourly);
Filter= Bollinger2 ;
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");

AddColumn(C, "CMP", 1.2);
AddColumn(Bollinger2,"Bollinger2",1.2);

Anant bro, if u read this thread please please help me
As I recall, filters apply to all time frames. This might be one problem so suggest checking it out.
 
#8
Ok yaar now do me one more favor. I want to combine may exploration afls in one afl so that when i run exploration, every afl included in this single afl will explore stocks on their own conditions n parameters. Here is an example, pls tell if this is possible n if yes then pls modify as the afl below doesnt work as required
_SECTION_BEGIN("bollinger");
TimeFrameSet(inHourly);
A= BBandTop(Close, 20, 2 );


B= BBandBot( Close, 20, 2 );

Bollinger1= (A-B< .02*C AND Close<400) OR (A-B< .015*C AND Close>400);

Filter= Bollinger1 AND V>10000 ;
TimeFrameRestore();
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");

AddColumn(C, "CMP", 1.2);
AddColumn(Bollinger1,"Bollinger1",1.2);
_SECTION_END();

_SECTION_BEGIN("5 day high low");
TimeFrameSet(inDaily);
H = HHV(H, 4) ;
L= LLV(L,4) ;




High1= (Ref(H,-1)-C<.01*H AND Ref(H,-1)-C>.005 AND H< Ref(H,-1) AND C<400) OR (Ref(H,-1)-C<.005*H AND Ref(H,-1)-C>0.005 AND C>400) ;
Low1= (C-Ref(L,-1)<.01*L AND C-Ref(L,-1)>.005 AND L>Ref(L,-1) AND C<400) OR (C-Ref(L,-1)<.005*H AND C-Ref(L,-1)>0.005 AND C>400);

Filter= V>30000 AND (High1 OR Low1) ;
TimeFrameRestore();

SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol");
AddColumn(DateTime(), "Date", formatDateTime);
AddColumn(C, "CMP", 1.2);
AddColumn(High1, "high1", 1.2);
AddColumn(low1, "low1", 1.2);
_SECTION_END();
Yes, it is possible. You can just give your own name for each filter and check for all of them in the end using "OR" clause. About displaying which filter condn is successful, that is tricky part. You will have to assign a variable.

Let us say, you have 2 filters initially.

code 1:
filter = iif(a==b, 1,0);

code 2:
filter = iif(x==y,1,0);

now, if you want to combine both into single code and also display which filter gave success, you will have to do something like this

-- begin new code:
filterAcode=0;
filterBcode=0;

filterA = iif(a==b, 1,0);
filterB = iif(x==y,1,0);

if filterA=1
filterAcode=1;
if filterB=1
filterBcode=1;

filter= filterA or filterB;
NumColumns = 2;
Column0Name = "FilterA";
Column0 = FilterAcode;
Column1Name = "FilterB";
Column1 = FilterBcode;
-- end of new code


I am just giving theory without checking the syntax. But, this is how multiple filters are combined.

If you are looking out for something like single column that displays the actual filter name itself, then there is a bug in ami where it does not display values if we try to check for previous day/hour. You can check my candle stick exploration for daily chart. it displays results fine if single day is explored. But, does not display values if multiple days are choosen.

http://www.traderji.com/amibroker/41669-indicators-candlestick-patterns.html

thank you
nagarjuna
 

colion

Active Member
#9
Filter applies to all time frame? what does that mean?:confused:
If the filters apply to all time frames then you have to write some code that forces the filter that you want to operate in the proper time frame and not in other time frames. In your case, although you want a different filter for each time frame (i.e., 60 min and daily) both are functioning (I suspect) in both time frames. To use a different filter for each time frame you have to code the conditions that activate the filter. For example, this (or something similar) might work:

filter = iif( timeframeset( indaily ) == 1, fiterInDaily, filterInhourly );

If something that seperates the time frames does not work then the best thing to do is check with AmiBroker Support and I'm sure that they will provide a solution.
 
#10
Sorry guys Im unable to understand all this. Pkgmtnl, if u got this, pls help me making this afl dude
 

Similar threads