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.

Call of Ichimoku Indicator from Indicator
 Post subject: Call of Ichimoku Indicator from Indicator Post rating: 0   New post Posted: Wed 10 Nov, 2010, 01:04 

User rating: 0
Joined: Wed 10 Nov, 2010, 00:56
Posts: 16
Hi,

i'm trying to call the ichimoku indicator from a custom indicator. What i want to do is extract the TenkanSen return value and display that in the Chart.

private IIndicator ichimoku;
private double[][][] inputs = new double[1][][];
private double[][] outputs = new double[1][];

...

inputParameterInfos = new InputParameterInfo[]{new InputParameterInfo("Price", InputParameterInfo.Type.PRICE)};

...

ichimoku = context.getIndicatorsProvider().getIndicator("ICHIMOKU");
ichimoku.setInputParameter(0,inputs[0]);
ichimoku.setOptInputParameter(0,9);
ichimoku.setOptInputParameter(1,26);
ichimoku.setOptInputParameter(2,52);

ichimoku.setOutputParameter(0,output[0]);

IndicatorResult ichi_result= ichimoku.calculate(startIndex, endIndex);


The ichi_result.getNumberOfElements() is empty.

1) What am i doing wrong here?
2) How can i specify the time period on which i want to calculate the ichimoku ts value from?
3) Is there an equivalent in jForex to the MQL iBarShift function? E.g. for #2 i want to calculate which M5 bar the current M1 bar some random m1 bar belongs to so that i can draw the M5 TenkanSen line on my M1 chart.

Thanks a lot for any help. It is very much appriciated.


 
 Post subject: Re: Call of Ichimoku Indicator from Indicator Post rating: 0   New post Posted: Fri 19 Nov, 2010, 15:44 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,

1) The function getNumberOfElements() returns nothing because you need to set output parameters for the Ichimoku indicator:
        ichimoku.setOutputParameter(0, new double[endIndex + 1]);
        ichimoku.setOutputParameter(1, new double[endIndex + 1]);
        ichimoku.setOutputParameter(2, new double[endIndex + 1]);
        ichimoku.setOutputParameter(3, new double[endIndex + 1]);
        ichimoku.setOutputParameter(4, new double[endIndex + 1]);
        ichimoku.setOutputParameter(5 , new Object[endIndex + 1]);


2) To add time period parameters to the form, please create a structure for the periods and add it to the OptInputParameterInfo array the as Period parameter:
        int[] periodValues = new int[10];
        String[] periodNames = new String[10];
        periodValues[0] = 0;
        periodNames[0] = Period.ONE_MIN.name();
        periodValues[1] = 1;
        periodNames[1] = Period.FIVE_MINS.name();
        periodValues[2] = 2;
        periodNames[2] = Period.TEN_MINS.name();
        periodValues[3] = 3;
        periodNames[3] = Period.FIFTEEN_MINS.name();
        periodValues[4] = 4;
        periodNames[4] = Period.THIRTY_MINS.name();
        periodValues[5] = 5;
        periodNames[5] = Period.ONE_HOUR.name();
        periodValues[6] = 6;
        periodNames[6] = Period.FOUR_HOURS.name();
        periodValues[7] = 7;
        periodNames[7] = Period.DAILY.name();
        periodValues[8] = 8;
        periodNames[8] = Period.WEEKLY.name();
        periodValues[9] = 9;
        periodNames[9] = Period.MONTHLY.name();

        optInputParameterInfos = new OptInputParameterInfo[] {new OptInputParameterInfo("Period", OptInputParameterInfo.Type.OTHER, new IntegerListDescription(7, periodValues, periodNames))};



3) You can use IHistory.getBars methods to get bars by the the specified period.


 
 Post subject: Re: Call of Ichimoku Indicator from Indicator Post rating: 0   New post Posted: Sat 20 Nov, 2010, 15:39 

User rating: 0
Joined: Wed 10 Nov, 2010, 00:56
Posts: 16
Thanks a lot. Two questions:

1) The ichimoku sources treats the first optinput parameter as the tenkan value. How does it work to just pass a period to it?
2) I though IHistory is not available in Indicators.

Thanks


 
 Post subject: Re: Call of Ichimoku Indicator from Indicator Post rating: 0   New post Posted: Mon 22 Nov, 2010, 16:29 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
1. If you want to pass period to the Ichimoku indicator from your custom indicator you should create an input parameter with a predefined Period:

        
        inputParameterInfos = new InputParameterInfo[] {
                        new InputParameterInfo("Input data", InputParameterInfo.Type.PRICE){{
                 setPeriod(Period.ONE_HOUR);
                };
        }};
        ichimoku.setInputParameter(0,inputs[0]);      

2. Yes, you are right, there is no way to access historical data from an indicator. For these purposes please use the IHistory interface methods in your strategy.


 

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