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.

Trade manager for jforex
 Post subject: Trade manager for jforex Post rating: 0   New post Posted: Sat 10 Dec, 2011, 18:39 

User rating: 0
Joined: Sat 10 Dec, 2011, 18:30
Posts: 1
Location: GB
Hi guys, sorry for the disturb. I was always using mt4for trading, but a while ago, im placing my trades with my jforex platform. i just like it... but im looking for a simple strategy, that can work as a simple trade manager. Im not good at all in java progr. im just a trader. so what im looking it... the trade man. needs to include:
@@@i would like to add a nr, that will represent the risk, than i would like to have a sp.for the Sl pipps, and the strategy needs to calc. the lot size, that the trade will be executed. example.: Sl 10 risk percentage:2 in this case lets say, the balance its 1000$,then then the lot will be 0.002<it means,that i can risk with the 10pips 20$>
@@@posibility for adding a trailing st.
@@@option to set with a click the pos.to BE
@@@scale out 50%of the position, when the trade reaches an xammount of pipps...

Somebody knows similar trade managers? or somebody can help.me how can i cr. a simple man. like this one. the imp things, are above.. that autom. position calc. its the most important aspect for me.

Thank u very much guys! i read a lot about dukascopy.. so keep it like this....

have a great day!

>>and GL with the trades! 8-)


 
 Post subject: Re: Trade manager for jforex Post rating: 0   New post Posted: Tue 13 Dec, 2011, 10:45 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Quote:
@@@i would like to add a nr, that will represent the risk, than i would like to have a sp.for the Sl pipps, and the strategy needs to calc. the lot size, that the trade will be executed. example.: Sl 10 risk percentage:2 in this case lets say, the balance its 1000$,then then the lot will be 0.002<it means,that i can risk with the 10pips 20$>

Here is sample code to compute the lot:
import com.dukascopy.api.*;

public class GetLotStrat implements IStrategy {

    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
   
    @Configurable("risk in percent")
    public int risk = 2;

    public void onStart(IContext context) throws JFException {       
        IAccount account = context.getAccount();
        if(risk < 1 || risk > 100) {
            throw new JFException("Invalid risk value: "+risk);
        }
       
        double lot = account.getEquity() * account.getLeverage() * risk / 100;
        lot = lot / 1000000; // convert to millions
       
        context.getConsole().getOut().println(lot);
    }

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


Quote:
@@@posibility for adding a trailing st

There is a strategy that updates stop loss price. Please see the following forum topic:
viewtopic.php?f=65&t=42122&hilit=update+stop+loss

note that it is possible to iterate orders using the following code:
for (IOrder order : engine.getOrders(instrument)) {
   if (order.getState() == IOrder.State.FILLED) {
      ...
   }
}


Quote:
@@@option to set with a click the pos.to BE

Here is a topic where break even strategy is discussed:
viewtopic.php?f=65&t=44322&hilit=filled

Quote:
@@@scale out 50%of the position, when the trade reaches an xammount of pipps...

This code may be useful for that:
viewtopic.php?f=65&t=12283&p=16486&hilit=+partial+close+#p16486


Attachments:
GetLotStrat.java [1.15 KiB]
Downloaded 284 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-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