history data for spy not work ?

Posted By: faustf

history data for spy not work ? - 06/07/23 23:01

hi i download a history spx500 http://opserver.de/down/history_SPY.zip uncompress and insert the data inside the forlder \Zorro\History after i create a simple script
function run()
{
set(PARAMETERS+LOGFILE);
BarPeriod = 1440; // Periodo giornaliero

if(day() == MONDAY && hour() == 23 && minute() == 58)
{
// Calcola l'RSI a 2 periodi
vars Price = series(price());
vars RSI2 = series(RSI(Price, 2));

if(RSI2[0] < 30)
{
enterLong(1);
printf("Entered long position");
}
}

if(day() == WEDNESDAY && hour() == 0 && minute() == 5)
{
exitLong(1);
printf("Exited long position");
}
}

i choice in script my script and spx500 test but tell me

spx compiling...........
Error 047: SPX500 no 2018 history (History\SPX500.t6)
Error 047: SPX500 2018..2023 no data
Error 047: No SPX500 prices
Posted By: AndrewAMD

Re: history data for spy not work ? - 06/08/23 02:42

Probably because you downloaded SPY data instead of SPX500 data.
Posted By: faustf

Re: history data for spy not work ? - 06/08/23 08:29

but why if i insert in history spy when i open a combobox not appear , and i saw only spx500 ?
Posted By: Grant

Re: history data for spy not work ? - 06/08/23 09:14

You need to adjust your asset list file, see https://zorro-project.com/manual/en/account.htm
Posted By: faustf

Re: history data for spy not work ? - 06/08/23 20:24

thanks for rply i add this line SPY,2838,0.5,0.0645,-0.1439,1,0.1,-1,0,0.1,0,SPY/USD at file assefix.csv now appear spy i run my script
function run()
{
set(PARAMETERS+LOGFILE);
BarPeriod = 1440; // Periodo giornaliero

if(day() == MONDAY && hour() == 23 && minute() == 58)
{
// Calcola l'RSI a 2 periodi
vars Price = series(price());
vars RSI2 = series(RSI(Price, 2));

if(RSI2[0] < 30)
{
enterLong(1);
printf("Entered long position");
}
}

if(day() == WEDNESDAY && hour() == 0 && minute() == 5)
{
exitLong(1);
printf("Exited long position");
}
}


but after run i click over button result but showme only a chart with out open and close operation not have simulated nothing , anyone know why ?? thanks again
Posted By: AndrewAMD

Re: history data for spy not work ? - 06/08/23 20:48

run() is only called once per day at BarPeriod 1440, yet you’re checking for entry and exit conditions as if it’s an intraday script. Eliminate those conditions.
Posted By: faustf

Re: history data for spy not work ? - 06/09/23 20:29

i remove function run but i have this error

Zorro 2.48.1
(c) oP group Germany 2022


spx compiling...........
Test: spx SPY 2018..2023


spx compiling...........
Error 061: No main or run function!
Posted By: Grant

Re: history data for spy not work ? - 06/10/23 17:58

Because you removed the run() function for whatever reason.
Posted By: faustf

Re: history data for spy not work ? - 06/11/23 21:34

ops sorry i eliminate bar period
function run()
{
set(PARAMETERS+LOGFILE);
//BarPeriod = 1440; // Periodo giornaliero

if(day() == MONDAY && hour() == 23 && minute() == 58)
{
// Calcola l'RSI a 2 periodi
vars Price = series(price());
vars RSI2 = series(RSI(Price, 2));

if(RSI2[0] < 30)
{
enterLong(1);
printf("Entered long position");
}
}

if(day() == WEDNESDAY && hour() == 0 && minute() == 5)
{
exitLong(1);
printf("Exited long position");
}
}


but return me thesame result .... only the chart
Posted By: Grant

Re: history data for spy not work ? - 06/12/23 00:09

You disabled BarPeriod, so that means you're using 1 hour bars by default. However, you're checking if 'minute() == 58', so that won't work with this BarPeriod.
Andrew already wrote this.

https://zorro-project.com/manual/en/barperiod.htm
Posted By: faustf

Re: history data for spy not work ? - 06/12/23 19:23

but if i remove this how can controll if is monday at 23:58 ???? i want execute this not always
Posted By: faustf

Re: history data for spy not work ? - 06/12/23 20:46

i modify my script i this mode now return me this error

spx compiling........
Error in 'line 15:
Syntax error: Wrong type NOT:DOUBLE::LONG
< if(RSI2[0] < 30 && !isPositionOpen)
>

var isPositionOpen = 0; // Variabile per tenere traccia dello stato della posizione

function run()
{
set(PARAMETERS+LOGFILE);
//BarPeriod = 1440; // Periodo giornaliero

if(day() == MONDAY && hour() == 23 )
{
// Calcola l'RSI a 2 periodi
vars Price = series(price());
vars RSI2 = series(RSI(Price, 2));

if(RSI2[0] < 30 && !isPositionOpen)
{
enterLong(1);
isPositionOpen = 1; // Imposta lo stato della posizione su aperta
printf("Entered long position");
}
}

if(day() == WEDNESDAY && hour() == 0 && isPositionOpen)
{
exitLong(1);
isPositionOpen = 0; // Imposta lo stato della posizione su chiusa
printf("Exited long position");
}
}
Posted By: AndrewAMD

Re: history data for spy not work ? - 06/12/23 21:21

That’s because isPositionOpen is the wrong type in Lite C. It is a var. Change it to int.
Posted By: Grant

Re: history data for spy not work ? - 06/13/23 11:38

I think we have a language barrier. You should use 'BarPeriod = 1;' to make your trading rule valid.
Posted By: faustf

Re: history data for spy not work ? - 06/13/23 19:15

but why not close the first WEDNESDAY after open monday ??? look the result https://ibb.co/w7DHF2k
Posted By: Grant

Re: history data for spy not work ? - 06/13/23 21:54

My bad, I just saw that you removed 'minute() == 58' from your trading rule in your latest version.
Posted By: faustf

Re: history data for spy not work ? - 06/14/23 19:24

i insert a minuts , but never operate o_O

int isPositionOpen = 0; // Variabile per tenere traccia dello stato della posizione

function run()
{
set(PARAMETERS+LOGFILE);
//BarPeriod = 1440; // Periodo giornaliero

if(day() == MONDAY && hour() == 23 && minute() == 58)
{
// Calcola l'RSI a 2 periodi
vars Price = series(price());
vars RSI2 = series(RSI(Price, 2));

if(RSI2[0] < 30 && !isPositionOpen)
{
enterLong(1);
isPositionOpen = 1; // Imposta lo stato della posizione su aperta
printf("Entered long position");
}
}

if(day() == WEDNESDAY && hour() == 0 && minute() == 5 && isPositionOpen)
{
exitLong(1);
isPositionOpen = 0; // Imposta lo stato della posizione su chiusa
printf("Exited long position");
}
}
Posted By: Grant

Re: history data for spy not work ? - 06/15/23 00:07

Both Andrew and I already explained you why this is. Please READ those posts again.
Posted By: faustf

Re: history data for spy not work ? - 06/15/23 19:17

i modify the script in this mode barperiod=1

int isPositionOpen = 0; // Variabile per tenere traccia dello stato della posizione

function run()
{
set(PARAMETERS+LOGFILE);
BarPeriod = 1;

if(day() == MONDAY && hour() == 23 && minute() == 58)
{
// Calcola l'RSI a 2 periodi
vars Price = series(price());
vars RSI2 = series(RSI(Price, 2));

if(RSI2[0] < 30 && !isPositionOpen)
{
enterLong(1);
isPositionOpen = 1; // Imposta lo stato della posizione su aperta
printf("Entered long position");
}
}

if(day() == WEDNESDAY && hour() == 0 && minute() == 5 && isPositionOpen)
{
exitLong(1);
isPositionOpen = 0; // Imposta lo stato della posizione su chiusa
printf("Exited long position");
}
}

but not close in wednesday https://ibb.co/cJcgn0R
Posted By: faustf

Re: history data for spy not work ? - 06/16/23 20:20

i try to modify the script in this mode
int isPositionOpen = 0; // Variabile per tenere traccia dello stato della posizione

function run()
{
set(PARAMETERS+LOGFILE);
BarPeriod = 60;


if(day() == MONDAY && hour() == 23 )

{
// Calcola l'RSI a 2 periodi
vars Price = series(price());
vars RSI2 = series(RSI(Price, 2));

if(RSI2[0] < 30 && !isPositionOpen)
{
enterLong(1);
isPositionOpen = 1; // Imposta lo stato della posizione su aperta
printf("Entered long position");
}
}

if(day() == WEDNESDAY && hour() == 0 && isPositionOpen)
{
exitLong(1);
isPositionOpen = 0; // Imposta lo stato della posizione su chiusa
printf("Exited long position");
}
}

but nothing not close in WEDNESDAY :(((
Posted By: Grant

Re: history data for spy not work ? - 06/17/23 23:50

All of your script proposals contain many bugs, but right now I'm referring to your versions with the minute() rules:

- When using series(), always use them in the beginning of your run() function, NOT after an if-statement.
- day() refers to day of the month, see https://zorro-project.com/manual/en/month.htm. In your case you should use dow().
- isPositionOpen is declared as integer, but you're using it as a boolean in your if-statements.
- When printing something to the console, use a new line, so this means starting with '\n'.
- When closing a postion, simply use 'exitLong()'

Remark: there's no need to define the value 'isPositionOpen = 0' in the beginning, since '0' is already the default value.

Here's the fixed code:

Code
int isPositionOpen; // Variabile per tenere traccia dello stato della posizione

function run()
{	
set(PARAMETERS+LOGFILE);
BarPeriod = 1;

// Calcola l'RSI a 2 periodi
vars Price = series(price());
vars RSI2 = series(RSI(Price, 2));

if(dow() == 1 && hour() == 23 && minute() == 58)
{

if(RSI2[0] < 30 && isPositionOpen == 0)
{
enterLong(1);
isPositionOpen = 1; // Imposta lo stato della posizione su aperta
printf("\nEntered long position");
}
}

if(dow() == 3 && hour() == 0 && minute() == 5 && isPositionOpen == 1)
{
exitLong();
isPositionOpen = 0; // Imposta lo stato della posizione su chiusa
printf("\nExited long position");
}
}
Posted By: faustf

Re: history data for spy not work ? - 06/21/23 19:00

thanks so much now is clear thanks you so much
Posted By: faustf

Re: history data for spy not work ? - 06/21/23 20:40

why if i chabge if(dow() == 5 && hour() == 0 && minute() == 5 && isPositionOpen == 1) choice (dow() == 5 but close a operation many month after

https://ibb.co/BjXqhKr
Posted By: Grant

Re: history data for spy not work ? - 06/21/23 21:08

So as a closing rule, right? Simply because it can take some time before all criteria are met.

I've tested your rule on the EUR/USD and I see plenty of trades

Quote
Name,Type,Asset,ID,Lots,Open,Close,Entry,Exit,Profit,Roll,ExitType
faust,Long,EUR/USD,1927593,1,2019-01-21 23:58,2019-01-25 00:05,1.136950,1.130732,-6.40,-0.20,Sold
faust,Long,EUR/USD,3329733,1,2019-02-04 23:58,2019-02-08 00:05,1.143615,1.133903,-9.88,-0.20,Sold
faust,Long,EUR/USD,4028803,1,2019-02-11 23:58,2019-02-15 00:05,1.127930,1.129540,+1.40,-0.20,Sold
faust,Long,EUR/USD,7531954,1,2019-03-18 23:58,2019-03-22 00:05,1.133663,1.137298,+3.42,-0.20,Sold
faust,Long,EUR/USD,8233324,1,2019-03-25 23:58,2019-03-29 00:05,1.131596,1.122957,-8.81,-0.20,Sold
faust,Long,EUR/USD,8935194,1,2019-04-01 23:58,2019-04-05 00:05,1.120600,1.122365,+1.56,-0.20,Sold
faust,Long,EUR/USD,9634964,1,2019-04-08 23:58,2019-04-12 00:05,1.125646,1.125946,+0.0969,-0.20,Sold
faust,Long,EUR/USD,10335434,1,2019-04-15 23:58,2019-04-26 00:05,1.130482,1.113237,-17.87,-0.67,Sold
faust,Long,EUR/USD,13822483,1,2019-05-20 23:58,2019-05-24 00:05,1.116894,1.118284,+1.18,-0.20,Sold
...
Posted By: faustf

Re: history data for spy not work ? - 06/22/23 19:05

yes but the condition is wendsday at morning must close not is like time
Posted By: Grant

Re: history data for spy not work ? - 06/22/23 23:00

You keep changing your training rules. You wrote 'dow() == 5' in your last post, so that means on a Friday. Simply use 'dow() == 3' for Wednesday.
Posted By: faustf

Re: history data for spy not work ? - 06/23/23 18:56

i chenged but not close in Wednesday
Posted By: Grant

Re: history data for spy not work ? - 06/23/23 23:19

Not sure what you've exactly changed, but I see plenty of closings on Wednesday:

Quote
Name,Type,Asset,ID,Lots,Open,Close,Entry,Exit,Profit,Roll,ExitType
faust,Long,EUR/USD,1927593,1,2019-01-21 23:58,2019-01-23 00:05,1.136950,1.136316,-0.70,-0.07,Sold
faust,Long,EUR/USD,3329733,1,2019-02-04 23:58,2019-02-06 00:05,1.143615,1.140600,-3.07,-0.07,Sold
faust,Long,EUR/USD,4028803,1,2019-02-11 23:58,2019-02-13 00:05,1.127930,1.133254,+5.24,-0.07,Sold
faust,Long,EUR/USD,7531954,1,2019-03-18 23:58,2019-03-20 00:05,1.133663,1.135462,+1.73,-0.07,Sold
faust,Long,EUR/USD,8233324,1,2019-03-25 23:58,2019-03-27 00:05,1.131596,1.127346,-4.30,-0.07,Sold
faust,Long,EUR/USD,8935194,1,2019-04-01 23:58,2019-04-03 00:05,1.120600,1.120275,-0.39,-0.07,Sold
faust,Long,EUR/USD,9634964,1,2019-04-08 23:58,2019-04-10 00:05,1.125646,1.126610,+0.89,-0.07,Sold
faust,Long,EUR/USD,10335434,1,2019-04-15 23:58,2019-04-17 00:05,1.130482,1.128434,-2.11,-0.07,Sold
faust,Long,EUR/USD,11028003,1,2019-04-22 23:58,2019-04-24 00:05,1.125931,1.122101,-3.89,-0.07,Sold


Code
if(dow() == 3 && hour() == 0 && minute() == 5 && isPositionOpen == 1)
...
Posted By: faustf

Re: history data for spy not work ? - 06/27/23 18:55

but not close if i look a chart look image https://ibb.co/Q6f7YK9
Posted By: Grant

Re: history data for spy not work ? - 06/27/23 20:42

Different data sets, different outcomes. We're talking in circles here.
Posted By: faustf

Re: history data for spy not work ? - 06/28/23 17:50

i use fxopen demo this is my history https://fromsmash.com/historyspx
© 2024 lite-C Forums