above is a snippet of my code that's been giving days of issues, seemingly something happened between the 14th and 16th.
I'm hedging. In the instance where: position ticket 1 is buy and position ticket 2 is sell , I would expect to catch the DebugBreak() on ticket #2. But my structure is only returning a POSITION_TYPE_BUY no matter what. I thought this was an issue with the structure, but I can see the other variables in that structure change as well, just not pos.Side or anything depending on that var.
I tried declaring it to it's own variable and its the same deal, it will always return POSITION_TYPE_BUY for both.
I was using CPositionInfo for a while but when I noticed this bug, I saw that it would return some odd unknown error and not the expected POSITION_TYPE_SELL
Even the Intergers being returned aren't the expected 1 and 0.
I've initialized my struct PositionData pos; inside all 3 scopes to no effect. Which doesn't seem to matter because it seems PositionGetInteger(POSITION_TYPE) doesn't seem to be returning anything new.
for(int i = PositionsTotal() - 1; i >= 0; i--) { ulong ticket = PositionGetTicket(i); if(PositionSelectByTicket(ticket)) { //....a lot of position info storing before.... if(PositionSelectByTicket(ticket)) pos.Side = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE); ENUM_POSITION_TYPE side = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE); if(pos.Side != POSITION_TYPE_BUY) DebugBreak(); //....a lot of logic after.... } }Ended up just having it called twice to double check the information was up to date. I'm pretty sure this isn't the answer, but it works.
The problem I was having is I had several nested loops that also cycle through the positions to pull a metric.
Solution. Make sure I make all my PositionGet Calls before any of those other nested loops.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
above is a snippet of my code that's been giving days of issues, seemingly something happened between the 14th and 16th.
I'm hedging. In the instance where: position ticket 1 is buy and position ticket 2 is sell , I would expect to catch the DebugBreak() on ticket #2. But my structure is only returning a POSITION_TYPE_BUY no matter what. I thought this was an issue with the structure, but I can see the other variables in that structure change as well, just not pos.Side or anything depending on that var.
I tried declaring it to it's own variable and its the same deal, it will always return POSITION_TYPE_BUY for both.
I was using CPositionInfo for a while but when I noticed this bug, I saw that it would return some odd unknown error and not the expected POSITION_TYPE_SELL
Even the Intergers being returned aren't the expected 1 and 0.