Dukascopy
 
 
Wiki JStore Search Login

problem with indicator conversion
 Post subject: problem with indicator conversion Post rating: 0   Post Posted: Tue 20 Aug, 2013, 19:22 
User avatar

User rating: 1
Joined: Tue 26 Feb, 2013, 08:36
Posts: 20
Location: Poland, Warsaw
Hi,
I'd like to convert my old indicator from mq4 to java. (I use guide from here: https://www.dukascopy.com/wiki/#Convert_an_indicator)

During conversion I receive an error:
Quote:
2013-08-20 18:01:27 ----------
2013-08-20 18:01:27 Type mismatch: cannot convert from boolean to int
2013-08-20 18:01:27 ^^^^^
2013-08-20 18:01:27 case false:
2013-08-20 18:01:27 2. ERROR in C:\...\jfxide\tmp\compile\SafeZone_v01.java (at line 95)
2013-08-20 18:01:27 ----------
2013-08-20 18:01:27 Type mismatch: cannot convert from boolean to int
2013-08-20 18:01:27 ^^^^
2013-08-20 18:01:27 case true:
2013-08-20 18:01:27 1. ERROR in C:\...\jfxide\tmp\compile\SafeZone_v01.java (at line 85)
2013-08-20 18:01:27 ----------


I've checked for assigments and comparisions and I can not find a problem.

Please help :)

Regards,
Piter


Attachments:
Indicator.mq4 [4.39 KiB]
Downloaded 364 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: problem with indicator conversion Post rating: 1   Post Posted: Tue 20 Aug, 2013, 23:56 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi piter_44:

I do not know mt4 programing language but it seems a problem with "bool uptrend" variable. On the script this variable don't is initialized, it have the default value i don't know what mt4 uses by default... may be if you change it to int and replace the "true" with the value 1 and false with 0 (int values for boolean true and false in mt4) on the switch function and on the assignments may resolve this problem.

I hope this helps

Trade well

JL


 
 Post subject: Re: problem with indicator conversion Post rating: 0   Post Posted: Wed 21 Aug, 2013, 10:12 
User avatar

User rating: 1
Joined: Tue 26 Feb, 2013, 08:36
Posts: 20
Location: Poland, Warsaw
Hi jlongo,

Thanks for reply, I have tried this I also checked if there is not assignment (=) operator instead of a comparison operator (==) which is common mistake.

Regards,
Piter


 
The Best Answer  Post subject: Re: problem with indicator conversion Post rating: 0   Post Posted: Wed 21 Aug, 2013, 23:08 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
The issue here is that in java you cannot use switch with a boolean parameter.
The original mq4 code reads as:
...
bool uptrend;
...
switch(uptrend)
{
         case true:
...
         break;
         case false:
...
         break;   


This is not valid in java.

There are 2 solutions:
1) Support must do something with this, that in such situation the generated java code is compilable, not just a raw copy of the mq4 stuff.
2) You must modify the mq4 code and try not to use a boolean in the switch statement.

As a workaround, you can give it a try to compile and test the attached java source, that is a modified version of the generated one.


Attachments:
File comment: modified version of the generated code
SafeZone_v01.java [5.25 KiB]
Downloaded 354 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: problem with indicator conversion Post rating: 0   Post Posted: Thu 22 Aug, 2013, 09:27 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
It is fixed in a next platform version.


 
 Post subject: Re: problem with indicator conversion Post rating: 0   Post Posted: Thu 22 Aug, 2013, 11:42 
User avatar

User rating: 1
Joined: Tue 26 Feb, 2013, 08:36
Posts: 20
Location: Poland, Warsaw
tcsabina thanks a lot it works :)


 

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