Add Price Volume Trend (PVT) Indicator and Tests

- Implemented the PvtIndicator class for calculating Price Volume Trend in Quantower.
- Created unit tests for the Pvt class to validate calculations and state management.
- Added validation tests to ensure consistency with OoplesFinance's implementation.
- Developed a comprehensive documentation (Pvt.md) explaining the PVT concept, calculations, and usage.
- Included methods for batch calculations and streaming updates for PVT.
This commit is contained in:
Miha Kralj
2026-01-28 17:54:43 -08:00
parent dc1902f4d5
commit 76d2b50cbb
39 changed files with 8633 additions and 14 deletions
+4 -2
View File
@@ -124,7 +124,8 @@ public sealed class Nvi : ITValuePublisher
}
// Calculate NVI - only update when volume decreases
if (s.Index > 0 && s.PrevClose > 0 && s.PrevVolume > 0 && close > 0 && volume < s.PrevVolume)
// Matches PineScript: if not (na(src) or na(vol) or na(src[1]) or na(vol[1]) or src[1] == 0.0 or vol[1] <= 0.0) and vol < vol[1]
if (s.Index > 0 && s.PrevClose > 0 && s.PrevVolume > 0 && volume < s.PrevVolume)
{
s.NviValue *= close / s.PrevClose;
}
@@ -268,7 +269,8 @@ public sealed class Nvi : ITValuePublisher
}
// Only update when volume decreases (using sanitized values)
if (prevClose > 0 && prevVolume > 0 && currentClose > 0 && currentVolume < prevVolume)
// Matches PineScript: if not (na(src) or na(vol) or na(src[1]) or na(vol[1]) or src[1] == 0.0 or vol[1] <= 0.0) and vol < vol[1]
if (prevClose > 0 && prevVolume > 0 && currentVolume < prevVolume)
{
nvi *= currentClose / prevClose;
}