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 with Math.max in 4sma indicator
 Post subject: Problem with Math.max in 4sma indicator Post rating: 0   New post Posted: Mon 14 Feb, 2011, 00:16 

User rating: 2
Joined: Wed 18 May, 2011, 17:36
Posts: 49
Location: FranceFrance
Hello
could you explain how to correct an error with the Math.max function? I don't understand how it works. I try to make indicator with 4 sma but I m not able to make it works with four sma, only with 3 sma.
Thanks

23:16:15 ----------
23:16:15 The method max(int, int) in the type Math is not applicable for the arguments (int, int, int)
23:16:15 ^^^
23:16:15 return Math.max(sma1Lookback, Math.max(sma2Lookback, sma3Lookback,sma4Lookback));
23:16:15 1. ERROR in C:\Users\Math\AppData\Local\Temp\jfxide\tmp\FOURSMAIndicator.java (at line 83)
23:16:15 ----------


Attachments:
FOURSMAIndicator.java [4.69 KiB]
Downloaded 393 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 Math.max in 4sma indicator Post rating: 0   New post Posted: Mon 14 Feb, 2011, 09:46 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
The method Math.max takes two arguments, not three:
Math.max(sma1Lookback, Math.max(Math.max(sma2Lookback, sma3Lookback), sma4Lookback));


 
 Post subject: Re: Problem with Math.max in 4sma indicator Post rating: 0   New post Posted: Mon 14 Feb, 2011, 12:02 

User rating: 2
Joined: Wed 18 May, 2011, 17:36
Posts: 49
Location: FranceFrance
Hi
thanks. Could show me the way to do it when you have 3 arguments (in my indicator, 4sma)? Thanks


 
 Post subject: Re: Problem with Math.max in 4sma indicator Post rating: 0   New post Posted: Tue 15 Feb, 2011, 09:58 

User rating: 0
Joined: Tue 07 Dec, 2010, 15:50
Posts: 17
lol.
1/it's quite obvious
2/its written above.


 
 Post subject: Re: Problem with Math.max in 4sma indicator Post rating: 0   New post Posted: Tue 15 Feb, 2011, 18:34 

User rating: 2
Joined: Wed 18 May, 2011, 17:36
Posts: 49
Location: FranceFrance
:oops: :oops: :oops:
Oh my god!! I was thinking support's answer was a quote of my piece of code.... :D
I change the code and now it compiles without any error!
Thanks support and thanks Crito to wake me up!!
M.

An other question: Is it now possible to code the width of the sma line? I read in another topic that it doesn't work. Is it ok now? and does someone know how to do it?
Same question about the color... I tryed to add " import java.awt.Color" and "outputParameterInfos[3].setColor(Color.BLUE);" to have my last and bigger sma in a special color but it doesn't work, there is always a default color....Is there a particular way to do it?

Thanks for any help.
edit:below the indicator FOURSMA and a screenshot


Attachments:
Chart_EUR_USD_1 Min_FOURSMA.png [20.14 KiB]
Downloaded 470 times
FOURSMAIndicator.java [4.74 KiB]
Downloaded 379 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 Math.max in 4sma indicator Post rating: 0   New post Posted: Wed 16 Feb, 2011, 10:01 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Please have a look at the following code:
outputParameterInfos = new OutputParameterInfo[] {         
        new OutputParameterInfo("SMA1", OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.LINE){{
           setColor(Color.RED);                 
        }},
        new OutputParameterInfo("SMA2", OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.LINE){{
           setColor(Color.BLACK);
        }},
        ...       
       


 
 Post subject: Re: Problem with Math.max in 4sma indicator Post rating: 0   New post Posted: Wed 16 Feb, 2011, 13:37 

User rating: 2
Joined: Wed 18 May, 2011, 17:36
Posts: 49
Location: FranceFrance
hi! Thanks. I Will try it. Have you got an answer for the widthness of the Line?
Thanks
m.


 
 Post subject: Re: Problem with Math.max in 4sma indicator Post rating: 0   New post Posted: Thu 24 Feb, 2011, 20:14 

User rating: 2
Joined: Wed 18 May, 2011, 17:36
Posts: 49
Location: FranceFrance
Could someone help me with the width of a sma? Is it impossible to code it?
Thanks a lot if you could answer me...
M


 
 Post subject: Re: Problem with Math.max in 4sma indicator Post rating: 0   New post Posted: Tue 01 Mar, 2011, 10:03 

User rating: 2
Joined: Wed 18 May, 2011, 17:36
Posts: 49
Location: FranceFrance
Always waiting for a short answer...


 
 Post subject: Re: Problem with Math.max in 4sma indicator Post rating: 0   New post Posted: Tue 01 Mar, 2011, 10:51 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
At the moment the width can only be set through the 'Add/Edit Indicator' dialog or through the IChart.addIndicator() when adding your indicator on chart.


 

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