Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Nymphodora, AndrewAMD, TipmyPip, Quad, Imhotep), 847 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Call function with TimeFrame #462448
09/30/16 12:08
09/30/16 12:08
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,
I'm trying understand the TimeFrame and have this simple code:

Quote:

//--------------- Frame 10 ---------------
int Frame10(){
TimeFrame= 10;
static int nCount=0;
nCount++;

if (nCount > 6) { // <== line 7 order
enterShort();
nCount = 0;
}

return 0;
}

function run()
{
StartDate = 20160101;
EndDate=20160131;
set(LOGFILE);
BarPeriod = 1; // 1 minute bars
Hedge = 2;
Stop=1000*PIP;
TakeProfit=1000*PIP;

Frame10();
}


a) in code change on line 7:
with number 3-5-7... system not open orders...
with number 2-4-6... system open orders...
b) with 6 open but first order is a wrong time:

Quote:

Name,Type,Asset,ID,Lots,Open,Close,Entry,Exit,Profit,Roll,ExitType
xtest,Short,EUR/USD,9001,1,2016-01-04 00:30,2016-01-31 23:58,1.0848,1.0826,1.90,0.02,Sold
xtest,Short,EUR/USD,16002,1,2016-01-04 01:40,2016-01-31 23:58,1.0841,1.0826,1.30,0.02,Sold
xtest,Short,EUR/USD,23003,1,2016-01-04 02:50,2016-01-31 23:58,1.0868,1.0826,3.64,0.02,Sold
xtest,Short,EUR/USD,30004,1,2016-01-04 04:00,2016-01-31 23:58,1.0872,1.0826,4.00,0.02,Sold


Re: Call function with TimeFrame [Re: Grat] #462470
10/03/16 02:51
10/03/16 02:51
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
HI,
from the manual
Workshop 6: Portfolio strategies. Money management.

Quote:
What does this mean? The trend trading strategy from workshop 4 used 60-minutes bars, while counter trend trading was based on 240-minutes bars. When we trade both together in the same script, we'll need both types of bars. The BarPeriod variable must not be changed at runtime, as it determines the sampling of the price curves. But the TimeFrame variable does the job. Alice has set BarPeriod to 60 minutes, so it needs a TimeFrame of 4 bars for getting the 240 minutes period for the counter trend strategy. TimeFrame affects all subsequent price and series calls, all indicators using those series, and the ATR function.


I have this code:

Quote:

//--------------- Frame 10 ---------------
int Frame10(){
TimeFrame= 60; // 60 minute ???

if (AlgoVar[0] > -2){
AlgoVar[0]--;
printf("\nDNT minute %d AlgoVar %.1f", minute(),AlgoVar[0]);

}else AlgoVar[0]=5;
return 0;
}

function run()
{
StartDate = 20160101;
EndDate=20160131;
set(LOGFILE);
BarPeriod = 1; // 1 minute bars
Hedge = 2;
Stop=1000*PIP;
TakeProfit=1000*PIP;
Frame10();
}


I got this result:

Quote:

DNT minute 3 AlgoVar 2.0
DNT minute 4 AlgoVar 1.0
DNT minute 5 AlgoVar 0.0
DNT minute 6 AlgoVar -1.0
DNT minute 7 AlgoVar -2.0
DNT minute 9 AlgoVar 4.0
DNT minute 10 AlgoVar 3.0
DNT minute 11 AlgoVar 2.0
DNT minute 12 AlgoVar 1.0
DNT minute 13 AlgoVar 0.0
DNT minute 14 AlgoVar -1.0
DNT minute 15 AlgoVar -2.0


function Frame10() is called every 1 minute bar and execute code inside. Except the indicator - this is a correct - call every 60 minute.

Re: Call function with TimeFrame [Re: Grat] #462480
10/03/16 17:08
10/03/16 17:08
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Working with time frames is described here: http://manual.zorro-project.com/barperiod.htm. If you want to call a function not at any bar, but only at the end of a time frame, use the frame() function.

Re: Call function with TimeFrame [Re: jcl] #462482
10/03/16 17:58
10/03/16 17:58
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Super,

thank's

laugh


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1