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.

Strategy for Specific UserName
 Post subject: Strategy for Specific UserName Post rating: 0   New post Posted: Mon 14 Apr, 2014, 05:15 
User avatar

User rating: 1
Joined: Sun 09 Feb, 2014, 14:42
Posts: 15
Location: Indonesia, Bandung
Hello. I am trying to make strategy that only run on specific username. I try this code :
package jforex;

import java.util.*;

import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;
import com.dukascopy.api.IIndicators.AppliedPrice;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IAccount.AccountState;

public class Tes2 implements IStrategy {
    private IAccount account;
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
   
    private String User;
   
    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 {
        account = context.getAccount();
        User = "DEMO10037gQxAbEU";
        if (account.getUserName() == User) {
            console.getOut().println("Strategy Run");
        } else {
            console.getOut().println("This Strategy doesn't belong to this account");
            context.stop();
        }
    }

    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 {
    }
}


But the strategy stops although User == account.getUserName(). Can anyone help me?
Thank you


 
 Post subject: Re: Strategy for Specific UserName Post rating: 0   New post Posted: Mon 28 Apr, 2014, 07:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please continue at the already existing topic for this subject:
https://www-cl.site.dukascopy.com/swiss/ ... als#p78908


 
 Post subject: Re: Strategy for Specific UserName Post rating: 0   New post Posted: Mon 28 Apr, 2014, 09:52 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
hargun wrote:
But the strategy stops although User == account.getUserName(). Can anyone help me?
Thank you
Try this approach
account.getUserName().equals(User)


 
 Post subject: Re: Strategy for Specific UserName Post rating: 0   New post Posted: Mon 09 Jun, 2014, 13:24 
User avatar

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


 

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