Live: ExecuteMarketOrder() Opens TWO positions!!

Created at 17 Sep 2019, 02:08
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CA

Cam_maC

Joined 16.08.2017

Live: ExecuteMarketOrder() Opens TWO positions!!
17 Sep 2019, 02:08


Hello,

I have been backtesting my robot for a long time with no problems, I use it live for one day and its opening two positions of the same size.

My OnBar() logic is very simple with no "For" loops so I cant see how it opens two positions!

ExecuteMarketOrder(TradeType.Buy, this.SymbolName, volume, InstanceName, SL, TP);

Even the Journal doesnt show anything about two positions being opened.

17/09/2019 03:00:14.310 | → Request to Buy 0.50 Lot(s) Bitcoin (SL: 2500) is ACCEPTED, order OID41503458 created (16/09/2019 17:00:14.026 UTC+0)
17/09/2019 03:00:14.419 | → Order OID41503458 is FILLED at 10146.92, position PID25230692 (16/09/2019 17:00:14.127 UTC+0)
17/09/2019 03:00:13.716 | → Order OID41503452 is FILLED at 10146.92, position PID25226124 CLOSED (16/09/2019 17:00:13.556 UTC+0) ## Closing my old position ##
17/09/2019 03:00:13.419 | Request to close position PID25226124 is sent to server
17/09/2019 03:00:13.873 | Request to Buy 0.50 Lot(s) Bitcoin (SL: 2500) is sent to server

But I now have two positions open:

Position: PID25230692 and PID25230691


@Cam_maC
Replies

PanagiotisCharalampous
17 Sep 2019, 07:59

Hi Cam_maC,

Can you share the cBot code so that we can have a look?

Best Regards,

Panagiotis


@PanagiotisCharalampous

Cam_maC
17 Sep 2019, 08:37

Hi Panagiotis,

I figured it out.

Helps if you dont have two copies of the robot running.

Hope that puts a smile on your face :-)

Thanks


@Cam_maC