But the lists have identical fields and content except for their status, Bull, Bear, Open, Closed
I have the following named lists:
BullOpenGaps
BearOpenGaps
BullClosedGaps
BearClosedGaps
the reason I separate them into Bull and Bear is because the formula is different for the values I store in the list.
The reason I separate into Open and Closed is that I need to search the Open lists frequently to determine trade status and update fields. If I only have 1 list for Open & Closed, I would have to search a very large list just to find the few Open gaps to evaluate.
But the separate lists work great. It's only a problem with the extra code I need to Render the gaps
When I go to render them, I have to make the same method call 4 times, passing the same information to the render method. This is what the code looks like.
for (int x = BullGapsOpen.Count - 1; x >= 0 ; x--)
RenderFVG(BULL,
chartControl.GetXByTime(BullGapsOpen[x].startTime),
chartScale.GetYByValue(BullGapsOpen[x].top),
chartControl.GetXByTime(BullGapsOpen[x].endTime) - chartControl.GetXByTime(BullGapsOpen[x].startTime) + 2 * pad,
(int)chartScale.GetPixelsForDistance(BullGapsOpen[x].height),
BullGapsOpen[x].border, BullGapsOpen[x].period);
Is there any way to loop through the list, but substitute the List Name in each of the places where I use it....
like it I could had a variable "listName", I could
listName = BullGapsOpen.
for (int x = listName.Count - 1; x >= 0 ; x--)
RenderFVG(BULL,
chartControl.GetXByTime(listName[x].startTime),
chartScale.GetYByValue(listName[x].top),
chartControl.GetXByTime(listName[x].endTime) - chartControl.GetXByTime(listName[x].startTime) + 2 * pad,
(int)chartScale.GetPixelsForDistance(listName[x].height),
listName[x].border, listName[x].period);
is there any way to do this?

Comment