FLX8
- ago
I am attempting to observe whether a Symbol with a Open Postion was acknowledged each Execute loop to determine if there is gaps in the data.

I am probably not approaching this with best practice, and I am open to alternative suggestions because this is a bit of a headache.

In PreExecute I am a assigning a list of open Postions from OpenPositionsAllSymbols to the variable "manage".
In Execute, every time the symbol has been acknowledged, I remove that Position from "manage" List.
In PostExecute, if "manage" still has a Count > 0, I am deducing that there was not a BarHistory object pertaining to that symbol that was fed to the main loop.

I think my issue stems from my I assigning manage to OpenPositionsAllSymbols, and it is not a clone. I cannot find any understable way to cloning a List if it is not a List of Primitive types.

Any suggestions on how I can approach this?

CODE:
PreExecute() { manage = OpenPositionsAllSymbols; } Execute(BarHistory bars, int idx) { Position p = LastPosition; if (manage.Exists(x => x.Bars == bars) { // HOLD or CLOSE manage.Remove(p); } } PostExecute() { if (manage.Count > 0) {             File.AppendAllText(target, $"\n\nRunaway Trades: ({manage.Count})");             foreach (Position p in manage) {                File.AppendAllText(target, $"\n\t{p.Bars.Symbol}");             } } }
0
546
Solved
1 Replies

Reply

Bookmark

Sort
FLX8
- ago
#1
nevermind, I got it working by adding:
CODE:
PreExecute() { selections.Clear(); foreach (Position p in OpenPositionsAllSymbols) {       selections.Add(p.Bars); } }


and managing the positions from there
0
Best Answer

Reply

Bookmark

Sort