Gamestudio Links
Zorro Links
Newest Posts
Bug in train mode, or it seem to me
by mistery. 09/24/26 17:34
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 09/22/26 12:21
Capital slider is not saving in Z12
by Petra. 09/22/26 06:49
Parent/child object
by VoroneTZ. 09/22/26 05:52
Zorro tutorial ideas?
by AndrewAMD. 09/21/26 14:50
Trades during a running bar
by Martin_HH. 09/21/26 12:03
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (bigsmack, 3run, AndrewAMD), 37,438 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Knull, Opus, Jubilee, lopezsergio07, mistery
19240 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Bug in train mode, or it seem to me #489657
09/22/26 09:40
09/22/26 09:40
Joined: Sep 2026
Posts: 3
M
mistery Offline OP
Guest
mistery  Offline OP
Guest
M

Joined: Sep 2026
Posts: 3
First i am a newbie, so sorry if i am missing something, thanks if some answer is received

Easy strategy over QQQ eod *t6 data, open trade any day of week at market open and close any day at market close (just for testing propose)
after train best parameters are 1.54 to open and 4.32 to close the trade. I test then to get a +17% annual return
Then i can open the *.par and change the 1.54 to 4.00, and test again to get a +142%, i can change to 1.00 and return is 63%
What i am doing wrong? to me seem the train is not getting best values.

I attack the QQQ.t6 data here: https://drive.google.com/file/d/1EunmN96XuVFCOmNWyxM7d62RDoU0ULlI/view?usp=drive_link
And copy the strategy bellow:



// Simple Zorro Lite-C bot:

TRADE *myTrade;


function run()
{
set(PARAMETERS,LOGFILE); // write a trade log so you can verify fills
BarPeriod = 1440; // 1440 minutes = daily bars (matches EOD data)
LookBack = 0; // no indicators, no warm-up period needed

StartDate = 20160101; // adjust to taste, or delete to use full history
EndDate = 20171231; // Dates need to match FFFFMMDD format if you put just FFFF not work
// in trest mode, just works to download data

//asset("IWM_eod"); // loads C:\Zorro\History\IWM_eod.t6
asset("QQQ"); // loads C:\Zorro\History\QQQ.t6
Spread = 0; // bid/ask spread in pips (or price units) — 0 = no spread cost
Slippage = 0; // slippage added to fill price — 0 = fill exactly at the modeled price
Commission = 0; // commission per lot/contract — 0 = no commission
RollLong = 0; // overnight long swap/rollover — 0 = no carry cost
RollShort = 0; // overnight short swap/rollover — 0 = no carry cost

// --- DIAGNOSTIC: print what Zorro sees on the days that matter ---
// if(dow(0) == (1) || dow(0) == 2 || dow(0) == 3 || dow(0) == 4 || dow(0) == 5)
// printf("\n%s dow=%i Open=%.3f Close=%.3f",
// strdate("%Y-%m-%d", 0), dow(0), priceOpen(), priceClose());

//setf(TrainMode,TRADES+PEAK); //Funciona por que en train da 1.00
var DiaPreOpen = optimize("Parametro DiaPreOpen",5,1,5,1);
int IntDiaPreOpen = (int)round(DiaPreOpen);
// (int) recast a still stored in the 8-byte
//floating-point format to a genuine integer, i tested without (int) and work
//var DiaSemana = optimize("Parametro DiaSemana",2,1,4,1);

// --- Entry: signal on Tuesday (2), fills at Wednesday's open ---
// Fill=3 delays the fill to the next price quote (next bar's open).
printf("\n DiaPreOpen=%.3f", DiaPreOpen); //Saldrá un float
printf("\n IntDiaPreOpen=%i", IntDiaPreOpen); // Saldrá un integer
if(dow(0) == IntDiaPreOpen && !myTrade) {
Fill = 3;
myTrade = enterLong();
}

// Fill=1 fills at the most recent quote instead of waiting for the next
// one, so with daily bars the close order fills at THIS bar's close
// (Thursday), not the following day's open.

var DiaClose = optimize("Parametro DiaClose",4,1,5,1);
int IntDiaClose = (int)round(DiaClose);
if(dow(0) == IntDiaClose && myTrade) {
Fill = 1;
exitTrade(myTrade);

// --- DIAGNOSTIC: confirm the exit landed on THIS (Thursday) bar
// and that no Stop/Trail line appears for this trade in the log.
printf("\n >> EXIT check: signaled %s (dow=%i) at Close=%.3f -- check trade log above for Stop/Trail lines",
strdate("%Y-%m-%d", 0), dow(0), priceClose());

myTrade = 0;
Fill = 3; // restore delayed fill for the next Tuesday entry
}
}

Re: Bug in train mode, or it seem to me [Re: mistery] #489659
09/22/26 14:47
09/22/26 14:47
Joined: Jul 2000
Posts: 28,135
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,135
Frankfurt
You can see in the parameter charts the performance of any parameter over its range. If training does not select the best parameter, it's either a single peak and thus an unstable system, or you have a bug in your script that affects trading.

If you can't find the bug, we do have a script fixing service. Contact support and they'll find it. Of course, if it really is a Zorro bug, the fee will be refunded - but from your description, this sounds very, very unlikely.

Re: Bug in train mode, or it seem to me [Re: jcl] #489661
Yesterday at 17:34
Yesterday at 17:34
Joined: Sep 2026
Posts: 3
M
mistery Offline OP
Guest
mistery  Offline OP
Guest
M

Joined: Sep 2026
Posts: 3
Thanks jcl, i undesrtand you. Time is glod, and your i guess is more gold than mine. Happy you have the "script fixing service". By the way congratulations on your Zorro Project, i am near tu buy it

After serveral days working on it + AI aid, i attach the working system, just in case it helps others, notice system is only for testings purpose, i am sure it is overfitted

// Weekly entry/exit test - QQQ daily bars - trainable
//
// Parameters (all describe the ACTUAL fill moment, not the signal day):
// EntryDay / ExitDay : 1=Mon .. 5=Fri, 0 = every day
// EntryOpen / ExitOpen : 0 = fill at the CLOSE of that day
// 1 = fill at the OPEN of that day
//
// How it is done (run() executes at the close of each bar):
// fill at CLOSE of day D -> signal on D, Fill = 1
// fill at OPEN of day D -> signal on previous day, Fill = 3
//
// Same-bar ordering: close-fills happen before open-fills.
// - entry at close + exit at next open (overnight): entry first, then exit
// - everything else: exit first, then entry

int EntryDay, EntryOpen, ExitDay, ExitOpen;
TRADE* Cur = 0; // the one trade we manage

int prevDay(int d) // Mon -> Fri, otherwise d-1
{
if(d <= 1) return 5;
return d - 1;
}

void doExit()
{
if(!Cur) return;
if(ExitOpen) Fill = 3; else Fill = 1;
exitTrade(Cur);
Cur = 0;
}

void doEntry()
{
if(Cur) return;
if(EntryOpen) Fill = 3; else Fill = 1;
Cur = enterLong();
}

function run()
{
set(LOGFILE, PARAMETERS);
BarPeriod = 1440;
LookBack = 0;

StartDate = 20160101;
EndDate = 20171231;

asset("QQQ");
Spread = 0; Slippage = 0; Commission = 0;
RollLong = 0; RollShort = 0;

if(is(INITRUN)) Cur = 0; // never keep a stale pointer between runs

// optimize(Start, Min, Max, Step) - same calls, same order, every bar
// Start values = your earlier test: buy Tue open, sell next Mon close
EntryDay = (int)round(optimize("EntryDay",2, 0, 5, 1),1);
EntryOpen = (int)round(optimize("EntryOpen",1, 0, 1, 1),1);
ExitDay = (int)round(optimize("ExitDay",1, 0, 5, 1),1);
ExitOpen = (int)round(optimize("ExitOpen",1, 0, 1, 1),1);

int d = dow(0);
int eSig = EntryDay;
if(EntryOpen) eSig = prevDay(EntryDay); //So, if true (1) enter at open
int xSig = ExitDay;
if(ExitOpen) xSig = prevDay(ExitDay); //So, if true (1) enter at open
int doE = (EntryDay == 0) || (d == eSig);
int doX = (ExitDay == 0) || (d == xSig);

if(!EntryOpen && ExitOpen) { // close -> open (overnight)
if(doE) doEntry();
if(doX) doExit();
} else {
if(doX) doExit();
if(doE) doEntry();
}


//PlotBars
set(LOGFILE,PLOTNOW);
plot("EntryDay", EntryDay,NEW,BLUE);
plot("ExitDay", ExitDay,0,RED);
}


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1