Dukascopy
 
 
Wiki JStore Search Login

How to automatically add levels in indicator?
 Post subject: How to automatically add levels in indicator? Post rating: 0   New post Posted: Thu 09 May, 2013, 09:33 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
How to automatically add levels in indicator?

For example, as is in RSI indicator.

I know I can add levels later when indicator is on the chart. But I would programm so that the level already appeared at the start


 
 Post subject: Re: How to automatically add levels in indicator? Post rating: 0   New post Posted: Thu 09 May, 2013, 17:05 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
There is no such functionality in JForex-API.


 
 Post subject: Re: How to automatically add levels in indicator? Post rating: 0   New post Posted: Fri 10 May, 2013, 10:48 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
OK Thanks,

I suggest to add such option.


 
 Post subject: Re: How to automatically add levels in indicator? - suggestion for a workaround Post rating: 1   New post Posted: Thu 23 May, 2013, 07:37 
User avatar

User rating: 1
Joined: Fri 24 Jun, 2011, 16:05
Posts: 21
Location: Austria, Innsbruck
Altough there is no explicit functionality in JForex, there is a workaround.

You can define an output, give them a value and format it.

Code could like this:

1.) Define the Level as Output
OutputParameterInfo level = new OutputParameterInfo("Level", OutputParameterInfo.Type.DOUBLE,
OutputParameterInfo.DrawingStyle.LEVEL_DASH_LINE)
{{
setShowOutput(true);
setName("Level");
setColor(Color.BLACK);
setLineWidth(2);
}}
;

2.) Add the Level to outputParameterInfos
outputParameterInfos = new OutputParameterInfo[] { indicatorLine, level};


3.) Allocate a value to the level (0 for the Zero-Level)
In this example i

public IndicatorResult calculate(int startIndex, int endIndex) {
......


outputs[0][j] = //= indicator = Result of "IndicatorResult calculate"

outputs[1][j] = 0; //constant value for the wanted level
..
}


You can add more level if you want.

Restrictions:
With the current API and the above workaround the level-lines disappear when you scroll back the chart, but they work on the "actual" part of the chart.

If anyone finds a better solution please send me the information.

Best would be, when the jForex-API would support levels.

Best regards


 

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