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
3 registered members (AndrewAMD, juanex, Grant), 1,018 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
Page 2 of 2 1 2
Re: A way to access advice signal values for training outside Zorro? [Re: jcl] #436238
01/22/14 03:57
01/22/14 03:57
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
Part 1. I want to dump the results of all trades to a file. These are my training targets.
Part 2. I want to dump the values of several signals to a file. These are my training signals.

To prevent leaking future data into signals, training signals and targets must be synchronized.

I can dump part 2 at every bar. There will be one record per bar, and they will be ordered by Bar number.
I can dump part 1 only in EXITRUN since I need to wait for the trade to play out.

I figured I would use all_trades to loop through these trades, as you helpfully suggested, but I encountered three prohibitive factors.
1. There are gaps when a trades are not entered or when entry conditions were not met. If there are several entries per Bar, some may have a gap and others not. So it's very difficult to sift them all out.
2. There is no way to get a TRADE's entry time. There is no such thing as a TradeBarEntry property. So now (1) really seems like a quagmire.
3. They are not sorted by Entry time. It doesn't matter that the list starts out sorted, and in the interest of efficiency something comes along and partially disturbs the sorting. In computer science, an array is either sorted by some quality or it is not. Here, it's not. So, no help there either.

Do you get it?

To get around this, I am maintaining my own array of TRADE* I've created. It looks like you might imagine.
Code:
TRADE** my_trades = NULL;
int* my_trades_bar = NULL;
int my_trades_pos;

void init_my_trades() {
  int size = MAX_BARS * TRADES_PER_BAR * sizeof(TRADE*);
  my_trades = (TRADE*) malloc(size + 1);
  size = MAX_BARS * TRADES_PER_BAR * sizeof(int);
  my_trades_bar = (int*) malloc(size + 1);
  my_trades_pos = 0;
}
void my_trade(TRADE* trade) {
  my_trades[my_trades_pos] = trade;
  my_trades_bar[my_trades_pos] = Bar;
  my_trades_pos++;
  if (my_trades_pos >= MAX_BARS * TRADES_PER_BAR) {
    printf("\nOut Of my_trades positions.");
    quit();
  }
}

function run() {
  if (is(INITRUN)) {
    init_my_trades();
    ...
  }
  ...
  my_trade(enterLong());
  my_trade(enterShort());

  if(is(EXITRUN)) {
    for (trade_num = 0; cols_output < TRADES_PER_BAR; trade_num++) {
      ThisTrade = my_trades[trade_num];
      // write TradeResult to file
      // two per line
      // with special handling for NULL.
    }
  }
}




In the meantime, as a side note, I observed surprising behavior of EntryTime = 1. I do not understand how, with EntryTime = 1, TradeBarOpen can be anything other than NULL or the bar number the trade was entered. EntryTime = 1 should mean open the trade withing this bar or not at all. Not, in a later bar.

Get it?

Re: A way to access advice signal values for training outside Zorro? [Re: GPEngine] #436244
01/22/14 08:33
01/22/14 08:33
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
Ok, I see now what you're trying to do, but you won't have to sort trades or allocate complicated arrays for this.

If you want to dump advise signals, they are already stored in the TRADE "fSignal" array. You just need to print them to your file. You can find the TRADE struct in "trading.h". If your signals are no advise parameters, you can nevertheless store them in the fSignal array after entering the trade. The TRADE pointer is returned by the enter command.

As to the EntryTime problem, EntryTime is only the time for meeting the entry condition. It cannot be used to open the trade at the bar number it was entered. A trade that was pending at the close of bar X will open at bar X+1, the earliest - unless you got a time machine wink.

Hope this helps...

Re: A way to access advice signal values for training outside Zorro? [Re: jcl] #446507
10/18/14 15:10
10/18/14 15:10
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
Yes, it was helpful.

The trades which were entered but not opened because the Entry limit was not met within EntryTime, are still significant for statistics and offline training.

It seems that Zorro promptly forgets about them and obviously all_trades doesn't list them.

Page 2 of 2 1 2

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