Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

how to get margin required,and how to get total order count?
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=81&t=50886
Page 1 of 1

Author:  Moggy [ Sat 08 Mar, 2014, 10:54 ]
Post subject:  how to get margin required,and how to get total order count?

i am 6 month old in MT4 but new in jforex,please kindly help me if you know the answers.
question 1:
how to get margin required per 1.0 lots for the current instrument and leverage?
is there some function like MarketInfo in MT4?
double marginrequired = MarketInfo(Symbol(),MODE_MARGINREQUIRED);
i have search a lot,but didn't find any function yet:(
question 2:
how to get total order count?
now i write a function:
private int getInstrumentTotalOrders(Instrument instrument)
throws JFException {
int localcount = 0;
List<IOrder> locallist = myengine.getOrders();
for (IOrder localorder : locallist) {
if (localorder.getInstrument().equals(instrument)) {
localcount++;
}
}
return localcount;
}
is there any simple way to get it?
Thanks in advance
Best Regards

Author:  Moggy [ Sun 30 Mar, 2014, 03:07 ]
Post subject:  Re: how to get margin required,and how to get total order count?

my solutions:

question one:
double PipValue = myinstrument.getPipValue();
double Ask = tick.getAsk();
private double getMarginRequired(Instrument instrument) throws JFException {
JFUtils localutils = mycontext.getUtils();
double pipvalueincurr = localutils.convertPipToCurrency(instrument,
myaccount.getCurrency());
return ((Ask / PipValue) * 1000000 * pipvalueincurr / myaccount
.getLeverage());
}

question two:
use the getOrders(Instrument) and count the total num.
myengine.getOrders(myinstrument);

if someone get better way,please kindly inform me.

  Page 1 of 1