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.

send text or date and time input argument to indicator
 Post subject: send text or date and time input argument to indicator Post rating: 0   Post Posted: Thu 06 Dec, 2012, 14:24 
User avatar

User rating: 1
Joined: Wed 06 Jul, 2011, 23:12
Posts: 42
Location: Romania, Bucharest
Dear Sirs,


What is the simplest method to send exact date and time as optional input parameter to an indicator?

For example, I need this if I want to show the cumulated volume (or better, a volume profile) since the start of the current London trading session.


Thank you very much in advance!
Iulian


 
 Post subject: Re: send text or date and time input argument to indicator Post rating: 0   Post Posted: Thu 06 Dec, 2012, 17:52 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
There is no directly suitable optional input descriptor for passing time values, as time in java is normally represented by the long datatype. Of course you could pass a string and then parse it by using SimpleDataFormat.parse, but that would be rather tedious and error-prone. Are you sure you want to pass a precise time value instead of trading session name? Say, you could make a list of trading sessions in the means of an optional input of type IntegerListDescription.


 
The Best Answer  Post subject: Re: send text or date and time input argument to indicator Post rating: 1   Post Posted: Thu 06 Dec, 2012, 18:32 

User rating: 1
Joined: Sun 22 Jul, 2012, 13:35
Posts: 40
viewtopic.php?f=65&t=47877

for example:
optInputParameterInfos = new OptInputParameterInfo[] {
                new OptInputParameterInfo("Start bar (year)",   OptInputParameterInfo.Type.OTHER,   new IntegerRangeDescription(year, 2000, 2012, 1)),
                new OptInputParameterInfo("Start bar (month)",  OptInputParameterInfo.Type.OTHER,   new IntegerRangeDescription(month, 1, 12, 1)),
                new OptInputParameterInfo("Start bar (day)",    OptInputParameterInfo.Type.OTHER,   new IntegerRangeDescription(day, 1, 31, 1)),
                new OptInputParameterInfo("Start bar (hour)",   OptInputParameterInfo.Type.OTHER,   new IntegerRangeDescription(hour, 0, 23, 1)),
                new OptInputParameterInfo("Start bar (minute)", OptInputParameterInfo.Type.OTHER,   new IntegerRangeDescription(minute, 0, 59, 1))
 };

try {
            DateFormat df = new SimpleDateFormat("dd.MM.yyyy H:mm"){{
                setTimeZone(TimeZone.getTimeZone("GMT"));
            }};
            startBarTime = df.parse(day+"."+month+"."+year+" "+hour+":"+minute).getTime();
            startBarTime = history.getBarStart(fd.getPeriod(), startBarTime);

        } catch (ParseException e) {
            e.printStackTrace();
        }


 
 Post subject: Re: send text or date and time input argument to indicator Post rating: 0   Post Posted: Fri 07 Dec, 2012, 15:20 
User avatar

User rating: 1
Joined: Wed 06 Jul, 2011, 23:12
Posts: 42
Location: Romania, Bucharest
Thank you both for your answers!
They are very usefull!

Iulian


 

Jump to:  

  © 1998-2025 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