Dukascopy Support Board http://www.dukascopy.com/swiss/english/forex/jforex/forum/ |
|
Pivot Points - JForex http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=56879 |
Page 1 of 1 |
Author: | wheelsofsteel2 [ Mon 31 Dec, 2018, 08:40 ] |
Post subject: | Pivot Points - JForex |
I am unable to locate the class/function in the JForex SDK to return the PivotPoint I see on my chart called PIVOT2, so I tried to calculate the value myself based on the previous DAILY bar as below. Two questions relating to the code segment: Q1: Can anyone please provide me with the code to retrieve the pivot point/s using the SDK and Java? Q2: The IBar (bars & bars2) do not exactly match the values for the previous DAILY bar on the chart. Is my code incorrect and can you suggest a better/correct way of retrieving the previous DAILY bar? prevBar is commented out as it's values are way off what I observe on the chart. Thank you. long prevBarTime = history.getPreviousBarStart(Period.DAILY, history.getLastTick(sInstrument).getTime()); //IBar prevBar; // = history.getBar(sInstrument, Period.DAILY, OfferSide.BID, 1); List<IBar> bars = history.getBars(sInstrument, Period.DAILY, OfferSide.BID, Filter.WEEKENDS, 2, prevBarTime, 1); List<IBar> bars2 = history.getBars(sInstrument, Period.DAILY, OfferSide.ASK, Filter.WEEKENDS, 2, prevBarTime, 1); double iAvgPriceH = (bars.get(0).getHigh() + bars2.get(0).getHigh())/2; double iAvgPriceL = (bars.get(0).getLow() + bars2.get(0).getLow())/2; //double iAvgPriceO = (bars.get(0).getOpen() + bars2.get(0).getOpen())/2; double iAvgPriceC = (bars.get(0).getClose() + bars2.get(0).getClose())/2; for (int i = 1; i < bars.size(); i++) {} oPivotPoints = new CPivotPoints(); oPivotPoints.PP = (iAvgPriceH + iAvgPriceL + iAvgPriceC)/3; oPivotPoints.S1 = (oPivotPoints.PP * 2) - iAvgPriceH; oPivotPoints.S2 = oPivotPoints.PP - (iAvgPriceH - iAvgPriceL); |
Author: | API Support [ Thu 03 Jan, 2019, 17:07 ] |
Post subject: | Re: Pivot Points - JForex |
Hello, Quote: Q1: Can anyone please provide me with the code to retrieve the pivot point/s using the SDK and Java? Indicators API have own method for calculating Pivot Points. This code should work. this.indicators = context.getIndicators(); Quote: Q2: The IBar (bars & bars2) do not exactly match the values for the previous DAILY bar on the chart. Is my code incorrect and can you suggest a better/correct way of retrieving the previous DAILY bar? prevBar is commented out as it's values are way off what I observe on the chart. It is a working way. Firstly, check your chart settings, if you use Period.DAILY for retrieving bars - they will be based on GMT Timezone, therefore Day Start Time in your chart preferences(Settings - Preferences - Charts) also need be GMT. Otherwise, the values will vary. |
Author: | fxprogrammer [ Mon 19 Aug, 2019, 20:20 ] |
Post subject: | Re: Pivot Points - JForex |
wheelsofsteel2 wrote: Q2: The IBar (bars & bars2) do not exactly match the values for the previous DAILY bar on the chart. Is my code incorrect and can you suggest a better/correct way of retrieving the previous DAILY bar? prevBar is commented out as it's values are way off what I observe on the chart. Try to create custom Daily period and filter Weekends to avoid zero periods: Period custom_daily = Period.createCustomPeriod(Unit.Day, 1, JFTimeZone.EET); Hope it helps, because this problem is about all Daily calculations, not only pivot but ATR etc. |
Page 1 of 1 |