Optimize strategies (#23)
* Update Tradingbox + set limit price * Change discord message
This commit is contained in:
@@ -33,16 +33,38 @@ public class StDevContext : Strategy
|
||||
return null;
|
||||
|
||||
var lastCandle = stDevCandles.Last();
|
||||
var zScore = lastCandle.ZScore ?? 0;
|
||||
|
||||
if (lastCandle.ZScore is < 1.2 and > (-1.2))
|
||||
// Determine confidence based on Z-score ranges
|
||||
// Lower absolute Z-score = more normal volatility = higher confidence for trading
|
||||
// Higher absolute Z-score = more extreme volatility = lower confidence for trading
|
||||
Confidence confidence;
|
||||
|
||||
if (Math.Abs(zScore) <= 0.5)
|
||||
{
|
||||
AddSignal(lastCandle, TradeDirection.None, Confidence.Medium);
|
||||
// Very low volatility - ideal conditions for trading
|
||||
confidence = Confidence.High;
|
||||
}
|
||||
else if (Math.Abs(zScore) <= 1.0)
|
||||
{
|
||||
// Normal volatility - good conditions for trading
|
||||
confidence = Confidence.Medium;
|
||||
}
|
||||
else if (Math.Abs(zScore) <= 1.5)
|
||||
{
|
||||
// Elevated volatility - caution advised
|
||||
confidence = Confidence.Low;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Bad zscore");
|
||||
// High volatility - trading not recommended
|
||||
confidence = Confidence.None;
|
||||
}
|
||||
|
||||
// Context strategies always return TradeDirection.None
|
||||
// The confidence level indicates the quality of market conditions
|
||||
AddSignal(lastCandle, TradeDirection.None, confidence);
|
||||
|
||||
return Signals.Where(s => s.Confidence != Confidence.None).OrderBy(s => s.Date).ToList();
|
||||
}
|
||||
catch (RuleException)
|
||||
|
||||
Reference in New Issue
Block a user