@jcl is it possible that there could be some issue with using file_content() and set(FACTORS) ??

I'm trying to integrate the above code but it seems whenever I use file_content() it breaks loading the .fac file with the following error:
Error 062: Can't open dt-e9-htc-30min.fac (rt)

I will try rewriting the function to use file_read() instead of file_content()

EDIT: it might be something else I'm doing wrong; it does seem to work on the proof-of-concept code above, even with set(FACTORS) so I'll have to keep poking at the code

EDIT2: it seems the issue has something to do with setting the trade stat variables, combined with reading .par and .fac files. I realize I may be doing something illegal by setting these values, but it seems to work as expected when there is no .par or .fac to be read. Therefore, I'll try another hack, which would be to let Zorro read the .par and .fac, and then reset those global stat variables after-the-fact. I just need a way to identify an "early iteration" of Zorro, perhaps not the INITRUN though.

EDIT3: interestingly, I think my theory is correct. If I simply allow Zorro to have the INITRUN to itself, it will allow me to read and reset the trade stats on an early non-first iteration. In WFO testing, it is later then unable to read the 2nd .par file, giving the error:
Quote:
dt-e9-htc-30min run..
Walk-Forward Test: dt-e9-htc-30min EURUSD 2008..2014
Read dt-e9-htc-30min_EURUSD.fac dt-e9-htc-30min_EURUSD_1.par
Error 062: Can't open dt-e9-htc-30min_2.par (rt)
...

That makes sense to me... it seems Zorro needs the stats to be reset when it begins testing a new parameter set, for some reason. Since .fac is only read once per entire WFO, it was able to do that on the INITRUN. Therefore, my tentative conclusion is that during TRADEMODE (live trading), it would work correctly, as there would only be one .fac and .par file read. After that iteration was complete, I would then read my .ini and reset the trad stats.

Here is the code I used to call my code from iteration 2:
Code:
static int zorroIteration;
if(is(INITRUN)) zorroIteration=0; else zorroIteration++;

//load most recent stats that were saved to disk
if (zorroIteration==1) loadStats("dt-e9-htc-30min.ini");



(I'm still testing and hope to run this on a demo account next week.)

EDIT4: seems like no matter what conditions I add, Zorro does not like to read the second .par file after I've read my text file (and manipulated the trade stat variables). I'm not sure if this is a "bug" or just an illegal operation in trying to set those trade stats. What I think it means is that... during WFO testing, the functions would interfere with normal WFO calculations. You wouldn't normally use them anyway, except for TRADEMODE. Here is the latest code that seems to work. I'll know better next week when I can get it tested on a demo account:
Code:
static int zorroIteration, LastWFOCycle;
if(is(INITRUN)) zorroIteration=1; else zorroIteration++;
if(WFOCycle != LastWFOCycle) printf("\nWFOCycle = %i",WFOCycle);
if(is(INITRUN)) LastWFOCycle=0; else LastWFOCycle = WFOCycle;

//load most recent stats that were saved to disk
if (zorroIteration==2) loadStats("dt-e9-htc-30min.ini");

//save stats to disk periodically, or upon trade count changes
if(minute()==60 || NumOpenTotal != numOpenLastCheck) saveStats("dt-e9-htc-30min.ini");
numOpenLastCheck = NumOpenTotal;



Last edited by dusktrader; 02/08/14 16:45.