I would write in a .txt file the profit/loss of all my current opened orders. How can I do this?
Thanks
[Phantal]
Post subject: Re: Profit/loss of opened orders
Post rating: 0
Posted: Thu 03 Jun, 2010, 20:03
User rating: 0
Joined: Fri 07 May, 2010, 02:59 Posts: 61
1) Look at Java's BufferedWriter class for doing the file I/O. 2) Figure out how to calculate the profit/loss of an order. It will look something like this:
Quote:
sign(direction) * (current price - entry price) * (total volume of order including leverage)
... where sign(direction) = +1 for long/buy, and -1 for short/sell 3) Write your result from the 2nd step to the file from the 1st step
Thanks, but I am a newbie in java language so... I saw this method in IOrder Class of JForex api: getProfitLossInAccountCurrency() Maybe it can help, but I don't know how to write the code
Concerning writing in a file, I have already implement this code (to write the equity) :
public void onAccount(IAccount account) throws JFException { this.account = account; this.equity = account.getEquity(); // Stream to write file FileOutputStream fout;
try { // Open an output stream fout = new FileOutputStream ("C:\\Program Files\\MetaTrader - Alpari UK\\experts\\files\\equity.txt");
// Print a line of text new PrintStream(fout).println (this.equity);
// Close our output stream fout.close(); } // Catches any error conditions catch (IOException e) { System.err.println ("Unable to write to file"); System.exit(-1); } }
It works well, but now I would like to write the Profit/loss in another file. If someone could write the code for me... thanks
[Phantal]
Post subject: Re: Profit/loss of opened orders
Post rating: 0
Posted: Sat 05 Jun, 2010, 00:45
User rating: 0
Joined: Fri 07 May, 2010, 02:59 Posts: 61
You should look at the Advertisement section and see if you can contract someone to do it for you, instead of asking someone to do your programming for free.