You have
public void SuperSignalQ1()
and later on you have
if (SuperSignalQ1 = True)
This if statement is broken.
In c#, you test with the double equals:
if (someVariable == true)
What you’ve got is an assignment statement, because there’s one equals sign.
You’re also missing some brackets, so C# thinks you are referring to it as a variable instead of a method.
So it thinks you are trying to assign a value of True
to the method pointer. Which it quite rightly complains about.
It looks like you actually want those methods to return a boolean value, and you could do something like this:
public bool SuperSignalQ1()
{
if(RSI > RSI2)
{
if(CCI > CCI2) //There are actually more than 20 if else here which is around 1000 lines
{
return true;
}
}
return false; // if none of the conditions are valid
}
public bool SuperSignalQ2()
{
if(RSI2 > RSI3)
{
if(CCI2 > CCI3) //There are actually more than 20 if else here which is around 1000 lines
{
return true;
}
}
return false; // if none of the conditions are valid
}
public bool SuperSignalQ3()
{
if(RSI3 > RSI4)
{
if(CCI3 > CCI4) //There are actually more than 20 if else here which is around 1000 lines
{
return true;
}
}
}
public void MainCalculation()
{
if (SuperSignalQ1() == true)
{
if(SuperSignalQ2() == true)
{
if (SuperSignalQ3() == true)
{
SetColor(Color.White);
}
}
}
}
BUT
- For boolean, you don’t usually use the
==
format, you’d just goif (SuperSignalQ1())
- As @aether643 suggested, you might want to refactor your code so you don’t have such a long chunk of code without mental breaks
- In C#, you can actually do assignments in
if
tests. Don’t do that.
CLICK HERE to find out more related problems solutions.