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.

Range bar on feed an printing crossover to console.
 Post subject: Range bar on feed an printing crossover to console. Post rating: 0   New post Posted: Sat 05 May, 2012, 22:35 

User rating: 0
Joined: Sun 22 Apr, 2012, 19:19
Posts: 54
Location: United KingdomUnited Kingdom
Hello Support

Can anyone assist me in with manipulating arrays and range bar on feed. I refer to this post in bug reports.

viewtopic.php?f=16&t=47108&p=63504&hilit=range+bar+on+feed#p63504

I am looking at macdemaonfeed2.java in the above post and would like assistance in manipulating arrays. In particular, can someone help me on how to program en ema/macd cross and print to console?

Thanks

Tin


 
 Post subject: Re: Range bar on feed an printing crossover to console. Post rating: 0   New post Posted: Tue 15 May, 2012, 08:00 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See the following strategy to see how to detect cross of indicator lines:
https://www.dukascopy.com/wiki/#SMA_Crossover


 
 Post subject: Re: Range bar on feed an printing crossover to console. Post rating: 0   New post Posted: Tue 15 May, 2012, 13:05 

User rating: 0
Joined: Sun 22 Apr, 2012, 19:19
Posts: 54
Location: United KingdomUnited Kingdom
Thanks

history.getBar requires period. Can you pls let me know how I implement this for range bar?

Thanks

T


 
 Post subject: Re: Range bar on feed an printing crossover to console. Post rating: 0   New post Posted: Tue 15 May, 2012, 13:23 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
How would you expect EMA and MACD to cross if one is drawn on chart and the other - on a separate panel?


 
 Post subject: Re: Range bar on feed an printing crossover to console. Post rating: 0   New post Posted: Tue 15 May, 2012, 18:13 

User rating: 0
Joined: Sun 22 Apr, 2012, 19:19
Posts: 54
Location: United KingdomUnited Kingdom
Sorry - I was not clear

I want to report when 2 emas cross and a macd cross separately.

T


 
 Post subject: Re: Range bar on feed an printing crossover to console. Post rating: 0   New post Posted: Wed 16 May, 2012, 09:30 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Since you basically need the same functionality for multiple line crosses, consider introducing an enum which does the job
    enum Cross {
        noCross,
        firstOvertakeScnd,
        scndOvertakeFirst;         
       
        public static Cross getCross(double firstOld, double firstNew, double scndOld, double scndNew){
            if(firstOld < scndOld && firstNew > scndNew){
                return firstOvertakeScnd;
            }
            if(scndOld < firstOld && scndNew > firstNew){
                return scndOvertakeFirst;
            }
           
            return noCross;
        }
        public String getCrossInfo (String firstLineName, String scndLineName){
            if(this == firstOvertakeScnd){
                return String.format("%s OVERTOOK %s", firstLineName, scndLineName);
            }
            if(this == scndOvertakeFirst){
                return String.format("%s OVERTOOK %s", scndLineName, firstLineName);
            }
            return String.format("%s did not cross %s", firstLineName, scndLineName);
        }
    }
And then you just call it on multiple result arrays:
 // calculate crosses 
int last = rangeBarCount - 1;
int prev = last - 1;
Cross macdCross = Cross.getCross(macd[MACD][prev], macd[MACD][last], macd[MACD_SIGNAL][prev], macd[MACD_SIGNAL][last]);
Cross emaCross = Cross.getCross(emaFast[prev], emaFast[last], emaSlow[prev], emaSlow[last]);
print("___Cross info: %s; %s",
    macdCross.getCrossInfo("macd", "macd signal"),
    emaCross.getCrossInfo("ema fast", "ema slow"));


Attachments:
MacdEmaOnFeedCross.java [8.9 KiB]
Downloaded 365 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Range bar on feed an printing crossover to console. Post rating: 0   New post Posted: Wed 16 May, 2012, 19:37 

User rating: 0
Joined: Sun 22 Apr, 2012, 19:19
Posts: 54
Location: United KingdomUnited Kingdom
Thanks very much - I will look through, test.

Best
T


 

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