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.

Adding ema indicator on IChart with AppliedPrice.HIGH or LOW (by default it's CLOSE)
 Post subject: Adding ema indicator on IChart with AppliedPrice.HIGH or LOW (by default it's CLOSE) Post rating: 0   New post Posted: Wed 17 Feb, 2016, 13:31 

User rating: 6
Joined: Tue 02 Jul, 2013, 16:52
Posts: 38
Dear Community, Dear Support,

I am using a version of TesterMainGUIMode from the wiki to test my strategy and see the price and positions on a chart.
Now I want to add 3 ema indicators: on high, low and close.

Ema on CLOSE was easy with:
                IChart chart = context.getChart(instrument);
                if (chart != null) {
                    IIndicator ema = indicators.getIndicator("EMA");
                    chart.add(ema, new Object[]{34});
                }

Now I want to add the ema on the AppliedPrice.HIGH and AppliedPrice.LOW

When looking at the indicator metadata, I get:
Exponential Moving Average: input count=1, optional input count=1, output count=1
Input 0: Price - DOUBLE
Opt input: Time Period, range: min=2, max=100000, default= 30
Output 0: Line - DOUBLE

I am (almost) sure there is a way to specify on which price to apply (high, low, close, etc...); may be by manipulating somehow the input. Unfortunately, I could not find out how in the wiki, forums or javadoc how to do it!

Thank you in advance for any help!


 
The Best Answer  Post subject: Re: Adding ema indicator on IChart with AppliedPrice.HIGH or LOW (by default it's CLOSE) Post rating: 1   New post Posted: Thu 18 Feb, 2016, 09:20 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Here is an example
IChart chart = context.getLastActiveChart();
       
        IIndicator ema = indicators.getIndicator("EMA");
        InputParameterInfo info = ema.getInputParameterInfo(0);
        info.setAppliedPrice(IIndicators.AppliedPrice.HIGH);
       
        chart.add(ema, new Object[]{34});


 

Jump to:  

cron
  © 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