5 registered members (AndrewAMD, ozgur, Ayumi, 2 invisible),
690
guests, and 10
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: history data for spy not work ?
[Re: faustf]
#487618
06/17/23 23:50
06/17/23 23:50
|
Joined: Aug 2017
Posts: 296 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 296
Netherlands
|
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: 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");
}
}
|
|
|
Re: history data for spy not work ?
[Re: faustf]
#487627
06/21/23 21:08
06/21/23 21:08
|
Joined: Aug 2017
Posts: 296 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 296
Netherlands
|
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 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 ...
|
|
|
Re: history data for spy not work ?
[Re: faustf]
#487636
06/23/23 23:19
06/23/23 23:19
|
Joined: Aug 2017
Posts: 296 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 296
Netherlands
|
Not sure what you've exactly changed, but I see plenty of closings on Wednesday: 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 if(dow() == 3 && hour() == 0 && minute() == 5 && isPositionOpen == 1)
...
|
|
|
|