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.

Making An EMA Of An Indicator
 Post subject: Making An EMA Of An Indicator Post rating: 0   New post Posted: Tue 15 Dec, 2020, 12:07 

User rating: 0
Joined: Tue 15 Dec, 2020, 11:57
Posts: 1
Location: Turkey,
Hello,

In order to write an EMA of an Instrument, we write;

double ema50 = indicators.ema(myInstrument, myPeriod, myOfferSide, IIndicators.AppliedPrice.CLOSE, 50, 0);


And we can declare a Price Oscillator of an Instrument just as;

double POSC = indicators.ppo(myInstrument, myPeriod, myOfferSide, IIndicators.AppliedPrice.CLOSE, 2, 26,IIndicators.MaType.EMA, 1);


So my question here is, how can i create, let's say an EMA of 10 and 20 of the Price Oscillator Indicator in Strategy Tester?


 
 Post subject: Re: Making An EMA Of An Indicator Post rating: 0   New post Posted: Mon 11 Jan, 2021, 21:40 

User rating: 1
Joined: Sat 02 Jan, 2021, 23:10
Posts: 2
Location: GermanyGermany
Hello,

A small function, I hope it will help.

double[] getMaFromArray(double[] valArray, IIndicators.MaType matype, int timePeriod) {
       
        IIndicator ma;
        ma = indicators.getIndicator("ma");
       
        //inputs
        ma.setInputParameter(0, valArray); //Value Array
        ma.setOptInputParameter(0, timePeriod);//Time Period
        ma.setOptInputParameter(1, matype.ordinal()); //MA Type
       
        //outputs
        int length = valArray.length - timePeriod+1; //Calculation Length of Result
       
        double[] result = new double[length];
        ma.setOutputParameter(0,result);
        ma.calculate(0, valArray.length-1);
       
        return result;
    }


 

Jump to:  

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