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.

need help using the six callback methods
 Post subject: need help using the six callback methods Post rating: 0   New post Posted: Tue 23 May, 2017, 23:27 
User avatar

User rating: 1
Joined: Tue 24 Feb, 2015, 22:29
Posts: 15
Location: Egypt, Cairo
Hi
I am new to coding jforex & java
my question is very simple
there are six interface methods : onStart , onTick ,onBar ,onMessage ,onAccount ,onStop
how to use information that belongs to one of these sex methods inside another method ?
for example : If I am inside onStart or inside onMessage method and I want to send buy order whose amount depends on equity ,how can I use account.getEquity() which belongs to onAccount method when I am inside onStart or inside onMessage method?
I hope someone reply me
thanks


 
 Post subject: Re: need help using the six callback methods Post rating: 0   New post Posted: Wed 24 May, 2017, 07:18 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
IAccount that is passed into IStrotegy.onAccount() is the same object that can be retrieved from context.getAccount(). context.getAccount() can be saved into strategy`s class and then it can be used from any method.
public class StrategyA implements IStrategy {
   
    private IAccount account;
   
    public void onStart(IContext context) throws JFException {       
        this.account = context.getAccount();
    }

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


 
 Post subject: Re: need help using the six callback methods Post rating: 0   New post Posted: Wed 24 May, 2017, 11:59 
User avatar

User rating: 1
Joined: Tue 24 Feb, 2015, 22:29
Posts: 15
Location: Egypt, Cairo
it works :D
thank you very very very very very very very very very very very very very very very very very very very very very very very very very very very much :lol: :lol:


 

Jump to:  

  © 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