Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Need Help for Renko Bar
 Post subject: Need Help for Renko Bar Post rating: 1   New post Posted: Tue 17 Jun, 2014, 08:15 
User avatar

User rating: 1
Joined: Sun 09 Feb, 2014, 14:42
Posts: 15
Location: Indonesia, Bandung
Hello. I try to make strategy using Renko 10 pips [7] and Simple Moving Average (SMA) 100.
But the indicator calculation result is different from the chart.
So I try to calculate the indicator from the chart (I get the strategy code from wiki):

package jforex.charts.ind;

import java.util.Arrays;

import com.dukascopy.api.DataType;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IChart;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IHistory;
import com.dukascopy.api.IIndicators;
import com.dukascopy.api.IIndicators.AppliedPrice;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.ITimedData;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.OfferSide;
import com.dukascopy.api.Period;
import com.dukascopy.api.feed.IFeedDescriptor;
import com.dukascopy.api.indicators.IIndicator;
import com.dukascopy.api.indicators.IIndicatorAppearanceInfo;
import com.dukascopy.api.indicators.OutputParameterInfo;

/**
 * The strategy calculates indicators with the same parameters
 * as they appear on the last selected chart
 *
 */
public class CalculateIndicatorsFromChart implements IStrategy {

    private IIndicators indicators;
    private IHistory history;
    private IConsole console;
    private IChart chart;
   
    private int dataCount = 3;

    @Override
    public void onStart(IContext context) throws JFException {
        indicators = context.getIndicators();
        history = context.getHistory();
        console = context.getConsole();
        chart = context.getLastActiveChart();
        if (chart == null) {
            console.getErr().println("No chart opened!");
            return;
        }
        IFeedDescriptor feedDescriptor = chart.getFeedDescriptor();
        if(feedDescriptor.getDataType() == DataType.TICKS){
            console.getWarn().println("Tick charts need to get calculate with from-to method");
            return;
        }
       
        for (IIndicatorAppearanceInfo info : chart.getIndicatorApperanceInfos()) {
            AppliedPrice[] appliedPrices = new AppliedPrice[info.getDrawingStyles().length];
            Arrays.fill(appliedPrices, AppliedPrice.CLOSE);
            OfferSide[] offerSides = new OfferSide[info.getDrawingStyles().length];
            Arrays.fill(offerSides, chart.getSelectedOfferSide());
            IIndicator indicator = indicators.getIndicator(info.getName());
            ITimedData feedData = history.getFeedData(feedDescriptor, 1);
            console.getInfo().println("completed " + feedData + " of feed: " + feedDescriptor);
            Object[] result = indicators.calculateIndicator(feedDescriptor, offerSides, info.getName(), appliedPrices, info.getOptParams(), dataCount, feedData
                    .getTime(), 0);
            for (int i = 0; i < indicator.getIndicatorInfo().getNumberOfOutputs(); i++) {
                OutputParameterInfo.Type outputType = indicator.getOutputParameterInfo(i).getType();
                String resultStr =
                        outputType == OutputParameterInfo.Type.DOUBLE ? Arrays.toString((double[]) result[i])
                        : outputType == OutputParameterInfo.Type.INT ? Arrays.toString((int[]) result[i])
                        : "object outputs need special processing";
                console.getOut().format("%s %s last %s values: %s", info.getName(), indicator.getOutputParameterInfo(i).getName(), dataCount, resultStr).println();
            }

        }
       
        context.stop();
    }

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {}

    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}

    @Override
    public void onMessage(IMessage message) throws JFException {}

    @Override
    public void onAccount(IAccount account) throws JFException {}

    @Override
    public void onStop() throws JFException {}

}


Image

Result of the last 3 values:
Chart -> 1.35860 ; 1.35856 ; 1.35851
Strategy -> 1.35865 ; 1.35862 ; 1.35858

1. How to fix miscalculation indicator in Renko bar?
2. How to fix calculates indicator from the chart?

Sorry for my bad English.
Thank you.


 
 Post subject: Re: Need Help for Renko Bar Post rating: 0   New post Posted: Wed 18 Jun, 2014, 13:10 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Hi,

Some thing to consider:
1) Make sure you are using the exact same settings (filters, indicator parameters, etc). More on this at:
https://www.dukascopy.com/wiki/#Indicato ... _checklist
2) There are some 'bugs' regarding Renko feed currently on the platform. Take a look on the following topics to see if you are facing the same issues:
viewtopic.php?f=85&t=50640
viewtopic.php?f=85&t=50994

Some good news:
If you indeed face those bugs, a redesigned version of Renko feed is available on the JForex 4 platform. Give it a try:
viewtopic.php?f=200&t=51402


 
 Post subject: Re: Need Help for Renko Bar Post rating: 0   New post Posted: Wed 18 Jun, 2014, 13:57 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We managed to replicate this, the issue has been registered.


 
 Post subject: Re: Need Help for Renko Bar Post rating: 0   New post Posted: Tue 24 Jun, 2014, 06:42 
User avatar

User rating: 1
Joined: Sun 09 Feb, 2014, 14:42
Posts: 15
Location: Indonesia, Bandung
Thank you Tcsabina and Admin


 
 Post subject: Re: Need Help for Renko Bar Post rating: 0   New post Posted: Tue 09 Dec, 2014, 16:22 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The issue has been fixed. Renko bar calculation has changed. In-progress Renko bars are no longer generated. Therefore there are no renko bars with index 0 and expression
history.getFeedData(renkoFeedDescriptor, 0);
will always return null;
The attached strategy includes an example with Renko bars.


Attachments:
CalculateIndicatorsFromChart2.java [5.26 KiB]
Downloaded 160 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Need Help for Renko Bar Post rating: 0   New post Posted: Tue 13 Jan, 2015, 01:39 
User avatar

User rating: 1
Joined: Sun 09 Feb, 2014, 14:42
Posts: 15
Location: Indonesia, Bandung
Thank you,Admin.

I try to use it on SMA and SAR. For SMA the result for API and Chart is same. But for SAR the result is different.
Image

I can't find SAR for IFeedDescriptor in javadoc. Is this affect the API calculation result?

Thank you


 
 Post subject: Re: Need Help for Renko Bar Post rating: 0   New post Posted: Tue 20 Jan, 2015, 13:54 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
SAR indicator needs more values for calculation.
Please try running the new test strategy that is in the attachment.
(1. open RENKO chart, 2. add SAR to the chart, 3. run the strategy)


Attachments:
CalculateIndicatorsFromChart3.java [5.26 KiB]
Downloaded 236 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Need Help for Renko Bar Post rating: 0   New post Posted: Wed 11 Feb, 2015, 14:45 
User avatar

User rating: 1
Joined: Sun 09 Feb, 2014, 14:42
Posts: 15
Location: Indonesia, Bandung
Thank you, Admin :)


 

Jump to:  

  © 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