Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by Grant. 02/24/26 22:21
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (TipmyPip, clint000, Grant, chsmac85, Martin_HH), 5,858 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
A way to access advice signal values for training outside Zorro? #431575
10/18/13 15:10
10/18/13 15:10
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
My understanding is
In Train mode, this call
Code:
if(adviseLong(DTREE,0,Signal1,Signal2) > 0)
    enterLong();


will open a new long position at every bar. The eventual profit of this position will be used as a target for training the DTREE at the current bar.

I would like to access these target values directly, so I can write them out to a file and use them as target outputs for training a model outside of Zorro. This will allow me to explore other model builders besides the built-ins, DTREE and PERCEPTRON.

Is it possible? It would save me some work.

Re: A way to access advice signal values for training outside Zorro? [Re: GPEngine] #431658
10/22/13 09:05
10/22/13 09:05
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
Yes, you can enumerate all closed trades in a for(all_trades) loop at the end of the training cycle, and store the trade results in a file.

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

Joined: Sep 2013
Posts: 504
California
Trying this now.
Can I make any assumptions about the order of the trades in for(all_trades) ?
So far it looks like they are not returned in the order I had hoped. i.e. they are in roughly chronological order, except that trades where TradeBarOpen = 198 are interleaved with trades where TradeBarOpen = 197.
Boo!

Re: A way to access advice signal values for training outside Zorro? [Re: GPEngine] #436066
01/18/14 08:33
01/18/14 08:33
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
They are sorted in the order of entering the trade.

This is not the same as the opening order. When the trade uses an entry limit, it can open at a different bar.

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

Joined: Sep 2013
Posts: 504
California
Follow-up question!
I have set EntryTime = 1 (the default). How can open bar be different from entry bar? laugh

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

Joined: Sep 2013
Posts: 504
California
Alright, I have something I think you'll be interested to see.

Forgive me for abusing the algo identifier feature in this demonstration. I'm giving each bar its own algo id as a way of tracking the bar in which the trade was entered. (There is no such thing as TradeBarEntry).

Facts About This Program
1. Exactly 0 or 2 trades are entered in each bar. This is verified by checking the return values of enterLong.
2. Algo id changes with each bar, based on value of Bar.
3. In EXIT_RUN, I loop over for(all_trades) and print TradeAlgo, 2 per line.

I expect that when looping over for(all_trades) I should get pairs of trades with the same algo id, in order.

Instead, I observe that starting with bar 212 things start to get scrambled.
Quote:
,0000194,0000194
,0000195,0000195
,0000196,0000196
,0000197,0000197
,0000198,0000198
,0000199,0000199
,0000200,0000200
,0000201,0000201
,0000202,0000202
,0000203,0000203
,0000204,0000204
,0000205,0000205
,0000206,0000206
,0000207,0000207
,0000208,0000208
,0000209,0000209
,0000210,0000210
,0000211,0000211
,0000214,0000212
,0000213,0000213
,0000214,0000219
,0000215,0000218
,0000216,0000217
,0000218,0000219
,0000224,0000220

Program follows.
Code:
int trade_num;
string outfn[255];
char buff[65536] = { '\0' };

function run() {
  if (is(INITRUN)) {
    if(!is(TESTMODE))
      quit("Click [Test].");
    BarPeriod = 80;
    LookBack = 141;
    StartDate = 20131201;
    EndDate = 20131230;
    set(TICKS + MUTE);
    Hedge = 2;
    TradesPerBar = 2;
    Weekend = 1;
    EntryTime = 1;
  }

  asset("EUR/USD");

  sprintf(buff, "%07dL1", Bar);
  algo(buff);

  var atr100 = ATR(100);
  TakeProfit = 3 * atr100;
  Stop = 3 * atr100;

  // Verify that exactly 0 or 2 trades are entered per bar.
  bool not_entered_1 = false;
  bool not_entered_2 = false;

  sprintf(buff, "%07dL1", Bar);
  algo(buff);
  Entry = -0.125 * atr100;
  if (!enterLong()) {
    not_entered_1 = true;
  }

  sprintf(buff, "%07dL2", Bar);
  algo(buff);
  Entry = 0;
  if (!enterLong()) {
    not_entered_2 = true;
  }

  if (not_entered_1 != not_entered_2) {
    printf("\nOnly 1 trade was entered at Bar %d.", Bar);
    quit();
  }

  if(is(EXITRUN)) {
    buff[0] = 0;
    strcpy(outfn, "out.csv");
    file_delete(outfn);
    trade_num = 0;
    for(all_trades) {
      if (trade_num % TradesPerBar == 0) {
        strcat(buff, "\n");
        file_append(outfn, buff);
        buff[0] = 0;
      }
      strcat(buff, ",");
      strcat(buff, TradeAlgo);
      trade_num++;
    }
    file_append(outfn, "\n");
  }
}


If I change this program slightly, so that each enterLong gets its own algo id, I see that things really are stumbling all over each other.
Now, for the first enterLong algo = ("%07dL1", Bar) and for the second enterLong algo = ("%07dL2", Bar).
Quote:
,0000205L1,0000205L2
,0000206L1,0000206L2
,0000207L1,0000207L2
,0000208L1,0000208L2
,0000209L1,0000209L2
,0000210L1,0000210L2
,0000211L1,0000211L2
,0000214L1,0000212L2
,0000213L1,0000213L2
,0000214L2,0000219L1

I cannot reconcile these observations with your statement that all_trades is sorted in the order of entering the trade. Have I misunderstood you?

Re: A way to access advice signal values for training outside Zorro? [Re: GPEngine] #436086
01/19/14 02:07
01/19/14 02:07
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
This was a giant diversion from my goal.
I am resorting to keeping my own linked list of TRADE* in the order I expect.

Re: A way to access advice signal values for training outside Zorro? [Re: GPEngine] #436113
01/20/14 08:52
01/20/14 08:52
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
The trades are listed in the entry order. But the list only contains trades that were really opened. If a trade does not meet its entry condition, as probably happens in your example, it is 'recycled' and used for the next entered trade without changing its position in the list.

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

Joined: Sep 2013
Posts: 504
California
Let me rephrase this so we're certain I understand you.
The trades are listed in entry order except that if a trade fails to have its entry criteria met it leaves an empty space which gets recycled.

In other words, if some trades did not have their entry condition met, the trades in all_trades are not listed in entry order. I don't mean to call you out on it, but what the heck? Look at your answer to post #2.


Alright, so that behavior alone means I cannot use all_trades. Still, I'm curious.

Let's visit this part. If a trade fails to have its entry condition met it leaves an empty space which gets recycled. I am using EntryTime = 1. So the knowledge about whether a trade had its entry condition met should be resolved within the bar. Is Zorro is holding on to a pool of vacant positions, and only occasionally going back and recycling them, in arbitrary order? Because otherwise how could I see the level of scrambling I'm seeing?

0000209L1
0000210L1
0000211L1
0000214L1
0000213L1
0000219L1
0000218L1
0000224L1
0000221L1
0000223L1
0000225L1

Re: A way to access advice signal values for training outside Zorro? [Re: GPEngine] #436181
01/21/14 08:52
01/21/14 08:52
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
All trades are stored in an internal array, in the order of their entry command. Thus, the array grows by 1 with every trade. Only exception is when a trade misses its entry and is never executed. In that case, the trade is not removed from the array, but instead the next entered trade occupies its space. Naturally this trade has then an earlier array position than it would have otherwise.

This mechanism was implemented to make Zorro a little faster and reduce its memory footprint especially with strategies that place a huge number of pending trades. I admit that I do not really understand your problem. If you need a certain order of trades for some reason, you must anyway copy the trade pointers into a sorted list - so why can't you use the all_trades loop and what do you intend to use instead?

Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | 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