mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-20 03:28:05 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user