Dukascopy
 
 
Wiki JStore Search Login

试编程指标,竟然不显示,可一切正常啊,请教为什么?
 Post subject: 试编程指标,竟然不显示,可一切正常啊,请教为什么? Post rating: 0   New post Posted: Sat 27 May, 2017, 08:38 
User avatar

User rating: 0
Joined: Sat 18 Mar, 2017, 05:03
Posts: 26
Location: China,
试编程一个指标,竟然不显示,可一切正常啊,请教为什么?
箭头指标在副图,为简化,直接赋值 60, 20 , 用console调试检查一切正常,metainfo显示也正常,怎么就是没箭头显示呢?

代码如下,请教!
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),
            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();
        }
      //这里直接赋值给指标数组60, 20
     
     return new IndicatorResult(startIndex, j, endIndex);   
    }
    //各个get/set
    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: 试编程指标,竟然不显示,可一切正常啊,请教为什么? Post rating: 0   New post Posted: Tue 30 May, 2017, 08:29 
User avatar

User rating: 0
Joined: Sat 18 Mar, 2017, 05:03
Posts: 26
Location: China,
经检查发现:
OutputParameterInfo.DrawingStyle.ARROW_SYMBOL_UP
在指标子面板无效! 
OutputParameterInfo.DrawingStyle.LINE/HISTROGRAM 正常。
看来是个BUG。
不知道技术人员设计时怎么 禁止在指标子面板绘制ARROW_SYMBOL,只是不绘制,用consol调试计算正常!!


 
 Post subject: Re: 试编程指标,竟然不显示,可一切正常啊,请教为什么? Post rating: 0   New post Posted: Tue 30 May, 2017, 16:08 
Visual JForex expert at Dukascopy

User rating: 1
Joined: Fri 28 Aug, 2015, 09:49
Posts: 53
Location: China, Shanghai
您好,

您可以将这一问题通过邮件反馈到[email protected]

会有相关的技术人员跟进的。

感谢您的配合。

祝好,

Kelvin Zhang


 
 Post subject: Re: 试编程指标,竟然不显示,可一切正常啊,请教为什么? Post rating: 0   New post Posted: Tue 30 May, 2017, 16:36 
User avatar

User rating: 0
Joined: Sat 18 Mar, 2017, 05:03
Posts: 26
Location: China,
已经发了,[email protected] 回mail要详细说明和代码,也发给他了。
话说技术人员也不来这技术论坛?
还是各部门互不相通,互相隔离?

验证很简单,把分形指标Fractsl改为指标子面板用,就会发现 根本不显示。


 
 Post subject: Re: 试编程指标,竟然不显示,可一切正常啊,请教为什么? Post rating: 0   New post Posted: Wed 31 May, 2017, 07:41 
Visual JForex expert at Dukascopy

User rating: 1
Joined: Fri 28 Aug, 2015, 09:49
Posts: 53
Location: China, Shanghai
您好,

负责代码编译的同事主要是查看邮件内容的。此处更多的是关于视像JForex的一些问题。

感谢您的理解和配合。

祝好,

Kelvin Zhang


 

Jump to:  

  © 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