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.

Color coding
 Post subject: Color coding Post rating: 0   Post Posted: Thu 29 Jul, 2010, 16:29 

User rating: 0
Joined: Fri 16 Jul, 2010, 00:26
Posts: 6
Hi,

how can I color-code moving average ( or any indicator that is drawn on the chart) so the line would change color if the current value is lower then the previous one and vice verse. Using two outputs with different colors gives a bad result.

Image


 
 Post subject: Re: Color coding Post rating: 0   Post Posted: Fri 30 Jul, 2010, 08:25 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
you can correct your indicator to have output as you described. To eliminate gaps between lines use the
OutputParameterInfo.setGapAtNaN(). To eliminate a line falling down to 0, use the Double.NaN instead of 0.


 
 Post subject: Re: Color coding Post rating: 0   Post Posted: Fri 30 Jul, 2010, 14:13 

User rating: 0
Joined: Fri 16 Jul, 2010, 00:26
Posts: 6
Support wrote:
Hi,
you can correct your indicator to have output as you described. To eliminate gaps between lines use the
OutputParameterInfo.setGapAtNaN(). To eliminate a line falling down to 0, use the Double.NaN instead of 0.
Thanks for the info.

Note: OutputParameterInfo.setGapAtNaN() will not eliminate gaps. It will draw a gap when the output is NaN.
This is how it looks:
Image

The problem is that for the line to be draw there must be two points. Since for the first candle that changes color there is only one point for that output that line won't be drawn. If I set OutputParameterInfo.DrawingStyle.DOTS it will draw correctly but I would like to know if there is a workaround for the LINE?


 
 Post subject: Re: Color coding Post rating: 0   Post Posted: Mon 02 Aug, 2010, 08:34 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Yes, there is. You can implement an IDrawingIndicator interface and use the drawOutput method.


 
 Post subject: Re: Color coding Post rating: 0   Post Posted: Tue 08 Nov, 2011, 18:43 

User rating: 1
Joined: Tue 12 Jul, 2011, 20:43
Posts: 51
Location: Germany,
Hi Support,

can you please provide a simple indicator example which shows how to implement the IDrawingIndicator interface - a moving average line which is green if current value is greater than previous value and red if current value is lower than previous value ?

Thanks and regards
AbsoluteReturner


 
 Post subject: Re: Color coding Post rating: 0   Post Posted: Wed 09 Nov, 2011, 08:30 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
IDrawingIndicator is meant to be used for drawing custom drawings/objects that are not supported by default implementation. As examples of use of the IDrawingIndicator see sources for:
com.dukascopy.indicators.IchimokuIndicator
com.dukascopy.indicators.GatorIndicator
com.dukascopy.indicators.HekinAshiIndicator
and other indicators that implement IDrawingIndicator. Find the sources in Standalone API: https://www.dukascopy.com/wiki/index.php ... in_Eclipse


 

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