Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (1 invisible), 672 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Observed:incorrect TradeVar #471274
02/26/18 02:45
02/26/18 02:45
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
I want to
keep track of the order entry time (not trade entry time) in a TMF
so I can
use order entry time when analyzing TradeProfit across many trades
and use order entry time as a globally unique identifier (recall that Zorro re-uses trade ids)

Order Time is not a tracked trade variable (recall a post of mine from long ago). As a work-around, I am encoding order entry time as a TradeVar. I tried this toy script:
Code:
var encode_date() {
  var ret = 0.;
  ret += minute();
  ret += hour() * 100.;
  ret += day() * 10000.;
  ret += month() * 1000000.;
  ret += year() * 100000000.;
  return ret;
}

int manage(var order_date, var mult) {
	if (TradeIsClosed) {
		printf("n%0.0f: %f", order_date, TradeProfit);
	}
	return 0;
}

function run() {
  if (is(INITRUN)) {
    assetList("AssetsNew.csv");
    set(OPENEND);
    set(TICKS);	 
    StartDate = 20110201;
    EndDate = 20110202;
    BarPeriod = 1;
    LookBack = 140;
    Hedge = 2;
    Margin = 250.;
    TradesPerBar = 2;
    MaxLong = 10000;
    MaxShort = 10000;
    Weekend = 1+8;
  }
  
  var p = fabs(random());
  if (p > 0.999) {
	  LifeTime = 1440 * 7;
	  EntryTime = 1;
	  var mult = ATR(100);
	  Stop = 3 * mult;
	  TakeProfit = 3 * mult;
	  
	  var ec = encode_date();
	  if (p > 0.9995) {
		  printf("n%0.0f enterLong", ec);
		  enterLong(manage, ec, mult);
	  } else {
		  printf("n%0.0f enterShort", ec);
		  enterShort(manage, ec, mult);
	  }
  }
}


Observed:
arg order_date always contains 201102016512, representing a nonsense datetime. (hour 65).
Code:
Test: trade_management_aai EUR/USD (TICKS) 2011
Assets AssetsNew.csv
201101312349 enterLong
201102010425 enterShort
201102016512: 1.642228
201102012004 enterShort
201102016512: -10.414859
201102020131 enterLong
201102016512: -6.834805
Loss -16$  MI -238$  DD 17$  Capital 302$
Trades 3  Win 33.3%  Avg -5.1p  Bars 40
AR -945%  PF 0.10  SR -11.84  UI 100%  R2 0.69


Expected:
I expected arg order_date to contain the encoded order entry times, such as 201101312349, as shown in the entry printf lines.

How thoroughly confused am I?

Last edited by GPEngine; 02/26/18 02:45.
Re: Observed:incorrect TradeVar [Re: GPEngine] #471283
02/26/18 15:26
02/26/18 15:26
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
Ah, right. TradeVar are float.

Re: Observed:incorrect TradeVar [Re: GPEngine] #471310
02/27/18 18:11
02/27/18 18:11
Joined: Jan 2018
Posts: 29
L
luisd Offline
Newbie
luisd  Offline
Newbie
L

Joined: Jan 2018
Posts: 29
GP, I see you put the init in a block INITRUN in the run function.

I think those params can be set outside INITRUN and somehow Zorro initiates them only once at the start

am I correct please


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