forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Software

Create and Test Forex Strategies

You are not logged in. Please login or register.


Forex Software → Expert Advisor Studio → Data import - Exclude Weekend Data

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 8

Topic: Data import - Exclude Weekend Data

I modified the script to remove Saturday and Sunday candles.

for (int i = bars - 1; i >= 0; i--)
    {
        if (TimeDayOfWeek(Time[i]) != 0 && TimeDayOfWeek(Time[i]) != 6)
        {
           StringAdd(time,   IntegerToString((rates[i].time - millennium) / 60) + ",");
           StringAdd(open,   IntegerToString((int) MathRound(rates[i].open  * multiplier)) + ",");
           StringAdd(high,   IntegerToString((int) MathRound(rates[i].high  * multiplier)) + ",");
           StringAdd(low,    IntegerToString((int) MathRound(rates[i].low   * multiplier)) + ",");
           StringAdd(close,  IntegerToString((int) MathRound(rates[i].close * multiplier)) + ",");
           StringAdd(volume, IntegerToString(rates[i].tick_volume) + ",");
        }
    }

Everything worked well!

Today I decided to update my data and now the script has stopped working, giving me array out of range error for that if-statement.

Only change was MT update, did it mess up the script behaviour?

Re: Data import - Exclude Weekend Data

The problem is that Time is the time of the current chart, but later you export rates ... Depending on the chart you run the script, it may happen that bars is longer than the number of bars on the current chart and Time[ i ] crashes.

The solution is simple - replace Time with rates[ i ].time:

    for (int i = bars - 1; i >= 0; i--)
    {
        int dayOfWeek = TimeDayOfWeek(rates[i].time);
        if (dayOfWeek > SUNDAY && dayOfWeek < SATURDAY)
        {
            StringAdd(time,   IntegerToString((rates[i].time - millennium) / 60) + ",");
            StringAdd(open,   IntegerToString((int) MathRound(rates[i].open  * multiplier)) + ",");
            StringAdd(high,   IntegerToString((int) MathRound(rates[i].high  * multiplier)) + ",");
            StringAdd(low,    IntegerToString((int) MathRound(rates[i].low   * multiplier)) + ",");
            StringAdd(close,  IntegerToString((int) MathRound(rates[i].close * multiplier)) + ",");
            StringAdd(volume, IntegerToString(rates[i].tick_volume) + ",");
        }    
    }

..

and replacing the negation != with > < smile

Re: Data import - Exclude Weekend Data

smile It works! Thank you, Miroslav, you're a star!

Re: Data import - Exclude Weekend Data

It might be for useful for others as well, data import script with weekend data exclusion below.

Post's attachments

EA Studio Data Export Weekend Exclusion.mq4 6.38 kb, 4 downloads since 2017-02-16 

You don't have the permssions to download the attachments of this post.

Re: Data import - Exclude Weekend Data

Do you use that when downloading from Dukas?

Re: Data import - Exclude Weekend Data

Yeah, dukas has weekends marked, very annoying. With this script no weekend bars.

7 (edited by Blaiserboy 2017-02-18 02:28:51)

Re: Data import - Exclude Weekend Data

Thanks.....!

So far, I have been using broker data (MT5).

Is there some reason why you have use dukas data instead of your broker.  Did you do some testing to see a benefit?

I have the script set to 100,000 bars.....

The data supplied by EA Studio is much less as Popov has tried to get quality data only.

I am kinda mixed up as to which to use.... broker data with errors or clean data supplied or. dukas. LOLOL

Lately I have been using the supplied data and been having good luck using the strategies.. of course, that could change as the weeks pass.

Opinion?


(I am running two copies to generate new strategies..... and a third to try to improve on the best strategies generated, like copying the generated strategy into the third copiy and adding a couple indicators to see if I can generate better quality metrics..... sorta tedious but getting some good results for very little effort because EA Studio is so powerful.)

Re: Data import - Exclude Weekend Data

As I'm working with 8 pairs, I need similar and same length datasets for proper evaluation and scenarios. That's why I went to duka data. Additionally, I can set up a bit higher spread with imported data, that way I make the test a bit harder.

Posts: 8

Pages 1

You must login or register to post a reply

Forex Software → Expert Advisor Studio → Data import - Exclude Weekend Data

Similar topics in this forum