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.

problem opening custom indicator(mq4 to java, compiled jfx)
 Post subject: problem opening custom indicator(mq4 to java, compiled jfx) Post rating: 0   New post Posted: Thu 17 May, 2012, 08:53 

User rating: 0
Joined: Wed 16 May, 2012, 19:03
Posts: 2
I have followed all steps to transform am mq4 indicator to java , succesfully compiled it to jfx, but when I try to open it I get the message: "wrong selection", "
"selected indicators {0}". What should I do?
thank you


 
 Post subject: Re: problem opening custom indicator(mq4 to java, compiled jfx) Post rating: 0   New post Posted: Thu 17 May, 2012, 09:20 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Did you try the "Add to active chart" option which is shown in the example? Did that work?
Alternatively, could you please provide the jfx file such that we can see if we can replicate the issue with the particular compiled indicator.


 
 Post subject: Re: problem opening custom indicator(mq4 to java, compiled jfx) Post rating: 0   New post Posted: Thu 17 May, 2012, 14:00 

User rating: 0
Joined: Wed 16 May, 2012, 19:03
Posts: 2
hi, that is exactely when the problem appears, when I try to attach it;
here is the converted indicator:

package jforex.converted;
import java.awt.Color;
import com.dukascopy.api.*;
import com.dukascopy.connector.engine.*;
import com.dukascopy.connector.engine.Properties;
import com.dukascopy.connector.engine.IndicatorBuffer;
@RequiresFullAccess
@Library("C:/Users/flo/Desktop/libs/MQL4Connector-2.6.60.2.jar")
public class StochasticWallabys2 extends MQL4ConnectorStrategy {

protected void initProperties() {
if (properties == null) {
properties = new Properties();
}
properties.setProperty("indicator_width4","2");
properties.setProperty("indicator_buffers","4");
properties.setProperty("indicator_minimum","0");
properties.setProperty("link","http:");
properties.setProperty("indicator_separate_window","true");
properties.setProperty("indicator_color2","Silver");
properties.setProperty("copyright","Copyright 2010 Toshiyuki Tega (Softgate Limited)");
properties.setProperty("indicator_color1","Silver");
properties.setProperty("indicator_maximum","100");
properties.setProperty("indicator_color3","Silver");
properties.setProperty("indicator_color4","Red");
properties.setProperty("indicator_style4","STYLE_SOLID");
properties.setProperty("indicator_style3","STYLE_SOLID");
properties.setProperty("indicator_style2","STYLE_SOLID");
properties.setProperty("indicator_style1","STYLE_SOLID");
}
protected int indicator_width4 = 2;
protected Color indicator_color2 = Silver;
protected Color indicator_color1 = Silver;
protected Color indicator_color3 = Silver;
protected Color indicator_color4 = Red;
@Configurable("") public int KPeriod=toInt(7);
@Configurable("") public int DPeriod=toInt(3);
@Configurable("") public int Slowing=toInt(3);
@Configurable("") public int Timeframe1=toInt(1);
@Configurable("") public int Timeframe2=toInt(5);
@Configurable("") public int Timeframe3=toInt(15);
@Configurable("") public int Type=toInt(0);
@IndicatorBuffer ("") public double[] Wallabys = new double[0];
@IndicatorBuffer ("") public double[] Stoch1 = new double[0];
@IndicatorBuffer ("") public double[] Stoch2 = new double[0];
@IndicatorBuffer ("") public double[] Stoch3 = new double[0];
public int init() throws JFException {
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Stoch1);
SetIndexLabel(0,"Stochastic 1");
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,Stoch2);
SetIndexLabel(1,"Stochastic 2");
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,Stoch3);
SetIndexLabel(2,"Stochastic 3");
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,Wallabys);
SetIndexLabel(3,"Wallabys");
IndicatorShortName("Stochastic Wallabys ("+KPeriod+","+DPeriod+","+Slowing+","+Type+","+Timeframe1+","+Timeframe2+","+Timeframe3+")");
if(true)return toInt(0);return 0;
}
public int deinit() throws JFException {
if(true)return toInt(0);return 0;
}
public int start() throws JFException {
int countedBars = 0;
int barsNeeded = 0;
int i=toInt(0);
int shift1 = 0;
double stoch1 = 0.0;
int shift2 = 0;
double stoch2 = 0.0;
int shift3 = 0;
double stoch3 = 0.0;
countedBars = toInt(IndicatorCounted());
barsNeeded = toInt(Bars-countedBars);
for(i=(int)0;i<barsNeeded;i++){
shift1 = toInt(iBarShift(null,Timeframe1,iTime(null,0,i),false));
stoch1 = toDouble(iStochastic(null,Timeframe1,KPeriod,DPeriod,Slowing,MODE_SMA,Type,MODE_MAIN,shift1));
shift2 = toInt(iBarShift(null,Timeframe2,iTime(null,0,i),false));
stoch2 = toDouble(iStochastic(null,Timeframe2,KPeriod,DPeriod,Slowing,MODE_SMA,Type,MODE_MAIN,shift2));
shift3 = toInt(iBarShift(null,Timeframe3,iTime(null,0,i),false));
stoch3 = toDouble(iStochastic(null,Timeframe3,KPeriod,DPeriod,Slowing,MODE_SMA,Type,MODE_MAIN,shift3));
Stoch1[toInt(i)]=toDouble(stoch1);
Stoch2[toInt(i)]=toDouble(stoch2);
Stoch3[toInt(i)]=toDouble(stoch3);
Wallabys[toInt(i)]=toDouble((stoch1+stoch2+stoch3)/3);
}
if(true)return toInt(0);return 0;
}

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException{}


then I get the message compiled ok:

2012-05-17 12:36:20 Compilation successful. Strategy ID: 018518F527C043D1DF3CF4C45EEFA8E4

when I try add to chart it won t work


 
 Post subject: Re: problem opening custom indicator(mq4 to java, compiled jfx) Post rating: 0   New post Posted: Thu 17 May, 2012, 14:03 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You compiled the indicator as a strategy. Please use the integrated converter, see:
viewtopic.php?f=65&t=47063


 

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