I would like to know if the following public indicator (TcFAutoFibos - NinjaTrader Ecosystem - thanks @Xusto91 !) could be extended or modified to create a plot/signal when price retraces to a certain ratio level of the MIN/MAX range? Using the fib drawing tool is not a must, though a nice to keep for visuals.
Example pseudo code for a retracement in an uptrend market - ratio can be 0.5, 0.618, etc
if highest_swing_time > lowest_swing_time:
(max_level - (max_level-min_level)*ratio)
Example pseudo code for retracement in a downtrend market - ratio can be 0.5, 0.618, etc
if highest_swing_time < lowest_swing_time:
(min_level + (max_level-min_level)*ratio)
Right now the indicator draws an autofib looking back N period (Strength param), but does not generate plots or signals for retracement levels. In the end the idea would be to think of a strategy leveraging those signals.
Code excerpt
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Automatically draw fibonacci retracements from swing highs and lows in the market.";
Name = "TcFAutoFibos";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
Strength = 20;
}
else if (State == State.Configure)
{
min=MIN(Low,Strength);
max=MAX(High,Strength);
}
}
protected override void OnBarUpdate()
{
if (CurrentBar<Strength)
return;
if (High[0]>max[1])
barsSinceHigh=0;
else if (barsSinceHigh>-1 && IsFirstTickOfBar)
barsSinceHigh++;
if (Low[0]<min[1])
barsSinceLow=0;
else if (barsSinceLow>-1 && IsFirstTickOfBar)
barsSinceLow++;
if (Math.Min(barsSinceHigh,barsSinceLow)<=0)
return;
if (barsSinceHigh<barsSinceLow)
fib=Draw.FibonacciRetracements(this,"fib",IsAutoScale,barsSinceLow,Low[barsSinceLow],barsSinceHigh,High[barsSinceHigh]);
else
fib=Draw.FibonacciRetracements(this,"fib",IsAutoScale,barsSinceHigh,High[barsSinceHigh],barsSinceLow,Low[barsSinceLow]);
}
#region Properties
[Range(1, int.MaxValue)]
[NinjaScriptProperty]
[Display(Name="Strength", Order=1, GroupName="Parameters")]
public int Strength
{ get; set; }
#endregion
}
}

Comment