|
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.
| How to use use MACD RSI KDJ EMA function as MQ4? |
|
David_Chen
|
| Post subject: How to use use MACD RSI KDJ EMA function as MQ4? |
Post rating: 0
|
Posted: Mon 24 Dec, 2018, 07:32
|
|
User rating: 0
Joined: Sun 23 Dec, 2018, 16:58 Posts: 5 Location: China,
|
|
HI I have MQ4 EA,I wang to convert to JFOREX,but I don't know hou to call these indicators function. 10 yeasr ago,I wrote EA call these function as: double m0=indicators.sma(insturment.EURUSD,Period.TEN_MIN,OfferSide.BID,IIndicators.AppliedPrice.MEDIAN_PRICE,period,0); double m1=indicators.sma(insturment.EURUSD,Period.TEN_MIN,OfferSide.BID,IIndicators.AppliedPrice.MEDIAN_PRICE,period,1);
It's easy to change from MQ4 to JFOREX. But I canot find these function ,I read the sample,it used as the follow(It's very difficut to undserstand): Object[] indicatorResult = indicators.calculateIndicator(selectedInstrument, Period.TEN_MINS, new OfferSide[] {OfferSide.BID}, "SMA", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {30}, 0); double m0 = (Double) indicatorResult[0]; indicatorResult = indicators.calculateIndicator(selectedInstrument, Period.TEN_MINS, new OfferSide[] {OfferSide.BID}, "SMA", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {30}, 1); double m1 = (Double) indicatorResult[0];
|
|
|
|
|
 |
|
API Support
|
| Post subject: Re: How to use use MACD RSI KDJ EMA function as MQ4? |
Post rating: 0
|
Posted: Thu 03 Jan, 2019, 12:55
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hello, Your example is correct. There is two options for retrieving sma value: use standart indicators.calculateIndicator() method and specify indicator by name, or use already provided indicators.sma() method. Code sample: public void onStart(IContext context) throws JFException { this.console = context.getConsole(); this.history = context.getHistory(); this.context = context; this.indicators = context.getIndicators();
Instrument selectedInstrument = Instrument.EURUSD; int timePeriod = 30;
//first option Object[] indicatorResult = indicators.calculateIndicator(selectedInstrument, Period.TEN_MINS, new OfferSide[] {OfferSide.BID}, "SMA", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {timePeriod}, 0); double example1FirstBar = (Double) indicatorResult[0]; indicatorResult = indicators.calculateIndicator(selectedInstrument, Period.TEN_MINS, new OfferSide[] {OfferSide.BID}, "SMA", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {timePeriod}, 1); double example1SecondBar = (Double) indicatorResult[0];
//second option double example2FirstBar = indicators.sma(Instrument.EURUSD,Period.TEN_MINS,OfferSide.BID,IIndicators.AppliedPrice.MEDIAN_PRICE, timePeriod, 0); double example2SecondBar = indicators.sma(Instrument.EURUSD,Period.TEN_MINS,OfferSide.BID,IIndicators.AppliedPrice.MEDIAN_PRICE,timePeriod, 1);
console.getOut().println(example1FirstBar); console.getOut().println(example1SecondBar);
console.getOut().println(example2FirstBar); console.getOut().println(example2SecondBar); }
|
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|