I want to include Choppiness Index indicator as a part of entry criteria. The error happens in Strategy Analyzer window, when I choose Optimize: ChoppinessEBool. It gives correct results, when it is set to TRUE, and gives 0's (0 trades, 0 profit/loss) when it is set to FALSE.
I will paste my formulas here, so you could maybe help me with an error.
_____________________________________________
public class AI_ADX_200807_O : Strategy
private bool ChoppinessEBool = false,
_____________________________________________
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
ChpE = false; // Choppiness Index: Entry- Boolean.
ChoppinessPeriodE = 2; // Choppiness Index: Entry- Period.
ChoppinessTE = 80; // Choppiness Index: Entry- To (Highest Value).
_______________________________________________
protected override void OnBarUpdate()
{
ChoppinessEBool = (((ChpE && ChoppinessIndex(ChoppinessPeriodE)[0] < ChoppinessTE)) ? true : false);
if (CrossAbove(ADX(Period), Trend, 1)
&& ADX(Period)[0] < ADXMax
&& Close[0] > SMA(Close, MAB)[0] && ChoppinessEBool)
{
EnterLong();
}
_________________________________________________
As I said, it works fine, when Optimization is set to TRUE, but when it's set to FALSE, it returns 0 trades. And I want it to work as 'it supposed to' - Ignore Choppiness indicator, so I could compare which method - with or without indicator - performs better.
Comment