My algo is made to work on CFDs with the FXCM broker.
I have read the NT / Fxcm disclaimer about the states of the orders when there is disconnections.
I have salso see in the logs that there is some disconnections on my server and that it's written :Strategy 'myStrategy' lost price connection but will keeep running and the same with lost order connection.
As i want my strategy to be fully automated i have few questions about how to manage these cases.
In my strategy, the orders are submited with a tag to identify them like that :
EnterLongLimit(2, true, positionSize, C_target_price, "BoX_ORDER");
SetStopLoss("BoX_ORDER", CalculationMode.Pips, C_SL_Size , false);
SetProfitTarget("BoX_ORDER", CalculationMode.Pips, (C_SL_Size * riskReward));
Then In the function OnOrderUpdate() i retrieve the order with it's name and it's state (submited or working and filled) and assign it to a variable.
Then i use this variable (the order) in the function OnBarUpdate() to manage the active order.
For exemple I use myOrder.Time.AddHours(96) to set an expiration and to cancel the order with CancelOrder(myOrder) after 4 days if it have not been filled.
And also use in a variable an integer with the trade bar index when the order is filled to check conditions with the active order from this bar index.
When certain conditions are meeted i will use SL order modification like this :
SetStopLoss("BoX_ORDER", CalculationMode.Price, entryOrder.AverageFillPrice, false);
Everything works fine on backtests as there is no disconnections, but i want to prevent the problems that can happends in real time.
For that i would like to ask the community :
In the case of a disconnection and a re connection, will the algo will be able to identify the order by it's name (the tag) to manage it correctly ?
It seems that in some cases the strategy is restarted automaticly after long disconnections, in this case will the algo will be able to identify the orders to manage them and did the variable that was stored with the integer of the trade bar index at the moment that the order is filled will logically be lost (as restart meens variable get re intitialized)?
Also, is there is a way to write in the code instructions to disconnect then reconnect if the connection is no more active since a certain time, because it happends a few times that the connection status stay on red for long time ?
Also, is it a good idea to store the tradeId given by the broker to identify the active orders after disconnections, or to store this id in a flie with C# to retreive the orders after disconnections ?
Thanks a lot for the help
Roman
Comment