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.

Bar start times
 Post subject: Bar start times Post rating: 0   New post Posted: Fri 19 Aug, 2011, 20:33 

User rating: 0
Joined: Fri 19 Aug, 2011, 20:29
Posts: 45
Location: Germany,
Hi,

when using multi currency indicators like

viewtopic.php?f=6&t=27949

does one have to search for the correct bar times in each currency or are they the same?

e.g.

is bar index 0 of eurusd always the same as index 0 in gbpusd or is it sometimes possible that another instrument has not yet opened a new bar
and indices are screwed by 1? That is the case in Metatrader e.g. the latest m1 eurusd bar is shorty after open not necessarily the same as the latest in gbpusd since that might still have to create a new bar in the pricefeed.

Thanks
yoursong


 
 Post subject: Re: Bar start times Post rating: 0   New post Posted: Mon 22 Aug, 2011, 09:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
yoursong wrote:
is bar index 0 of eurusd always the same as index 0 in gbpusd or is it sometimes possible that another instrument has not yet opened a new bar and indices are screwed by 1?
For all subscribed and tradable instruments the bars get formed and fed to the indicator at the same execution block, meaning that a bar of one instrument can't independently "arrive" earlier or later than bars of other instruments.


 
 Post subject: Re: Bar start times Post rating: 0   New post Posted: Mon 22 Aug, 2011, 12:38 

User rating: 0
Joined: Fri 19 Aug, 2011, 20:29
Posts: 45
Location: Germany,
Thanks. That is nice.

So when i feed multiple instruments into an indicator via the inputparams i only have to take care of the fact
that not all might have the same number of bars avaible?

e.g. i fed eurusd, gbpusd, usdjpy in on M1 eurusd chart. Sometimes all 3 get 4000 bars, a lot of times though only eurusd (chart instrument) gets 4000 bars and the others only 2000-3000 which means some bars a bit back are not available for calculation.

How do i handle such situations?

Thanks


 
 Post subject: Re: Bar start times Post rating: 0   New post Posted: Tue 23 Aug, 2011, 09:17 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
yoursong wrote:
So when i feed multiple instruments into an indicator via the inputparams i only have to take care of the fact
that not all might have the same number of bars avaible? How do i handle such situations?
You don't need to handle them in any special way. You can consider these inputs as signals from which the indicator takes the part which is necessary for calculations and ignores the rest.
If you need more than the last bar for the calculations, consider changing the getLookback() value to set the minimum amount of bars that the indicator will receive as inputs.


 
 Post subject: Re: Bar start times Post rating: 0   New post Posted: Tue 23 Aug, 2011, 12:26 

User rating: 0
Joined: Wed 08 Jun, 2011, 10:19
Posts: 29
Location: North Pole
yoursong wrote:
e.g. i fed eurusd, gbpusd, usdjpy in on M1 eurusd chart. Sometimes all 3 get 4000 bars, a lot of times though only eurusd (chart instrument) gets 4000 bars and the others only 2000-3000 which means some bars a bit back are not available for calculation.
How do i handle such situations?
I'm in this situation, use something like this
                int minInputLen =  input[0].length; // Instr1 on Chart
                minInputLen =  Math.min(inputs[1][0].length, minInputLen); // Instr2
                minInputLen =  Math.min(inputs[2][0].length, minInputLen); // Instr3

                int delta   =  input[0].length - minInputLen;
                if ((delta>0) && (delta + getLookback() < startIndex)) {
                    return new IndicatorResult(0, 0);
                }

                int delta1 =  input[0].length - inputs[1][0].length;
                int delta2 =  input[0].length - inputs[2][0].length;

                for (int i = (delta>=0 ? delta : 0); i < input[0].length; i++) {
                    double p1 = inputs[1][0][i - delta1];
                    double p2 = inputs[2][0][i - delta2];
                }


 

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