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.

How can I dispatch an event from my custom indicator?
 Post subject: How can I dispatch an event from my custom indicator? Post rating: 0   New post Posted: Wed 22 Jul, 2020, 15:19 

User rating: 0
Joined: Fri 17 Jul, 2020, 09:10
Posts: 5
Location: United Arab Emirates, Dubai
Hi
I have an almost heavy-calculation indicator that i want to use it in a strategy. for my indicator starting candle is important so in my strategy OnBar event, every time i have to recalculate from the beginning of given period.
I also add my indicator to chart at OnStart, but that wouldn't give me indicator results(
chart.add(x)
).
So I wonder is it possible to fire an event from my indicator and handle that event from my strategy once I add my indicator to the chart?


 
 Post subject: Re: How can I dispatch an event from my custom indicator? Post rating: 1   New post Posted: Thu 23 Jul, 2020, 10:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Greetings.

Strategy can wait until indicator values will be calculated after adding indicator to chart.
The example is in the strategy attached AddIndicatorToChart.java.

Regards.


Attachments:
AddIndicatorToChart.java [1.93 KiB]
Downloaded 148 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: How can I dispatch an event from my custom indicator? Post rating: 0   New post Posted: Thu 23 Jul, 2020, 15:22 

User rating: 0
Joined: Fri 17 Jul, 2020, 09:10
Posts: 5
Location: United Arab Emirates, Dubai
Thanks for reply.
But does this way works for running strategy on live streaming data?
I mean onStart method would be called once at the begining, right? so as new candles come in, calculate method of the used indicator won't get called for new data, i guess.


 
 Post subject: Re: How can I dispatch an event from my custom indicator? Post rating: 0   New post Posted: Wed 09 Sep, 2020, 10:08 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Indicator on chart will be recalculated when new candle come in.
Strategy can wait until value for new candle will be available in onBar() method by analogy with code in onStart() - see previous example AddIndicatorToChart.java
Also, strategy can calculate indicator synchronously by calling one of IIndicators.calculateIndicator() methods.


 

Jump to:  

cron
  © 1998-2024 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