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 to programmatically add a level for an indicator that is used in a strategy?
 Post subject: How to programmatically add a level for an indicator that is used in a strategy? Post rating: 0   New post Posted: Mon 07 Sep, 2015, 16:10 
User avatar

User rating: 2
Joined: Wed 29 Jan, 2014, 10:18
Posts: 30
Location: Austria,
Hi

How to add a level for an indicator that is used in a strategy?

@Override
 public void onStart(IContext context) throws JFException {
        this.console = context.getConsole();     
        this.engine = context.getEngine();
        this.history = context.getHistory();
        this.indicators = context.getIndicators();
        this.context = context;

       IIndicator adx = indicators.getIndicator("ADX");
       adx.getOutputParameterInfo(0).setLineWidth(2);   // set line width

       // Now, how to add a level 20 to ADX indicator?

       chart.add(adx, new Object[] {adxPeriod} );

     
      ................
}



Thanks for your help


 
 Post subject: Re: How to programmatically add a level for an indicator that is used in a strategy? Post rating: 0   New post Posted: Fri 11 Sep, 2015, 09:51 
User avatar

User rating: 2
Joined: Wed 29 Jan, 2014, 10:18
Posts: 30
Location: Austria,
Any code example how to do this?

Thanks


 
 Post subject: Re: How to programmatically add a level for an indicator that is used in a strategy? Post rating: 0   New post Posted: Wed 16 Sep, 2015, 10:06 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
There is no access to indicator levels from API, but you can add on chart price marker instead:
IChart chart = context.getChart(Instrument.EURUSD);
IIndicator adx = indicators.getIndicator("ADX");
adx.getOutputParameterInfo(0).setLineWidth(2);
IChartPanel adxPanel = chart.add(adx, new Object[] {14});
IChartObjectFactory factory = chart.getChartObjectFactory();
IPriceMarkerChartObject marker = factory.createPriceMarker();
marker.setPrice(0, 20.0);
marker.setLineStyle(LineStyle.DASH);
marker.setDecoration(IDecoratedChartObject.Placement.Beginning, IDecoratedChartObject.Decoration.None);
marker.setDecoration(IDecoratedChartObject.Placement.End, IDecoratedChartObject.Decoration.None);
adxPanel.add(marker);


 

Jump to:  

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