Fibonacci Retracement Entry
Demonstrates the FiboRetracementEntry class by assigning swing high/low from the previous bar in OnPositionOpenFilter. This is a strategy subclass (not MZpackStrategyBase) — it must be used with a MZpackStrategyBase host that configures entries with FiboRetracementEntry objects.
Source: [INSTALL PATH]/API/Samples/FiboRetracementEntry.cs
Class: FiboRetracementEntryStrategy : MZpack.NT8.Algo.Strategy
What It Covers
- Subclass of
Algo.Strategy(notMZpackStrategyBase) OnPositionOpenFilteroverride to setFiboRetracementEntryswing levels- Uses previous bar's High/Low as swing for Fibonacci retracement calculation
Source Code
public class FiboRetracementEntryStrategy : MZpack.NT8.Algo.Strategy
{
public FiboRetracementEntryStrategy(string name, MZpackStrategyBase strategy)
: base(name, strategy) { }
public override bool OnPositionOpenFilter(DateTime time)
{
MZpack.NT8.Algo.Position position = Positions.FirstOrDefault();
if (position != null)
{
foreach (var e in position.Entries)
{
if (e is FiboRetracementEntry)
{
((FiboRetracementEntry)e).SwingHigh = MZpackStrategy.Highs[0][1];
((FiboRetracementEntry)e).SwingLow = MZpackStrategy.Lows[0][1];
}
}
return true;
}
return false;
}
}
Key Points
FiboRetracementEntryrequires swing levels to calculate retracement entry pricesOnPositionOpenFilterfires before position opens — the ideal place to set dynamic swing levelsHighs[0][1]andLows[0][1]reference the previous bar (1 bar ago) for on-bar-close strategies
See Also
- Algo.Strategy — strategy base class
- Entry — entry types
- Working with Samples — how to compile samples