Dukascopy
 
 
Wiki JStore Search Login

how to get margin required,and how to get total order count?
 Post subject: how to get margin required,and how to get total order count? Post rating: 0   New post Posted: Sat 08 Mar, 2014, 10:54 
User avatar

User rating: 1
Joined: Tue 27 Aug, 2013, 17:39
Posts: 26
Location: China, Shanghai
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


 
 Post subject: Re: how to get margin required,and how to get total order count? Post rating: 0   New post Posted: Sun 30 Mar, 2014, 03:07 
User avatar

User rating: 1
Joined: Tue 27 Aug, 2013, 17:39
Posts: 26
Location: China, Shanghai
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.


 

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