Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (fogman, Grant, AndrewAMD, juanex), 989 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
MTF entry doesn't work correctly #419438
03/10/13 10:40
03/10/13 10:40
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Hi,

I write this MTF script.
It uses 15 min bar on entry and 4h on exits.
By seeing a plot, 4h exit works correctly but entry is not what I expect, although both plots are correct.

I think I am wrong at using MTF and I am not sure that where is scope for TimeFrame so plese correct it.

Code:
function run(){
	
set(PLOTPRICE+PLOTNOW);
BarPeriod = 15;
LookBack = 5000;
StartDate = 20121024;
NumDays = 5;
set(TICKS);
  
TimeFrame = 1;
vars Close = series(priceClose());
vars tmp1 = series(SMA(Close,21));
	
TimeFrame = 16;
vars Close = series(priceClose());
vars tmp16 = series(SMA(Close,21));

        
if(priceClose(0) < tmp1[0])
enterShort();


if(priceClose(0) > tmp16[0]  )
exitShort();
        
plot("SMA15min", tmp1[0], 0, RED);
plot("SMA4h", tmp16[0], 0, RED);

}



Last edited by SFF; 03/11/13 10:48.
Re: MTF entry doesn't work correctly [Re: SFF] #419533
03/11/13 12:33
03/11/13 12:33
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
I suppose you wanted to enter a trade on every bar, but you called enterShort with a time frame of 16 bars. So a trade could only be entered on every 16th bar. Was that your problem?

Re: MTF entry doesn't work correctly [Re: jcl] #419536
03/11/13 12:52
03/11/13 12:52
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Yes, Only exitShort is called on every 16th bar and it is done correctly in the above script.
But here, I want to enter on every bar if a condition is met on BarPeriod = 15.

I want to define TimeFrame for every indicators used in a code.
In MTF strategy, it is very helpful to see what indicator used for what time frame.

This code is wrong?
I defined TimeFrame = 1 here which is on every bar.
Maybe It is wrong to use same Close vars in both TFs.
Code:
TimeFrame = 1;
vars Close = series(priceClose());
vars tmp1 = series(SMA(Close,21));


Last edited by SFF; 03/11/13 13:43.
Re: MTF entry doesn't work correctly [Re: SFF] #419540
03/11/13 13:43
03/11/13 13:43
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
Then just set TimeFrame back to 1 bar for calling enterShort.

Re: MTF entry doesn't work correctly [Re: jcl] #419544
03/11/13 13:49
03/11/13 13:49
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Thanks, It is works correctly now.

For scope for TimeFrame, is it valid until another TimeFrame line?

Re: MTF entry doesn't work correctly [Re: SFF] #419609
03/12/13 13:25
03/12/13 13:25
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
Yes, it stays valid until it is changed again.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1