2 registered members (AndrewAMD, juanex),
1,247
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Keeping non-24h markets synchronized in live and backtest
[Re: MattY]
#462778
10/28/16 07:05
10/28/16 07:05
|
Joined: Aug 2016
Posts: 66
dr_panther
Junior Member
|
Junior Member
Joined: Aug 2016
Posts: 66
|
You could define the open time of a market like that (from the manual)
function run()
{
...
StartWeek = 10400; // start Monday 4 am
EndWeek = 51900; // end Friday 7 pm
Weekend = 7; // log off during the weekend
...
}
|
|
|
Re: Keeping non-24h markets synchronized in live and backtest
[Re: dr_panther]
#462816
10/30/16 08:34
10/30/16 08:34
|
Joined: Jun 2016
Posts: 9 Germany, BW
MattY
OP
Newbie
|
OP
Newbie
Joined: Jun 2016
Posts: 9
Germany, BW
|
Hey, thanks! StartWeek/EndWeek work, but they skip bars only at the beginning and end of the week.I am looking for a function that skips bars once a day. In the meanwhile I found the TimeFrame function. The manual states that it is for "for skipping bars outside market hours or when no price ticks arrive". I implemented this code to my script.
// skipping bars for a certain time period
static int BarsMissing = 0;
if(hour() >= 21 and hour() < 22) // 0 when the current bar has no price quotes
{
TimeFrame = 0; // set to zero when not in frame
BarsMissing++;
}
else if (hour() == 22 and minute() == 0 )
{
TimeFrame = -BarsMissing; // set TimeFrame to the negative number of skipped bars for ending the frame
BarsMissing = 0;
}
else
TimeFrame = 1; // Normal operation
But only the prices and indicator values are fixed for the specified time period and no bars are skipped. Anything wrong with the implementation?
|
|
|
Re: Keeping non-24h markets synchronized in live and backtest
[Re: Finstratech]
#462986
11/09/16 20:36
11/09/16 20:36
|
Joined: Jun 2016
Posts: 9 Germany, BW
MattY
OP
Newbie
|
OP
Newbie
Joined: Jun 2016
Posts: 9
Germany, BW
|
Thanks, but if I add an hour() condition to the complete function run() I get this error: Error 041: Inconsistent series calls / too many series Number or order of series calls in the script are different between run cycles, due to a bug in the script. Make sure that all series calls - or function calls that internally create series, such as LowPass, ATR, etc. - have the same order in every run, and are not skipped with if statements. Make also sure that your script does not generate series in tick-based intrabar functions (TMF, tick) or in endless loops. And I think it's not enough to put the entry and exit statements in an hour() condition, because I also don't want the indicators to be calculated for a specific time. /Matt
|
|
|
Re: Keeping non-24h markets synchronized in live and backtest
[Re: MattY]
#463069
11/13/16 00:43
11/13/16 00:43
|
Joined: Apr 2014
Posts: 482 Sydney, Australia
boatman
Senior Member
|
Senior Member
Joined: Apr 2014
Posts: 482
Sydney, Australia
|
@MattY - you would get that error if you put a series definition inside the if() statement. Series need to be created in the same way and in the same order for each iteration of the run function, therefore you shouldn't put them inside flow control statements. You could try defining your series outside the if() statement, and then wrapping only your entry logic inside the if() statement. Example:
vars mySeries = series(...);
if(tradeCondition == true)
{
Entry = priceHigh();
enterLong();
}
|
|
|
|