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.

pivot indicator NullPointerException
 Post subject: pivot indicator NullPointerException Post rating: 0   New post Posted: Fri 17 Feb, 2012, 14:04 

User rating: -
I use in my strategy in demo account in onBar method this code:

double[] pivot = indicators.pivot( instrument, Period.DAILY_SUNDAY_IN_MONDAY, OfferSide.ASK, 7, 1 );

and I always receive NullPointerException. What is wrong?

Thanks very much.


 
 Post subject: Re: pivot indicator NullPointerException Post rating: 0   New post Posted: Thu 23 Feb, 2012, 15:49 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Try the following example strategy:
package jforex.test;

import com.dukascopy.api.*;
import com.dukascopy.api.indicators.IIndicator;

public class TestPivotSmall implements IStrategy {

    private IConsole console;
    private IIndicators indicators;
    public Instrument instrument = Instrument.EURUSD;

    public void onStart(IContext context) throws JFException {
        this.console = context.getConsole();
        this.indicators = context.getIndicators();

        //calculate indicator
        double[] pivot = indicators.fibPivot(Instrument.EURUSD, Period.DAILY_SUNDAY_IN_MONDAY, OfferSide.BID, 7, 1);
       
        //retrieve indicator metadata
        IIndicator pivotInd = indicators.getIndicator("PIVOT");
        int outputCount = pivotInd.getIndicatorInfo().getNumberOfOutputs();
       
        print("Pivot indicator outputs: ");
        for(int i = 0; i < outputCount - 1; i++){
            String outputName = pivotInd.getOutputParameterInfo(i).getName();
            print(String.format("%s=%.5f", outputName, pivot[i]));
        }
       
    }

    private void print(Object message) {
        console.getOut().println(message);
    }
    public void onAccount(IAccount account) throws JFException {    }
    public void onMessage(IMessage message) throws JFException {    }
    public void onStop() throws JFException {    }
    public void onTick(Instrument instrument, ITick tick) throws JFException {    }
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {    }
}


Attachments:
TestPivotSmall.java [1.49 KiB]
Downloaded 282 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: pivot indicator NullPointerException Post rating: 0   New post Posted: Mon 27 Feb, 2012, 22:52 

User rating: 1
Joined: Mon 27 Feb, 2012, 22:49
Posts: 119
Location: Czech Republic,
Thanks. I tried it and it works. But there is a fibPivot indicator. If I set pivot indicator, I received ArrayIndexOutOfBoundsException: 1. But I did my own pivot calculation.


 
 Post subject: Re: pivot indicator NullPointerException Post rating: 0   New post Posted: Wed 29 Feb, 2012, 17:00 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
see:
https://www.dukascopy.eu/swiss/english/f ... 65&t=43589


 
 Post subject: Re: pivot indicator NullPointerException Post rating: 0   New post Posted: Wed 29 Feb, 2012, 22:50 

User rating: 1
Joined: Mon 27 Feb, 2012, 22:49
Posts: 119
Location: Czech Republic,
There is bad arguments error. But indicator is already now not important for me. I did my own calculation of pivot. Thanks


 

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