Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/19/24 18:45
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, AndrewAMD, TedMar), 837 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
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,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
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,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
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