|
AddIndicator() for Custom Indicator |
adamwest66
|
Post subject: AddIndicator() for Custom Indicator |
Post rating: 0
|
Posted: Sun 29 Jul, 2012, 14:51
|
|
User rating: 0
Joined: Sun 29 Jul, 2012, 14:43 Posts: 6
|
Hi, I use eclipse for my main programming, and test using both ITesterUserInterface and the JForex standalone gui. I want to programatically add my custom indicator to the chart - so it loads on startup in both modes. I make the call: context.getIndicators().registerCustomIndicator(MyIndicator.class); IIndicator myCustom = context.getIndicators().getIndicator("MYIND1"); chart.addIndicator(myCustom, new Object[]{4}); However, this fails miserably on the call to addIndicator() with: SEVERE: java.lang.NullPointerException com.dukascopy.api.JFException: java.lang.NullPointerException at strategy.MyStrategy.onStart(MyStrategy.java:44) at com.dukascopy.dds2.greed.agent.strategy.tester.StrategyRunner.run(StrategyRunner.java:428) at java.lang.Thread.run(Thread.java:680) Caused by: java.lang.NullPointerException at com.dukascopy.charts.math.indicators.IndicatorsProvider.getSavedIndicatorContext(IndicatorsProvider.java:417) at com.dukascopy.charts.chartbuilder.IChartWrapper.addIndicator(IChartWrapper.java:360) at com.dukascopy.charts.chartbuilder.IChartWrapper.addIndicator(IChartWrapper.java:339) at com.dukascopy.charts.wrapper.DelegatableChartWrapper.addIndicator(DelegatableChartWrapper.java:65)
It works fine if I use an out of the box indicator - such as "ATR". Can someone tell me what I am doing wrong? Note: I have seen the post "How to use the registerCustomIndicator() method?" by Paolo, but this does not work for me. Thanks
|
|
|
|
|
adamwest66
|
Post subject: Re: AddIndicator() for Custom Indicator |
Post rating: 0
|
Posted: Thu 02 Aug, 2012, 08:18
|
|
User rating: 0
Joined: Sun 29 Jul, 2012, 14:43 Posts: 6
|
|
|
|
|
API Support
|
Post subject: Re: AddIndicator() for Custom Indicator |
Post rating: 0
|
Posted: Thu 02 Aug, 2012, 08:32
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Please check that the indicator name is correct, you can fetch it from the registering method, i.e.: String indName = context.getIndicators().registerCustomIndicator(MyIndicator.class); console.getOut().println("Indicator name: " + indName ); IIndicator myCustom = context.getIndicators().getIndicator(indName); chart.addIndicator(myCustom, new Object[]{4}); If you still don't manage this, please provide full strategy example, the indicator and the standalone program.
|
|
|
|
|
adamwest66
|
Post subject: Re: AddIndicator() for Custom Indicator |
Post rating: 0
|
Posted: Thu 02 Aug, 2012, 21:15
|
|
User rating: 0
Joined: Sun 29 Jul, 2012, 14:43 Posts: 6
|
Hi, Many thanks for your reply. I did initially try that without any luck. As requested I've attached 3 files: - The main program (as provided by the standard eclipse Maven download)
- The indicator I am using (this was auto generated from the JForex gui - right-click on Custom Indcators->New Indicator)
- A very simple strategy class which has the lines of code in my previous example pasted into the onStart() method.
For the example indicator I've attached, I've also tried moving the initialisation of the state from the indicator.onStart() method to the top level of the class - this didnt work. The attached strategy/indicator code does however work when I register the indicator using the .jfx compiled version and add the indicatorName to the chart in the same way. File compiledCustomIndcatorFile = new File("/Users/primary/Documents/eclipse/TestProject/src/main/java/mypackage/SimpleIndicator.jfx"); String indicatorName = context.getIndicators().registerCustomIndicator(compiledCustomIndcatorFile);
Thanks
Attachments: |
File comment: Main Program
TesterMainGUIMode.java [11.84 KiB]
Downloaded 355 times
|
File comment: Basic Strategy
SimpleStrategy.java [1.02 KiB]
Downloaded 359 times
|
File comment: Example Indicator
SimpleIndicator.java [2.82 KiB]
Downloaded 343 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.
|
|
|
|
|
|
API Support
|
Post subject: Re: AddIndicator() for Custom Indicator |
Post rating: 0
|
Posted: Fri 03 Aug, 2012, 08:36
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Your variant of TesterMainGUIMode did not open a chart, please try the following variant: Attachment:
TesterMainGUIMode2.java [11.97 KiB]
Downloaded 389 times
If it fails, please provide full log.
|
|
|
|
|
adamwest66
|
Post subject: Re: AddIndicator() for Custom Indicator |
Post rating: 0
|
Posted: Sat 04 Aug, 2012, 23:44
|
|
User rating: 0
Joined: Sun 29 Jul, 2012, 14:43 Posts: 6
|
Hi, The main program I am using did not open a chart because the program is crashing before it gets painted. I see the exact same behaviour using the main gui program you have provided. You can also reproduce the issue using the JForex Marketplace JNLP file directly, and using a wrapper strategy to load the standalone program packaged as a jar file. Aug 4, 2012 11:22:34 PM mypackage.TesterMainGUIMode2 startStrategy INFO: Connecting... Aug 4, 2012 11:22:36 PM com.dukascopy.api.impl.connect.AuthorizationClient getRetrievePropsFromResponse INFO: >> [{}]https://www1.dukascopy.com/authorization/demo/auth?typus=0&munus=stngs&appello=DEMO2xxx&licentio=65ebce4a2b1742c92762debb5cec5041f2c6fd74915a1ae05b3b0b4f41a136cf&sermo=f0088522-b86e-4bb5-815c-b32414208b5b&stngs=1
Aug 4, 2012 11:22:36 PM com.dukascopy.api.impl.connect.AuthorizationClient getRetrievePropsFromResponse WARNING: << [{}]{news.host.url=https://external.dukascopy.com, jss.logserver.url=https://demo-login.dukascopy.com/jss-log/, userTypes=REGULAR,MANAGE_STOP_LIMIT,MINI_FX,, wlabel.logo=[B@1ebafdff, news.source=api, contest.chart.url=https://demo-login.dukascopy.com/aDDS/export/contestChart.php, menu.item.dayly.hl=/marketwatch/daily_hl_interbank/, menu.item.margin.level.calculator=/marketwatch/forexcalc/margin_level/, wlabel.shortLabel=Dukascopy Bank, encryptionKey=0182DDEE73BCBB5235AF5FD3AFD5071E, reports.url=/Reports, base.calendar.url=https://www.dukascopy.com/swiss/{0}, menu.item.economic.calendar=/marketwatch/calendars/eccalendar/, additionalUserTypes=[], feed.commission.history=[], brokerChat.url=https://www.dukascopy.com/chat/login.php?channel=3, wlabel.url=https://www.dukascopy.com, platformFaq.url=https://www.dukascopy.com/swiss/english/forex/faq/, menu.item.holidays.calendar=/marketwatch/calendars/NationalHolidaysCalendar/, menu.item.report.issue=/about/issues/, reports=portfolio_client,intraday_client,position_client, annual_report,deposit_receipt,trader_sll,self_traded_volume,activity_log,merge_log,trade_log,trader_sll_action_log,security_settings, tradelog_sfx.url=/aDDS/export/tradeLog.php, platformManual.url=https://www.dukascopy.com/wiki/, instruments=[CAD/HKD, EUR/SGD, EUR/NOK, EUR/NZD, AUD/NZD, USD/TRY, GBP/USD, NZD/CHF, USD/MXN, USD/HKD, SGD/JPY, EUR/HKD, AUD/CAD, USD/PLN, EUR/PLN, USD/NOK, USD/CHF, GBP/CHF, EUR/CHF, USD/JPY, GBP/CAD, HKD/JPY, GBP/JPY, EUR/CAD, USD/SEK, CHF/SGD, USD/DKK, EUR/SEK, NZD/JPY, AUD/SGD, NZD/USD, CAD/JPY, EUR/GBP, CHF/JPY, XAG/USD, GBP/AUD, AUD/JPY, XAU/USD, EUR/USD, AUD/USD, USD/CAD, USD/ZAR, EUR/JPY, USD/SGD, AUD/CHF, GBP/NZD, USD/RUB, NZD/CAD, CAD/CHF, EUR/AUD, EUR/DKK, EUR/TRY], menu.item.forex.calculator=/marketwatch/forexcalc/forex_calculator/, debug=false, client.mode=DEMO, loginId=423181, get.help.url=https://www.dukascopy.com/swiss/english/forex/jforex/forum/, menu.item.interest.rates.calendar=/marketwatch/calendars/InterestRatesCalendar/, wlabel.foUrl=https://demo-login.dukascopy.com, history.server.url=https://www.dukascopy.com/datafeed/, external_ip=87.194.77.227, wlabel.longLabel=Dukascopy Bank SA, services1.url=https://demo-login.dukascopy.com, wlabel.skype=dukascopy, wlabel.phone=+41 (0) 22 799 4888}
Aug 4, 2012 11:22:37 PM com.dukascopy.api.impl.connect.TesterClientImpl$2 authorized INFO: Authorized Aug 4, 2012 11:22:37 PM mypackage.TesterMainGUIMode2$1 onConnect INFO: Connected Aug 4, 2012 11:22:37 PM mypackage.TesterMainGUIMode2 startStrategy INFO: Subscribing instruments... Aug 4, 2012 11:22:37 PM mypackage.TesterMainGUIMode2 startStrategy INFO: Downloading data Aug 4, 2012 11:22:39 PM com.dukascopy.charts.data.datacache.LocalCacheManager readData WARNING: Some or all of the requested data was not found, instrument [EUR/USD], period [Ticks], side [null], chunk from [2012.08.03 23:00:00 000], chunk to [2012.08.04 00:00:00 000] Aug 4, 2012 11:22:39 PM mypackage.TesterMainGUIMode2 startStrategy INFO: Starting strategy Aug 4, 2012 11:22:39 PM mypackage.TesterMainGUIMode2$1 onStart INFO: Strategy started: 1 Aug 4, 2012 11:22:39 PM mypackage.TesterMainGUIMode2$2 dataLoaded INFO: Getting prices before start time Aug 4, 2012 11:22:39 PM mypackage.TesterMainGUIMode2$2 dataLoaded INFO: Creating data loading threads Aug 4, 2012 11:22:39 PM mypackage.TesterMainGUIMode2$2 dataLoaded INFO: Getting prices before start time Aug 4, 2012 11:22:40 PM mypackage.TesterMainGUIMode2$2 dataLoaded INFO: Filling in-progress candles Aug 4, 2012 11:22:40 PM mypackage.TesterMainGUIMode2$2 dataLoaded INFO: Executing onStart Registered: EXAMPIND
Aug 4, 2012 11:22:40 PM com.dukascopy.dds2.greed.agent.strategy.tester.StrategyRunner handleException SEVERE: null java.lang.NullPointerException at com.dukascopy.charts.math.indicators.IndicatorsProvider.getSavedIndicatorContext(IndicatorsProvider.java:417) at com.dukascopy.charts.chartbuilder.IChartWrapper.addIndicator(IChartWrapper.java:360) at com.dukascopy.charts.chartbuilder.IChartWrapper.addIndicator(IChartWrapper.java:339) at com.dukascopy.charts.wrapper.DelegatableChartWrapper.addIndicator(DelegatableChartWrapper.java:65) at mypackage.SimpleStrategy.onStart(SimpleStrategy.java:18) at com.dukascopy.dds2.greed.agent.strategy.tester.StrategyRunner.run(StrategyRunner.java:428) at java.lang.Thread.run(Thread.java:680) Strategy tester: java.lang.NullPointerException @ mypackage.SimpleStrategy.onStart(SimpleStrategy.java:18) null: java.lang.NullPointerException at com.dukascopy.charts.math.indicators.IndicatorsProvider.getSavedIndicatorContext(IndicatorsProvider.java:417) at com.dukascopy.charts.chartbuilder.IChartWrapper.addIndicator(IChartWrapper.java:360) at com.dukascopy.charts.chartbuilder.IChartWrapper.addIndicator(IChartWrapper.java:339) at com.dukascopy.charts.wrapper.DelegatableChartWrapper.addIndicator(DelegatableChartWrapper.java:65) at mypackage.SimpleStrategy.onStart(SimpleStrategy.java:18) at com.dukascopy.dds2.greed.agent.strategy.tester.StrategyRunner.run(StrategyRunner.java:428) at java.lang.Thread.run(Thread.java:680) Aug 4, 2012 11:22:40 PM com.dukascopy.api.impl.connect.TesterClientImpl$DefaultStrategyExceptionHandler onException SEVERE: Exception thrown while running onStart method: null java.lang.NullPointerException at com.dukascopy.charts.math.indicators.IndicatorsProvider.getSavedIndicatorContext(IndicatorsProvider.java:417) at com.dukascopy.charts.chartbuilder.IChartWrapper.addIndicator(IChartWrapper.java:360) at com.dukascopy.charts.chartbuilder.IChartWrapper.addIndicator(IChartWrapper.java:339) at com.dukascopy.charts.wrapper.DelegatableChartWrapper.addIndicator(DelegatableChartWrapper.java:65) at mypackage.SimpleStrategy.onStart(SimpleStrategy.java:18) at com.dukascopy.dds2.greed.agent.strategy.tester.StrategyRunner.run(StrategyRunner.java:428) at java.lang.Thread.run(Thread.java:680) Aug 4, 2012 11:22:40 PM com.dukascopy.api.impl.connect.TesterClientImpl$TesterLoadingProgressListener loadingFinished SEVERE: null java.lang.NullPointerException at com.dukascopy.charts.math.indicators.IndicatorsProvider.getSavedIndicatorContext(IndicatorsProvider.java:417) at com.dukascopy.charts.chartbuilder.IChartWrapper.addIndicator(IChartWrapper.java:360) at com.dukascopy.charts.chartbuilder.IChartWrapper.addIndicator(IChartWrapper.java:339) at com.dukascopy.charts.wrapper.DelegatableChartWrapper.addIndicator(DelegatableChartWrapper.java:65) at mypackage.SimpleStrategy.onStart(SimpleStrategy.java:18) at com.dukascopy.dds2.greed.agent.strategy.tester.StrategyRunner.run(StrategyRunner.java:428) at java.lang.Thread.run(Thread.java:680) Aug 4, 2012 11:22:40 PM mypackage.TesterMainGUIMode2$1 onStop INFO: Strategy stopped: 1
|
|
|
|
|
API Support
|
Post subject: Re: AddIndicator() for Custom Indicator |
Post rating: 0
|
Posted: Mon 06 Aug, 2012, 09:19
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
The issue will be fixed with JForex-API 2.6.73
|
|
|
|
|
adamwest66
|
Post subject: Re: AddIndicator() for Custom Indicator |
Post rating: 0
|
Posted: Fri 10 Aug, 2012, 08:07
|
|
User rating: 0
Joined: Sun 29 Jul, 2012, 14:43 Posts: 6
|
Hi,
Can you tell me when the patch will be released? Do you have a release forecast-schedule published somewhere?
Thanks Adam
|
|
|
|
|
|
Pages: [
1
]
|
|
|
|
|