|
|
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
GPEngine
OP
User
|
OP
User
Joined: Sep 2013
Posts: 504
California
|
My understanding is In Train mode, this call
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]
#436081
01/18/14 18:14
01/18/14 18:14
|
Joined: Sep 2013
Posts: 504 California
GPEngine
OP
User
|
OP
User
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. ,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.
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). ,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?
|
|
|
|