Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Pivot drawing exception
 Post subject: Pivot drawing exception Post rating: 0   New post Posted: Mon 16 Feb, 2015, 14:08 
User avatar

User rating: 0
Joined: Thu 11 Jul, 2013, 23:03
Posts: 1
Hello,

I was trying to draw pivot without other values and more importantly period separator from within my code.

Please, consider the following strategy :

package jforex;

import java.awt.Color;

import com.dukascopy.api.Configurable;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IChart;
import com.dukascopy.api.IChartObject;
import com.dukascopy.api.IChartPanel;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IEngine;
import com.dukascopy.api.IHistory;
import com.dukascopy.api.IIndicators;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.IUserInterface;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.Period;
import com.dukascopy.api.indicators.IIndicator;
import com.dukascopy.api.indicators.IndicatorInfo;
import com.dukascopy.api.indicators.OutputParameterInfo.DrawingStyle;

public class PivotEx implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
    private IChart chart;
    private IIndicator fourHoursPivot;
   
    @Configurable("Show")
    public boolean showEx = true;
   
    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        this.console = context.getConsole();
        this.history = context.getHistory();
        this.context = context;
        this.indicators = context.getIndicators();
        this.userInterface = context.getUserInterface();
       
        chart = context.getChart(context.getSubscribedInstruments().iterator().next());
       
        fourHoursPivot = indicators.getIndicator("PIVOT");
        fourHoursPivot.setOptInputParameter(0, Period.FOUR_HOURS);
        fourHoursPivot.setOptInputParameter(1, true);
       
        printIndicatorInfos(fourHoursPivot);
       
        if (showEx) {
           chart.add(fourHoursPivot, new Object[] { Period.FOUR_HOURS, true },
                   new Color[]{ Color.GREEN, Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(),
                   Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(),
                   Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.brighter()},
                   new DrawingStyle[] { DrawingStyle.LINE, DrawingStyle.NONE,  DrawingStyle.NONE,  DrawingStyle.NONE,
                   DrawingStyle.NONE,  DrawingStyle.NONE,  DrawingStyle.NONE,  DrawingStyle.NONE,  DrawingStyle.NONE,
                   DrawingStyle.NONE,  DrawingStyle.NONE,  DrawingStyle.NONE,  DrawingStyle.NONE, DrawingStyle.NONE},
                  new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
        } else {
           chart.add(fourHoursPivot, new Object[] { Period.FOUR_HOURS, true },
                   new Color[]{ Color.GREEN, Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(),
                 Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(),
                 Color.GREEN.darker(), Color.GREEN.darker(), Color.GREEN.darker(), Color.BLUE.darker() },
                   new DrawingStyle[] { DrawingStyle.LINE },
                   new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
        }
    }

    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onStop() throws JFException {
       chart.removeIndicator(fourHoursPivot);
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }
   
    private void printIndicatorInfos(IIndicator ind){
        IndicatorInfo info = ind.getIndicatorInfo();
        context.getConsole().getOut().println(String.format("%s: input count=%s, optional input count=%s, output count=%s",
            info.getTitle(), info.getNumberOfInputs(), info.getNumberOfOptionalInputs(), info.getNumberOfOutputs()));
        for (int i = 0; i < ind.getIndicatorInfo().getNumberOfInputs(); i++){
           context.getConsole().getOut().println(String.format("Input %s: %s - %s", i, ind.getInputParameterInfo(i).getName(), ind.getInputParameterInfo(i).getType()));
        }
        for (int i = 0; i < ind.getIndicatorInfo().getNumberOfOptionalInputs(); i++){
           context.getConsole().getOut().println(String.format("Opt Input %s: %s - %s", i, ind.getOptInputParameterInfo(i).getName(), ind.getOptInputParameterInfo(i).getType()));
        }
        for (int i = 0; i < ind.getIndicatorInfo().getNumberOfOutputs(); i++){
           context.getConsole().getOut().println(String.format("Output %s: %s - %s", i, ind.getOutputParameterInfo(i).getName(), ind.getOutputParameterInfo(i).getType()));
        }
    }
}


The exception thrown
Exception in drawOutput method: java.lang.IllegalArgumentException: null Stroke @ com.dukascopy.indicators.PivotIndicator.doDrawOutput(PivotIndicator.java:575)

Thank you


 
 Post subject: Re: Pivot drawing exception Post rating: 0   New post Posted: Fri 27 Feb, 2015, 08:22 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
This will be fixed in the next platform release.


 

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