Author Topic: Exploration on Multi Time frame  (Read 29771 times)

singhboy

  • Newbie
  • *
  • Posts: 24
    • View Profile
Exploration on Multi Time frame
« on: May 22, 2010, 06:33:09 am »
Hi, I use this exploration afl on 5 mint time frame

Code: [Select]
x = EMA(Close,13);
y = EMA (Close,5);

Buy=Cross(y,x)

   AND  (
( StochK( 5, 3)>StochD( 5, 3, 3 ))
       
);

Short= Cross(x,y)
  AND (
 ( StochK( 5,3) < StochD(5,3,3))
   
);

Filter=(Volume>100000) AND (Buy OR Short) AND (Close>200);
AddColumn(Close,"Close",1.4);
AddColumn(Buy,"buy",1.2);
AddColumn(Short,"short",1.2);
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
AlertIf( Short, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );


Now I want to add an aditional condition. I want the buy signal when stoch is up on both 5 mint and 15 mint time frames. When I explore on 5 mint, stoch condition is met on 5 mint but sum1 pls modify this afl so that it fulfills stoch condition on 15 mint as well. Thnx alot in advance
« Last Edit: May 22, 2010, 07:39:36 am by administrator »

pkgmtnl

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Exploration on Multi Time frame
« Reply #1 on: May 22, 2010, 07:36:37 am »
With kind blessings & regard of Admin;
Lets try

Code: [Select]
//SINGH BOY;

x = EMA(C,13);
y = EMA(C,5);

//15min conditions
TimeFrameSet(in15minute);
AA = StochK(5,3);
BB = StochD(5,3,3);
TimeFrameRestore;
CondB15 = AA>BB;

//5min Conditions;
TimeFrameSet(in5minute);
AA = StochK(5,3);
BB = StochD(5,3,3);
TimeFrameRestore;
CondB5 = AA>BB;

Buy = Cross(y,x) AND CondB15 And CondB5;

//15min conditions
TimeFrameSet(in15minute);
AA = StochK(5,3);
BB = StochD(5,3,3);
TimeFrameRestore;
CondS15 = AA<BB;

//5min Conditions;
TimeFrameSet(in5minute);
AA = StochK(5,3);
BB = StochD(5,3,3);
TimeFrameRestore;
CondS5 = AA<BB;

Sell = Cross(x,y) AND CondS15 And CondS5;

Filter=(Volume>100000) AND (Buy OR Sell) AND (Close>200);

Please test is first, i think It sud work.
Let me know if it donot.

« Last Edit: August 23, 2010, 06:02:27 am by administrator »
Thanx with regards.

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 200
    • View Profile
Re: Exploration on Multi Time frame
« Reply #2 on: May 22, 2010, 07:39:14 am »
What pkgmtnl posted will work and so will this:

Code: [Select]
TimeFrameSet( in5Minute );
Buy1 = StochK( 5, 3 ) > StochD( 5, 3, 3 );
TimeFrameRestore();

TimeFrameSet( in15Minute );
Buy2 = StochK( 5, 3 ) > StochD( 5, 3, 3 );
TimeFrameRestore();

x = EMA( Close, 13 );
y = EMA ( Close, 5 );

Buy = Cross( y, x ) AND  (
          (Buy1 AND Buy2)

      );

Short = Cross( x, y )
        AND (
            ( StochK( 5, 3 ) < StochD( 5, 3, 3 ) )

        );

Filter = ( Volume > 100000 ) AND ( Buy OR Short ) AND ( Close > 200 );
AddColumn( Close, "Close", 1.4 );
AddColumn( Buy, "buy", 1.2 );
AddColumn( Short, "short", 1.2 );
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
AlertIf( Short, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );

pkgmtnl

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Exploration on Multi Time frame
« Reply #3 on: May 22, 2010, 09:08:36 am »
Yes, This how difference is reflected b/w Genious & Novices.
Thanx with regards.

singhboy

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Exploration on Multi Time frame
« Reply #4 on: May 22, 2010, 10:57:40 am »
Thnx Alot to both of u. I will test it

singhboy

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Exploration on Multi Time frame
« Reply #5 on: May 23, 2010, 03:42:24 am »
Sorry Guys, I got the buy signal even wen stoch was down on 15 mint, n sell signal wen it was up on 15 mint. Afls meets stoch condition only on 5 mint. Infact I made the same afl myself too, but I named stoch conditions perhaps as C and D instead of Buy1 n Buy2. I thot changing this may help but  :-[

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 200
    • View Profile
Re: Exploration on Multi Time frame
« Reply #6 on: May 23, 2010, 07:41:57 pm »
singhboy, the buy signal should only show up if it is triggered on both 5min and 15min chart is it not working? If you want the same thing for sell do the same thing like I did to buy.

singhboy

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Exploration on Multi Time frame
« Reply #7 on: May 24, 2010, 10:29:09 am »
Dear admin, the buy signal comes even when stoch condition for buy is not true on 15 mint chart. Same for sell, means it gave sell signal when ema5 crossed ema 13 down, stoch was down on 5 mint but again, stoch was up on 15 mint.

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 200
    • View Profile
Re: Exploration on Multi Time frame
« Reply #8 on: May 24, 2010, 08:07:18 pm »
Hi singhboy,

That's very strange that shouldn't be happening at all can you double check that the formula is the same as the one I posted. It should work but if it doesn't I'm stumped and I can't test it since I don't trade intraday but try this last formula if it doesn't work I am out of ideas.

Code: [Select]
TimeFrameSet( in5Minute );
Buy1 = StochK( 5, 3 ) > StochD( 5, 3, 3 );
TimeFrameRestore();

TimeFrameSet( in15Minute );
Buy2 = StochK( 5, 3 ) > StochD( 5, 3, 3 );
TimeFrameRestore();

TimeFrameSet( in5Minute );
Sell1 = StochK( 5, 3 ) < StochD( 5, 3, 3 );
TimeFrameRestore();

TimeFrameSet( in15Minute );
Sell2 = StochK( 5, 3 ) < StochD( 5, 3, 3 );
TimeFrameRestore();

x = EMA( Close, 13 );
y = EMA ( Close, 5 );

Buy = Cross( y, x ) AND Buy1 AND Buy2;

Short = Cross( x, y ) AND Sell1 AND Sell2;

Buy = ExRem(Buy, Short);
Sell = ExRem(Short, Buy);

Filter = ( Volume > 100000 ) AND ( Buy OR Short ) AND ( Close > 200 );
AddColumn( Close, "Close", 1.4 );
AddColumn( Buy, "buy", 1.2 );
AddColumn( Short, "short", 1.2 );
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
AlertIf( Short, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );


singhboy

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Exploration on Multi Time frame
« Reply #9 on: May 25, 2010, 06:54:34 am »
It also doesnt work bro. For ex today on 3.14 pm it gave sell signal on abanoffshore at 686, stcoh value on 5 mint , K(5,3)=55.37, D(5,3,3)=61.18. On 15 mint  K(5,3)=59.97, D(5,3,3)=50.91. Hence it doesnt work. But still thnx alot for ur effort n replying me.

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 200
    • View Profile
Re: Exploration on Multi Time frame
« Reply #10 on: May 25, 2010, 08:19:38 pm »
Its very strange that it didn't help the last thing i can suggest is to ask on the Amibroker yahoo group and maybe Tomasz himself will reply.

singhboy

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Exploration on Multi Time frame
« Reply #11 on: May 26, 2010, 08:05:44 am »
Thnx bro, i posted my query there. If i get the afl, I will post here

singhboy

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Exploration on Multi Time frame
« Reply #12 on: May 30, 2010, 06:44:55 am »
dear admin, i got this reply on amibroker group frm Tomasz

Hello,

Or perhaps... from your question was ignored because it is answered in the manual

http://www.amibroker.com/guide/h_timeframe.html

Hint: you are missing TimeFrameExpand in your code.

Best regards,
Tomasz Janeczko amibroker.com

So i tried with this new afl

Code: [Select]
a=EMA(C,5);
b=EMA(C,13);

TimeFrameSet(in15Minute);
x= ( StochK( 5,3) > StochD(5,3,3));
y=StochK( 5,3) < StochD(5,3,3);
TimeFrameRestore();

Buy= Cross(a,b)
AND StochK(5,3) > StochD(5,3,3)
AND (
TimeFrameExpand(x, in15Minute) );

Sell= Cross(b,a)
AND StochK(5,3) < StochD(5,3,3)
AND (
TimeFrameExpand(y, in15Minute) );

Filter= (Buy OR Sell) AND (Close>200);
AddColumn(Close,"Close",1.4);
AddColumn(Buy,"buy",1.2);
AddColumn(Sell,"sell",1.2);

but this one doesnt work either. Did u get any hint frm Tomasz reply or mine try? If u got anything , pls post. Thnx
« Last Edit: August 23, 2010, 05:56:13 am by administrator »

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 200
    • View Profile
Re: Exploration on Multi Time frame
« Reply #13 on: May 30, 2010, 07:12:29 pm »
Please try this i hope it works I think I understand it all now. You are plotting on a 5 minute chart correct?

Code: [Select]
TimeFrameSet( in5Minute );
Buy1 = StochK( 5, 3 ) > StochD( 5, 3, 3 );
TimeFrameRestore();

TimeFrameSet( in15Minute );
Buy2 = StochK( 5, 3 ) > StochD( 5, 3, 3 );
TimeFrameRestore();

TimeFrameSet( in5Minute );
Sell1 = StochK( 5, 3 ) < StochD( 5, 3, 3 );
TimeFrameRestore();

TimeFrameSet( in15Minute );
Sell2 = StochK( 5, 3 ) < StochD( 5, 3, 3 );
TimeFrameRestore();

x = EMA( Close, 13 );
y = EMA ( Close, 5 );

Buy = Cross( y, x ) AND TimeFrameExpand(Buy1, in15Minute) AND Buy1;

Short = Cross( x, y ) AND Sell1 AND TimeFrameExpand(Sell2, in15Minute);

Buy = ExRem(Buy, Short);
Sell = ExRem(Short, Buy);

Filter = ( Volume > 100000 ) AND ( Buy OR Short ) AND ( Close > 200 );
AddColumn( Close, "Close", 1.4 );
AddColumn( Buy, "buy", 1.2 );
AddColumn( Short, "short", 1.2 );
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
AlertIf( Short, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );

singhboy

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Exploration on Multi Time frame
« Reply #14 on: May 30, 2010, 10:42:55 pm »
yes sir i explore on 5 mint, by the way this also doesnt work. Leave it now n thanks for ur effort