Add ORB confluence factors (NR4/NR7, gap alignment, breakout volume, prior close) + session file logger
Some checks failed
Build and Test / build (push) Has been cancelled
Some checks failed
Build and Test / build (push) Has been cancelled
This commit is contained in:
@@ -112,6 +112,11 @@ namespace NT8.Strategies.Examples
|
||||
_factorCalculators.Add(new VolatilityRegimeFactorCalculator());
|
||||
_factorCalculators.Add(new TimeInSessionFactorCalculator());
|
||||
_factorCalculators.Add(new ExecutionQualityFactorCalculator());
|
||||
_factorCalculators.Add(new NarrowRangeFactorCalculator(_logger));
|
||||
_factorCalculators.Add(new OrbRangeVsAtrFactorCalculator(_logger));
|
||||
_factorCalculators.Add(new GapDirectionAlignmentCalculator(_logger));
|
||||
_factorCalculators.Add(new BreakoutVolumeStrengthCalculator(_logger));
|
||||
_factorCalculators.Add(new PriorDayCloseStrengthCalculator(_logger));
|
||||
|
||||
_logger.LogInformation(
|
||||
"SimpleORBStrategy initialized with OR period {0} minutes and multiplier {1:F2}",
|
||||
@@ -191,6 +196,8 @@ namespace NT8.Strategies.Examples
|
||||
if (candidate == null)
|
||||
return null;
|
||||
|
||||
AttachDailyBarContext(candidate, bar, context);
|
||||
|
||||
var score = _scorer.CalculateScore(candidate, context, bar, _factorCalculators);
|
||||
var mode = _riskModeManager.GetCurrentMode();
|
||||
|
||||
@@ -349,6 +356,24 @@ namespace NT8.Strategies.Examples
|
||||
metadata.Add("orb_high", _openingRangeHigh);
|
||||
metadata.Add("orb_low", _openingRangeLow);
|
||||
metadata.Add("orb_range", openingRange);
|
||||
|
||||
double tickSize = 0.25;
|
||||
if (_config != null && _config.Parameters != null && _config.Parameters.ContainsKey("TickSize"))
|
||||
{
|
||||
var tickValue = _config.Parameters["TickSize"];
|
||||
if (tickValue is double)
|
||||
tickSize = (double)tickValue;
|
||||
else if (tickValue is decimal)
|
||||
tickSize = (double)(decimal)tickValue;
|
||||
else if (tickValue is float)
|
||||
tickSize = (double)(float)tickValue;
|
||||
}
|
||||
|
||||
if (tickSize <= 0.0)
|
||||
tickSize = 0.25;
|
||||
|
||||
var orbRangeTicks = openingRange / tickSize;
|
||||
metadata.Add("orb_range_ticks", orbRangeTicks);
|
||||
metadata.Add("trigger_price", lastPrice);
|
||||
metadata.Add("multiplier", _stdDevMultiplier);
|
||||
metadata.Add("opening_range_start", _openingRangeStart);
|
||||
@@ -365,5 +390,40 @@ namespace NT8.Strategies.Examples
|
||||
"ORB breakout signal",
|
||||
metadata);
|
||||
}
|
||||
|
||||
private void AttachDailyBarContext(StrategyIntent intent, BarData bar, StrategyContext context)
|
||||
{
|
||||
if (intent == null || intent.Metadata == null)
|
||||
return;
|
||||
|
||||
if (_config == null || _config.Parameters == null || !_config.Parameters.ContainsKey("daily_bars"))
|
||||
return;
|
||||
|
||||
var source = _config.Parameters["daily_bars"];
|
||||
if (!(source is DailyBarContext))
|
||||
return;
|
||||
|
||||
DailyBarContext baseContext = (DailyBarContext)source;
|
||||
DailyBarContext daily = baseContext;
|
||||
|
||||
daily.TradeDirection = intent.Side == OrderSide.Buy ? 1 : -1;
|
||||
daily.BreakoutBarVolume = (double)bar.Volume;
|
||||
daily.TodayOpen = bar.Open;
|
||||
|
||||
if (context != null && context.CustomData != null && context.CustomData.ContainsKey("avg_volume"))
|
||||
{
|
||||
var avg = context.CustomData["avg_volume"];
|
||||
if (avg is double)
|
||||
daily.AvgIntradayBarVolume = (double)avg;
|
||||
else if (avg is float)
|
||||
daily.AvgIntradayBarVolume = (double)(float)avg;
|
||||
else if (avg is int)
|
||||
daily.AvgIntradayBarVolume = (double)(int)avg;
|
||||
else if (avg is long)
|
||||
daily.AvgIntradayBarVolume = (double)(long)avg;
|
||||
}
|
||||
|
||||
intent.Metadata["daily_bars"] = daily;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user