Dukascopy
 
 
Wiki JStore Search Login

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

    Submit JForex API function requests in this forum only.
    Off topics are strictly forbidden.

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

showPresetDialog()
 Post subject: showPresetDialog() Post rating: 0   New post Posted: Wed 27 Nov, 2013, 12:28 
User avatar

User rating: 7
Joined: Tue 28 Feb, 2012, 09:45
Posts: 45
Location: JapanJapan
I want to use a method.
Something like this "int i = JFXPresetPane.showPresetDialog(JFrame, frame, IStrategy strategy);"
Image
Is such Class already exist?
regards,


Attachments:
PresetPanel.JPG [8.62 KiB]
Downloaded 470 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: showPresetDialog() Post rating: 0   New post Posted: Wed 27 Nov, 2013, 12:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Why would you need such method?


 
 Post subject: Re: showPresetDialog() Post rating: 0   New post Posted: Wed 27 Nov, 2013, 14:14 
User avatar

User rating: 7
Joined: Tue 28 Feb, 2012, 09:45
Posts: 45
Location: JapanJapan
I made my own Tester for onBarMethod Strategies.
And, Now, I use that tester strategy like this way,
package jforex.strategies;

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

import mobnaga.hispeedtester.*;
@Library("C:\\Documents and Settings\\adm\\My Documents\\JForex\\Strategies\\files\\mobnaga.hispeedtester.jar")
public class SMASimpleStrategy extends HST_FrontTypeS {
//public class SMASimpleStrategy implements IStrategy {
    private IEngine engine;
    private IHistory history;
    private IIndicators indicators;
    private IConsole console;
    private int counter = 0;

    @Configurable("Instrument")
    public Instrument instrument = Instrument.EURUSD;
    @Configurable("Period")
    public Period selectedPeriod = Period.FIFTEEN_MINS;
    @Configurable("SMA filter")
    public Filter indicatorFilter = Filter.NO_FILTER;
    @Configurable("Amount")
    public double amount = 0.02;
    @Configurable("Stop loss")
    public int stopLossPips = 10;
    @Configurable("Take profit")
    public int takeProfitPips = 90;

    public void onStart(IContext context) throws JFException {
        if(knockOn(context, context.getFilesDir().getAbsolutePath()+"\\HSTTEST_"+hstFromTime+".csv", null) == HST_ENDED) return;
        this.engine = context.getEngine();
        this.history = context.getHistory();
        this.indicators = context.getIndicators();
        this.console = context.getConsole();
    }

    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onStop() throws JFException {
        //close all orders
        for (IOrder order : engine.getOrders()) {
            engine.getOrder(order.getLabel()).close();
        }
    }

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

    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if (!instrument.equals(instrument) || !period.equals(selectedPeriod))
            return;

        IBar prevBar = history.getBar(instrument, selectedPeriod, OfferSide.BID, 1);

        int smaTimePeriod = 50;
        int candlesBefore = 2;
        int candlesAfter = 0;

        double sma = indicators.sma(instrument, selectedPeriod, OfferSide.BID, AppliedPrice.CLOSE, smaTimePeriod, indicatorFilter,
                candlesBefore, prevBar.getTime(), candlesAfter)[0];

        // SMA crossed previous green candle
        if (prevBar.getOpen() < sma && prevBar.getClose() > sma) {
            submitOrder(OrderCommand.BUY);
        }
        // SMA crossed previous red candle
        if (prevBar.getOpen() > sma && prevBar.getClose() < sma) {
            submitOrder(OrderCommand.SELL);
        }
    }

    private IOrder submitOrder(OrderCommand orderCmd) throws JFException {

        double stopLossPrice, takeProfitPrice;

        // Calculating stop loss and take profit prices
        if (orderCmd == OrderCommand.BUY) {
            stopLossPrice = history.getLastTick(this.instrument).getBid() - getPipPrice(this.stopLossPips);
            takeProfitPrice = history.getLastTick(this.instrument).getBid() + getPipPrice(this.takeProfitPips);
        } else {
            stopLossPrice = history.getLastTick(this.instrument).getAsk() + getPipPrice(this.stopLossPips);
            takeProfitPrice = history.getLastTick(this.instrument).getAsk() - getPipPrice(this.takeProfitPips);
        }

        // Submitting an order for the specified instrument at the current market price
        return engine.submitOrder(getLabel(instrument), this.instrument, orderCmd, this.amount, 0, 20, stopLossPrice, takeProfitPrice);
    }

    protected String getLabel(Instrument instrument) {
        String label = instrument.name();
        label = label + (counter++);
        label = label.toUpperCase();
        return label;
    }

    private double getPipPrice(int pips) {
        return pips * this.instrument.getPipValue();
    }

}

PresetPanel is this,
Image

But, If I use this way,
I have to add some line to each strategy file.
If I could use preferences easily by jforex tool, Then I can choose the strategy file in flexibly.
like this..
Image

thanks,


Attachments:
PresetPanel2.JPG [30.09 KiB]
Downloaded 477 times
PresetPanel.JPG [29.96 KiB]
Downloaded 467 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: showPresetDialog() Post rating: 0   New post Posted: Thu 05 Dec, 2013, 15:02 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The parameter dialog is part of the platform, if you wish to have a GUI to modify the parameters and presets from the JForex-SDK, then you need to build a dialog on your own, see example:
https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=42104&p=65211#p65211


 
 Post subject: Re: showPresetDialog() Post rating: 0   New post Posted: Wed 11 Dec, 2013, 12:51 
User avatar

User rating: 7
Joined: Tue 28 Feb, 2012, 09:45
Posts: 45
Location: JapanJapan
Thanks, I got it...


Attachments:
MyPresetSetterTest.java [7.5 KiB]
Downloaded 254 times
MyPresetSetterTest.java [7.5 KiB]
Downloaded 261 times
MyPresetSetterTest.java [7.5 KiB]
Downloaded 256 times
MyPresetSetterTest.jfx [164.81 KiB]
Downloaded 261 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.
 

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