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.

Simple Programing Problem
 Post subject: Simple Programing Problem Post rating: 0   New post Posted: Mon 26 Nov, 2012, 16:43 

User rating: 0
Joined: Mon 26 Nov, 2012, 16:32
Posts: 11
Location: JapanJapan
Hi, i'am newbee in Jforex.

I'am progressing step by step.
And i've simple problem. I'm just trying too use indicators and reading results. But I don't understand why my code is wrong. My code works, but values in returns are bullshits.... for me, my code seems to be correct, but results don't correspond to the reality.... i don't get the good values expected when control them in the chart with the same indicators that i called in my code.
I find this totally absurd....
Thanks for your help !!!

Here's my simple code.



package jforex;

import java.util.*;

import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;

public class StrategyTEST4 implements IStrategy {
    private IEngine engine;
    private IConsole console;

    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;


   
   
    @Configurable("Instrument")
    public Instrument instrument = Instrument.EURUSD;
    @Configurable("Period M15")
    public Period selectedPeriod = Period.FIFTEEN_MINS;
   
    @Configurable("Period H1")
    public Period selectedPeriodh = Period.ONE_HOUR;

    @Configurable("Period M5")
    public Period selectedPeriodc = Period.FIVE_MINS;
       
        @Configurable("Period M1")
    public Period selectedPeriodo = Period.ONE_MIN;       
                   
    @Configurable("SMA filter")
    public Filter indicatorFilter = Filter.NO_FILTER;
    @Configurable("Amount")
    public double amount = 0.1;
    @Configurable("Stop loss")
    public int stopLossPips = 20;
   
   
    @Configurable("w")
    public double w = 0;
   
   
    @Configurable("Take profit")
    public int takeProfitPips = 100;
   

   
    public static void main(String[] args)
        {System.out.println("Hello world");
        }
 

   
    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        this.console = context.getConsole();
        this.history = context.getHistory();
        this.context = context;
        this.indicators = context.getIndicators();
        this.userInterface = context.getUserInterface();
    }
   


    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onStop() throws JFException {
    }

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



           


    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
               
        int cciperiod = 14;
        int shift = 0;   
        int rsiperiod = 50;
               
        int fastPeriod = 12;
        int slowPeriod = 26;
        int signalPeriod = 9;

        double ccim = indicators.cci(instrument, selectedPeriod, OfferSide.BID, cciperiod, shift);
       
       
        double ccio = indicators.cci(instrument, selectedPeriodo, OfferSide.ASK, cciperiod, shift);

        double ccih = indicators.cci(instrument, selectedPeriodh, OfferSide.BID, cciperiod, shift);

         double[] macd = indicators.macd(instrument, selectedPeriodc,  OfferSide.BID, IIndicators.AppliedPrice.CLOSE, fastPeriod, slowPeriod, signalPeriod, shift);
   
         double macdd = macd[0];
         
        double rsih = indicators.rsi(instrument, selectedPeriodh, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, rsiperiod, shift);

        double rsic = indicators.rsi(instrument, selectedPeriodc, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, rsiperiod, shift);

        console.getOut().println("CCI M1 equals "+ccio);
        console.getOut().println("MACD M5 equals "+macdd);
        console.getOut().println("CCI M5 equals "+ccim);
        console.getOut().println("RSI M5 equals "+rsic);
        console.getOut().println("CCI HOUR equals "+ccih);
        console.getOut().println("RSI H1 equals "+rsih);
    }
}


 
 Post subject: Re: Simple Programing Problem Post rating: 0   New post Posted: Mon 26 Nov, 2012, 16:52 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
https://www.dukascopy.com/wiki/#Indicator_usage_checklist
For more convenient value comparison, consider including the indicator outputs in the OHLC informer object:
https://www.dukascopy.com/wiki/#Add_indicators_on_chart/Include_in_OHLC


 
 Post subject: Re: Simple Programing Problem Post rating: 0   New post Posted: Mon 26 Nov, 2012, 19:52 

User rating: 0
Joined: Mon 26 Nov, 2012, 16:32
Posts: 11
Location: JapanJapan
I just want to know the values for MACD, RSI, and CCI, for different time scales for each ticks.
So, i needn't filtration, and i needn't GMT time... but i've tryed each of the three alternatives (fllter all flats, etc...) and nothing change.
I get for each tick three or four values for each indicators for one timescales..., and one of them seems to be the good one....
So, i get simultanously three or four values where i'm supoosed to get only one.

How to get the one values for a ticks ?
Thank you.


 
 Post subject: Re: Simple Programing Problem Post rating: 0   New post Posted: Tue 27 Nov, 2012, 08:20 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
germain wrote:
So, i get simultanously three or four values where i'm supoosed to get only one.
Please precisely describe which output values of which indicators you want to get.


 
 Post subject: Re: Simple Programing Problem Post rating: 0   New post Posted: Tue 27 Nov, 2012, 09:58 

User rating: 0
Joined: Mon 26 Nov, 2012, 16:32
Posts: 11
Location: JapanJapan
I need to get, on each tick:
Main MACD M5
RSI M5
RSI H1
CCI M15 & CCI H1


 
 Post subject: Re: Simple Programing Problem Post rating: 0   New post Posted: Tue 27 Nov, 2012, 12:50 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Also please provide which output values for each indicator you wish to retrieve.


 
 Post subject: Re: Simple Programing Problem Post rating: 0   New post Posted: Tue 27 Nov, 2012, 14:04 

User rating: 0
Joined: Mon 26 Nov, 2012, 16:32
Posts: 11
Location: JapanJapan
I don't understand your question. What do you mean by "output value".
It seems for MACD, there's just two possibilities: Main and Signal. And i want the "Main".
And for the CCI and RSI there's just one and only one output ! No ???
So i don't know how i can be more precise.

Thanks for your help!


 
 Post subject: Re: Simple Programing Problem Post rating: 0   New post Posted: Tue 27 Nov, 2012, 15:25 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
https://www.dukascopy.com/wiki/#Add_indicators_on_chart/Plot_on_newly_opened_chart


 

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