You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, I am trying to get current market position(nr. of lots and direction) like this :
int OpenPosQTY()
{
int cnt = 0; int lots = 0;
for (int ic = OrdersTotal() - 1; ic >= 0; ic--)
{
OrderSelect(ic, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol())
{
if (OrderType() == OP_BUY) cnt++;
if (OrderType() == OP_SELL) cnt--;
lots = OrderLots() ;
}
}
Print("OPEN POSITION :", DoubleToStr(cnt *lots,6) );
return (cnt*lots);
}
Problem is that the variable is updated very late - seconds after a trade happens... I guess that is due to the fact that it recalculates with every new tick.... I need it to be instantly as I want to forward this change to an externall app. which will trade on other API.
Any idea how could this be done?