Dukascopy
 
 
Wiki JStore Search Login

Chart Pattern usage on strategy test chart and with indicators
 Post subject: Chart Pattern usage on strategy test chart and with indicators Post rating: 0   New post Posted: Tue 29 Oct, 2019, 01:23 

User rating: 0
Joined: Mon 18 Mar, 2019, 15:06
Posts: 4
Location: AustraliaAustralia
I want to use patterns (triangles, wedges) on test charts and within a strategy. Are there any examples that show how this can be done? I am finding the data returned very confusing.

As background, I am using this code to add a triangle pattern to a chart within a back test:

   @Override
   public void onStart(IContext context) throws JFException
   {
      super.onStart(context);

      IIndicator indicator = indicators.getIndicator("TRIANGLE");
      indicator.getInputParameterInfo(0).setAppliedPrice(IIndicators.AppliedPrice.CLOSE);
      indicator.setOptInputParameter(0, 1);
      indicator.setOptInputParameter(1, 50.0);
      indicator.setOptInputParameter(2, 1);
      indicator.setOptInputParameter(3, true);

                context.getChart(instrument).add(indicator,
              new Object[] { 1, 50.0, 1, true },
              new Color[] { Color.black, Color.black },
              new DrawingStyle[] { DrawingStyle.LINE, DrawingStyle.LINE },
              new int[] { 2, 2 } );


I have added the OhlcInformer to the chart, but the data displayed for the pattern is rather weird (as shown here):

Image

When calculating the triangle pattern, I use the following code:

                private static AppliedPrice[] inputTypes = new AppliedPrice[] { AppliedPrice.CLOSE };
                private static Object[] optionalParameters = new Object[] { 1, 50.0 };
                .....
      Object[] values = indicators.calculateIndicator(instrument, period, offerSides, "TRIANGLE", inputTypes, optionalParameters, 1);


There are three objects in the returned values array. Each item in the array is a PatternIndicatorOutput object which contains null. This doesn't change for any bar on the chart in or around the displayed pattern that I hover over. I'm not sure what should be displayed and how to use the data that is returned.

Any help would be appreciated.


Attachments:
2019-10-29_10-17-40.jpg [158.93 KiB]
Downloaded 30 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: Chart Pattern usage on strategy test chart and with indicators Post rating: 0   New post Posted: Tue 03 Dec, 2019, 14:54 
User avatar

User rating: 1
Joined: Wed 09 Oct, 2019, 16:17
Posts: 6
Location: United StatesUnited States
Thanks for sharing it with us.


 

Jump to:  

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