I want to create a crossover where period 1 (P1) is always smaller than the second one. To get this I thought I could simply add P1 and P2 for the second value.
For example: If P1 is 5 and P2 is 3 I would create a cross of 5 and 8.
Somehow my code does not work. The addition does not work.
How do I fix it?
protected override void Initialize() { Add(SMA(P1)); Add(SMA(P2)); CalculateOnBarClose = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (CrossAbove(SMA(P1), SMA(P1+P2), 1)) { EnterLong(DefaultQuantity, ""); } // Condition set 2 if (CrossBelow(SMA(P1), SMA(P1+P2), 1)) { EnterShort(DefaultQuantity, ""); } }
Comment