Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

$DayOfWeek parameter type not supported
 Post subject: $DayOfWeek parameter type not supported Post rating: 0   New post Posted: Tue 11 Dec, 2012, 04:20 
User avatar

User rating: 1
Joined: Fri 14 Sep, 2012, 02:25
Posts: 57
Location: New Zealand, Christchurch
hi - why can't I use DayOfWeek in a demo account Strategy remote run?
I get this error when I try & start it:

2012-12-11 03:08:17 Unable to run strategy remotely : Parameter type is not supported : jforex.strategies.indicators.fxp205$DayOfWeek; Parameter type is not supported : jforex.strategies.indicators.fxp205$DayOfWeek

It is fine on Local run & on Historical tester.
(other strategies without $DayOfWeek are fine on Remote run.)
I don't think I'm attempting anything unusual - here is example of how I'm using it:
@Configurable("Start Week")  public DayOfWeek openDayOfWeek  = DayOfWeek.MONDAY;
    @Configurable("Open hour")   public int openHour             = 7;
    @Configurable("Open min")    public int openMin              = 0;
    @Configurable("Close hour")  public int closeHour            = 19;
    @Configurable("Close min")   public int closeMin             = 0;
    @Configurable("End Week")    public DayOfWeek closeDayOfWeek = DayOfWeek.FRIDAY;

enum DayOfWeek {
        SUNDAY(1),
        MONDAY(2),
        TUESDAY(3),
        WEDNESDAY(4),
        THURSDAY(5),
        FRIDAY(6),
        SATURDAY(7);
        private int idx;
        private DayOfWeek(int idx) {
            this.idx = idx;
        }
        public int getIdx() {
            return idx;
        }
    }

if (!isInInterval(tick.getTime(), openDayOfWeek.getIdx(), openHour, openMin, closeDayOfWeek.getIdx(), closeHour, closeMin)) {
                closeOrder(shortOrder);
                closeOrder(longOrder);
                return;
            }

public boolean isInInterval(long time, int fromDayOfWeek, int fromHour, int fromMin, int toDayOfWeek, int toHour, int toMin){

        Calendar calFrom = new GregorianCalendar();
        calFrom.setTimeZone(TimeZone.getTimeZone("GMT"));
        calFrom.setTimeInMillis(time);
        calFrom.set(Calendar.HOUR_OF_DAY, fromHour);
        calFrom.set(Calendar.MINUTE, fromMin);

        Calendar calTo = new GregorianCalendar();
        calTo.setTimeZone(TimeZone.getTimeZone("GMT"));
        calTo.setTimeInMillis(time);
        calTo.set(Calendar.HOUR_OF_DAY, toHour);
        calTo.set(Calendar.MINUTE, toMin);

        if (Every_Day) {
            if (time >= calFrom.getTimeInMillis()  &&         // test time regardless of day
                time <= calTo.getTimeInMillis())
                    return true;
            else    return false;
        }
        Calendar calNow = new GregorianCalendar();
        calNow.setTimeZone(TimeZone.getTimeZone("GMT"));
        calNow.setTimeInMillis(time);
       
        if ((calNow.get(Calendar.DAY_OF_WEEK) >  fromDayOfWeek &&     // Tues - Thurs all ok
            (calNow.get(Calendar.DAY_OF_WEEK) <  toDayOfWeek)))
                return true;
        if ((calNow.get(Calendar.DAY_OF_WEEK) == fromDayOfWeek && time >= calFrom.getTimeInMillis())  ||    // Mon
            (calNow.get(Calendar.DAY_OF_WEEK) == toDayOfWeek   && time <=   calTo.getTimeInMillis()))        // Fri
                return true;
       
        return false;
    }


 
 Post subject: Re: $DayOfWeek parameter type not supported Post rating: 0   New post Posted: Tue 11 Dec, 2012, 08:17 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
fprophet wrote:
2012-12-11 03:08:17 Unable to run strategy remotely : Parameter type is not supported : jforex.strategies.indicators.fxp205$DayOfWeek; Parameter type is not supported : jforex.strategies.indicators.fxp205$DayOfWeek
You can't use user libraries of strategy remote run, see:
viewtopic.php?f=21&t=23909
Consider using Java SE libraries instead, see:
https://www.dukascopy.com/wiki/#Customize_trading_hours


 

Jump to:  

  © 1998-2026 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com