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.

Why the indicator can not display in ARROW_SYMBOL .....?
 Post subject: Why the indicator can not display in ARROW_SYMBOL .....? Post rating: 0   New post Posted: Sat 27 May, 2017, 13:41 
User avatar

User rating: 0
Joined: Sat 18 Mar, 2017, 05:03
Posts: 26
Location: China,
I am program an indicator, it is Ok when drawing in LINE or HISTROGRAM, but not display when ARROW_SYMBOL_DOWN and UP. What is wrong with is, please help me.

bellow is the source code: ( check the lines near //-----------------------------------------------------)

package com.dukascopy.indicators;
 
import java.awt.Color;
import  com.dukascopy.api.IConsole;
import com.dukascopy.api.IIndicators;
import com.dukascopy.api.indicators.IIndicator;
import com.dukascopy.api.indicators.IIndicatorContext;
import com.dukascopy.api.indicators.IIndicatorsProvider;
import com.dukascopy.api.indicators.IndicatorInfo;
import com.dukascopy.api.indicators.IndicatorResult;
import com.dukascopy.api.indicators.InputParameterInfo;
import com.dukascopy.api.indicators.IntegerListDescription;
import com.dukascopy.api.indicators.IntegerRangeDescription;
import com.dukascopy.api.indicators.LevelInfo;
import com.dukascopy.api.indicators.OptInputParameterInfo;
import com.dukascopy.api.indicators.OutputParameterInfo;
 
public class TryArrowIndicator implements IIndicator { 
    private IIndicatorsProvider indicatorsProvider;
   
 
    private IndicatorInfo indicatorInfo;
    private InputParameterInfo[] inputParameterInfos;
    private OutputParameterInfo[] outputParameterInfos;
    private OptInputParameterInfo[] optInputParameterInfos;
 
    private double[][][] inputs = new double[1][][];
    private double[][] outputs = new double[2][];
 
     
     private IConsole console = null;
    //
    public void onStart(IIndicatorContext context) {
        console = context.getConsole();
        indicatorsProvider = context.getIndicatorsProvider();
       
         
        indicatorInfo = new IndicatorInfo("TryArrow", "TryArrow", "Momentum Indicators", false, false, false, 1, 0, 2);
 
         
        inputParameterInfos = new InputParameterInfo[] {  new InputParameterInfo("Price", InputParameterInfo.Type.PRICE)  };
 
        outputParameterInfos = new OutputParameterInfo[] {
            new OutputParameterInfo("Dn", OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.ARROW_SYMBOL_DOWN), //LINE  HISTROGRAM
            new OutputParameterInfo("Up", OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.ARROW_SYMBOL_UP)
//---------------------------------------------------------------------------------------------------------
  };


        outputParameterInfos[0].setColor(Color.yellow);
        outputParameterInfos[1].setColor(Color.red);
        indicatorInfo.setDefaultLevelsInfo(new LevelInfo[] {
            new LevelInfo("", 20, OutputParameterInfo.DrawingStyle.DASH_LINE, Color.darkGray, 1, 1),
            new LevelInfo("", 80, OutputParameterInfo.DrawingStyle.DASH_LINE, Color.darkGray, 1, 1),
            new LevelInfo("", 40, OutputParameterInfo.DrawingStyle.DASH_LINE, Color.darkGray, 1, 1),
            new LevelInfo("", 60, OutputParameterInfo.DrawingStyle.DASH_LINE, Color.darkGray, 1, 1)
        });
    }
 
    public IndicatorResult calculate(int startIndex, int endIndex) {       
        int startIndexN =startIndex; int endIndexN = endIndex;
      return  calculate3( startIndexN,  endIndexN); 
    } 
   
    public IndicatorResult calculate3(int startIndex, int endIndex) {
        if (startIndex - getLookback3() < 0) {
            startIndex = getLookback3();
        }
        if (startIndex > endIndex) {
            return new IndicatorResult(0, 0);
        }
 
        int maLookback = 0;
        int i, j;
      console.getOut().format( "si=%d , ei=%d ,  mb=%d",startIndex,endIndex,maLookback).println();
        for (i = startIndex - maLookback, j = 0; i <= endIndex; i++, j++) {
           outputs[0][j]=60;
           outputs[1][j]=20;
        //   console.getOut().format( "0 kl=%f ",outputs[0][i]).println();   //debug
        }
      //set array directly with 60, 20
//---------------------------------------------------------------------------------------------------------       
     return new IndicatorResult(startIndex, j, endIndex);   
    }
    //
    public IndicatorInfo getIndicatorInfo() {
        return indicatorInfo;
    }
 
    public InputParameterInfo getInputParameterInfo(int index) {
        if (index < inputParameterInfos.length) {
            return inputParameterInfos[index];
        }
        return null;
    }
 
    public OptInputParameterInfo getOptInputParameterInfo(int index) {
        if (index < optInputParameterInfos.length) {
            return optInputParameterInfos[index];
        }
        return null;
    }
 
    public OutputParameterInfo getOutputParameterInfo(int index) {
        if (index < outputParameterInfos.length) {
            return outputParameterInfos[index];
        }
        return null;
    }
 
    public void setInputParameter(int index, Object array) {
        inputs[index] = (double[][]) array;
    }
 
    public void setOptInputParameter(int index, Object value) {
        switch (index) {
            default:
                throw new ArrayIndexOutOfBoundsException(index);
        }
    }
 
    public void setOutputParameter(int index, Object array) {
        outputs[index] = (double[]) array;
    }
 
    public int getLookback() {
         return  getLookback3();
    }
    public int getLookback2() {
        return  getLookback3();
   }
    public int getLookback3() {
        return 0;
   }
    public int getLookforward() {
        return 0;
    }
}


 
 Post subject: Re: Why the indicator can not display in ARROW_SYMBOL .....? Post rating: 0   New post Posted: Mon 29 May, 2017, 04:32 
User avatar

User rating: 0
Joined: Sat 18 Mar, 2017, 05:03
Posts: 26
Location: China,
On Sub-indicator panel, both on 32 and 64 bits version,
DrawingStyle in Line and Histrogram, all OK,
DrawingStyle in Symbol, not Drawing !!!


OS is Windows 7 pro, Java 1.81,
JForex 3.1.10, JForex API 2.13.36

Please correct this bug !!


 

Jump to:  

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