I am using an IB paper trading account to test this on EURUSD.
The pseudo-strategy I am using does generate trades correctly but the MarketPosition_At_Broker is always 0.
I am using the print command to watch MarketPosition and MarketPosition_At_Broker.
This is the kind of data I get in the output window:
Code: Select all
1/5/2010 9:36:15 AM : MarketPosition_at_Broker = 0
1/5/2010 9:36:15 AM : MarketPosition = -1
1/5/2010 9:38:00 AM : MarketPosition_at_Broker = 0
1/5/2010 9:38:00 AM : MarketPosition = -1
1/5/2010 9:40:05 AM : MarketPosition_at_Broker = 0
1/5/2010 9:40:05 AM : MarketPosition = -1
1/5/2010 9:42:01 AM : MarketPosition_at_Broker = 0
1/5/2010 9:42:01 AM : MarketPosition = -1
1/5/2010 9:44:03 AM : MarketPosition_at_Broker = 0
1/5/2010 9:44:03 AM : MarketPosition = 0
As you can see a trade does take place correctly and MC correctly calculates the position internally but the position at the broker is never updated.
This is the pseudo-strategy I am using:
Code: Select all
value1 = AverageFC( C, 9 ) ;
if C > var0 and C < value1 then Buy next bar market;
if C < var0 and C > value1 then sellshort next bar market;
if marketposition = -1 and C > value1 then buytocover next bar market;
if marketposition = 1 and C < value1 then sell next bar market;
print(datetimetostring(computerdatetime) + " : MarketPosition_at_Broker = " + NumToStr(MarketPosition_at_Broker,0));
print(datetimetostring(computerdatetime) + " : MarketPosition = " + NumToStr(MarketPosition,0));
The reason I need to have a correct indication of the actual position at the Broker is simple yet crucial. No matter how good MC is, there are always connection problems possibly resulting to errors. One simple way to manage these errors would be to compare the internally calculated position to the actual one and take action accordingly.
With MarketPosition_At_Broker always equal to 0 there is no way to write some failsafes that imo are necessary.
Is this is a bug of some sort or is it because of the paper-trading account I am using to test it?.
Can anyone please confirm the correct function of MarketPosition_At_Broker with a real account?