please add a compile warning
Posted: Jun 01 2024
Please add a compiler warning for the following scenario: I forgot to define the IInstrument Bars, unfortunately the compiler doesn't issue a warning, the code just doesn't compile. You can test this in the following simple code excerpt by simply removing or including the excluded IInstrument in the class (currently excluded/commented)
Code: Select all
private class BarTypBestimmerxx
{
private enum BarTyp { AufwärtsBar, AbwärtsBar, InnenBar, AußenBar }
public SignalObject strategie;
public BarTyp aktuellerBarTyp;
public VariableObject<BarTyp> barTyp;
// private IInstrument Bars;
public BarTypBestimmerxx(SignalObject strategy /*IInstrument bars*/)
{//
//_strategie = strategy;
//_Bars = bars;
barTyp = new VariableObject<BarTyp>(strategy);
}
private void BestimmeBarTyp()
{
if (Bars.High[1] < Bars.HighValue && Bars.Low[1] <= Bars.LowValue)
{
aktuellerBarTyp = BarTyp.AufwärtsBar;
}
else if (Bars.High[1] >= Bars.HighValue && Bars.Low[1] > Bars.LowValue)
{
aktuellerBarTyp = BarTyp.AbwärtsBar;
}
else if (Bars.High[1] >= Bars.HighValue && Bars.Low[1] <= Bars.LowValue)
{
aktuellerBarTyp = BarTyp.InnenBar;
}
else if (Bars.High[1] < Bars.HighValue && Bars.Low[1] > Bars.LowValue)
{
aktuellerBarTyp = BarTyp.AußenBar;
}
}
public bool AufwärtsBar
{
get { return aktuellerBarTyp == BarTyp.AufwärtsBar; }
}
public bool AbwärtsBar
{
get { return aktuellerBarTyp == BarTyp.AbwärtsBar; }
}
public bool InnenBar
{
get { return aktuellerBarTyp == BarTyp.InnenBar; }
}
public bool AußenBar
{
get { return aktuellerBarTyp == BarTyp.AußenBar; }
}
}
private void M_BestimmeBarTyp()
{
if (Bars.High[1] < Bars.HighValue && Bars.Low[1] <= Bars.LowValue)
{
barTyp.Value = BarTyp.AufwärtsBar;
}
else if (Bars.High[1] >= Bars.HighValue && Bars.Low[1] > Bars.LowValue)
{
barTyp.Value = BarTyp.AbwärtsBar;
}
else if (Bars.High[1] >= Bars.HighValue && Bars.Low[1] <= Bars.LowValue)
{
barTyp.Value = BarTyp.InnenBar;
}
else if (Bars.High[1] < Bars.HighValue && Bars.Low[1] > Bars.LowValue)
{
barTyp.Value = BarTyp.AußenBar;
}
}