I have a bunch of cases in a switch. I need the code to stay in one case at a time until a specific criteria is met, then I want to tell it which case to go to. I currently have the case going to itself, this does not cause an error, but it does cause the program I'm using to continuously load and never execute.
The criteria I need met is the bool statement 'activated', and until it is I would like the code to remain in the case.
There is a lot of code missing so it may not make sense, but I would like to know if there is better way to do this.
Also, before you ask, I am still a beginner and I know everyone hates goto statements. If you can propose an alternate, I will listen.
Thank you wise ones.
if(CurrentPosition.Value != 0){
switch(location)
{
case 0:
if(criteria1 && criteria2)
{
LimitLongsPT.Send(S1 + ((R1 - S1) * BuffZone));
LongStopSA.Send(S1 - StopAmount);
ShortStopDeep.Send(R1 + StopAmount);
TradeManager.ProcessEvents();
if(activated == true)
{
if(PublicFunctions.DoubleEquals(CurrentPosition.Value, 0))
{
break;
}
if(PublicFunctions.DoubleLess(CurrentPosition.Value, 0))
{
if(PublicFunctions.DoubleGreater(MP[0], S1) && PublicFunctions.DoubleLess(MP[0], R1))
{
goto case 15;
}
if(PublicFunctions.DoubleGreater(MP[0], R1) && PublicFunctions.DoubleLess(MP[0], R2))
{
goto case 16;
}
if(PublicFunctions.DoubleGreater(MP[0], S2) && PublicFunctions.DoubleLess(MP[0], S1))
{
goto case 23;
}
}
if(PublicFunctions.DoubleGreater(CurrentPosition.Value, 0))
{
if(PublicFunctions.DoubleGreater(MP[0], R1) && PublicFunctions.DoubleLess(MP[0], R2))
{
goto case 1;
}
}
}
}
**goto case 0;**
case 1:
if(PublicFunctions.DoubleGreater(CurrentPosition.Value, 0) && PublicFunctions.DoubleGreater(MP[0], R1) && PublicFunctions.DoubleLess(MP[0], R2))
{