I have a C# question, which I can find too much info about to understand it right to use it properly: arrays. As I'm no C# prodigy, I mainly learn from looking at existing code after which I try and alter it for my own use. Up till now with success, but I come to a point where I think my code could use optimization because loads of recurring lines of code are being used, while the same could probably coded more efficient and profesionally. I hope some of you might help me in the right direction.
In my code I have the following lines for example:
Under Variables I have:
private IOrder enterOrderPOPH = null;
private IOrder enterOrderPOPC = null;
private IOrder enterOrderPOCO = null;
private IOrder enterOrderPOCH = null;
and so another 358 (really...)
Later under OnBarUpdate after some trigger:
if (enterOrderPOPC != null) {CancelOrder(enterOrderPOPC); enterOrderPOPC = null; exitOrderPOPC = null; filledOrderPOPC = 0;}
if (enterOrderPOPH != null) {CancelOrder(enterOrderPOPH); enterOrderPOPH = null; exitOrderPOPH = null; filledOrderPOPH = 0;}
if (enterOrderPOCO != null) {CancelOrder(enterOrderPOCO); enterOrderPOCO = null; exitOrderPOCO = null; filledOrderPOCO = 0;}
if (enterOrderPOCH != null) {CancelOrder(enterOrderPOCH); enterOrderPOCH = null; exitOrderPOCH = null; filledOrderPOCH = 0;}
and again 358 other variations on the above.
There should be a more intelligent way than mine to have these 362 lines of if's checked and possibly executed without having to state all the variations literally. The only deviations between the lines are the letters like "POPC", which give each order it's unique key so I can trace them on the order updates and executions.
When looking online and the NT support forum, I come back to arrays again and again, without really understand how to bend this into a usable form whivh suits my enormous amount of lines in the code. And these 362 line are coming back several times, like on entering, exiting, checking on fills etc.
I hope you could get me along in tackling this RAM eating beast as it is right now.
Kind regards,
Francis

Comment