I am a little puzzled with the results I got today coding a trading filter using the Swing indicator. This is the very simple code (now it only prints, since I tested so many things):
const int STRENGTH = 20;
const int LOOPBACKBARS = 500;
int swingBarAgo = 0;
var loopbackBars = CurrentBar > LOOPBACKBARS ? LOOPBACKBARS : CurrentBar - 1;
int n = 0;
do
{
n++;
swingBarAgo = Swing(STRENGTH).SwingHighBar(0, n, loopbackBars);
if (swingBarAgo != -1)
{
Print(this, "OrderGenerator.FilterIfSwingUnviolated :: " + n + ": Swing at Bar " + (CurrentBar - swingBarAgo) + ". Price: " + High[swingBarAgo]);
}
} while (swingBarAgo != -1);
In this log example:
TradeSize: 27. Current StopLoss (ticks): 72.9607085548763 In Substate SignalFound :: Condition evaluated :TradeConditionsMet OrderGenerator.FilterIfSwingUnviolated :: 1: Swing at Bar 10533. Price: 4584.75 OrderGenerator.FilterIfSwingUnviolated :: 2: Swing at Bar 10495. Price: 4586 OrderGenerator.FilterIfSwingUnviolated :: 3: Swing at Bar 10461. Price: 4589 OrderGenerator.FilterIfSwingUnviolated :: 4: Swing at Bar 10424. Price: 4594.25 OrderGenerator.FilterIfSwingUnviolated :: 5: Swing at Bar 10277. Price: 4559 OrderGenerator.FilterIfSwingUnviolated :: 6: Swing at Bar 10239. Price: 4551.25 OrderGenerator.FilterIfSwingUnviolated :: 7: Swing at Bar 10205. Price: 4548.5 OrderGenerator.FilterIfSwingUnviolated :: 8: Swing at Bar 10168. Price: 4542.25 ...
Am I using the indicator wrong, any declaration missing? Has something changed in this indicator or its code recently? I used it in the past with no issues.
Thanks so much.

Comment