Etherist![]() Member ![]() Posts: 27 Joined: 6/9/2024 Location: South Australia ![]() | Hi there Lou Here's a possible solution to your question ... a long time coming, hey. Normalizing Gann Output and 100-Bar Price Range in OmniTrader The details below assume the following: 1. That your Gann calculation is returning a scalar value per bar (like an indicator) and not a set of levels/angles. 2. That you are plotting the Gann result using the Plot function. 3. That you want the normalized plot to always span from -1 to 1 (like RSI) and not from 0 to 100. 4. That you want the 100-day high/low based on price and not on your calculated Gann result. To normalize a Gann-based oscillator use a min–max scaling on the recent Gann values. In practice, compute the rolling maximum and minimum of the Gann value series and map the current value into [–1,1]. Specifically, use OmniLanguage’s HHV and LLV functions to get these extremes: for example, HHV(H,n) (or simply HHV(n)) returns the highest high of the last n bars, and LLV(n) returns the lowest low. Nirvana (OmniTrader) documentation suggests normalizing indicators this way to make them comparable across symbols. In formula terms: • Compute GannMax = HHV(GannSeries,Period) and GannMin = LLV(GannSeries,Period) over your chosen lookback (e.g. 100 bars). • Then set GannNorm = 2 * ((GannValue – GannMin) / (GannMax – GannMin)) - 1, ensuring to handle the case when GannMax = GannMin. The steps are: • Compute rolling HHV/LLV of the Gann values over NormPeriod. • Apply min–max scaling: GannNorm = 2 * ((GannValue - GannMin) / (GannMax - GannMin)) - 1, which yields a value in [–1,1] (if GannMax>GannMin; otherwise set to 0). This follows the recommended (value – LLV)/(HHV–LLV) normalization. • Compute the 100-bar price high/low directly from price: PriceHigh100 = HHV(H,100) and PriceLow100 = LLV(L,100). • Plot each series using Plot(...). ########################################### #Indicator #PARAM "NormPeriod",100,1,1000 #PARAM "HLPeriod",100,1,1000 Dim GannValue As Double Dim GannMax As Double Dim GannMin As Double Dim GannNorm As Double Dim PriceHigh100 As Double Dim PriceLow100 As Double Dim High100 As Double Dim Low100 As Double ' Example Gann calculation (replace with actual Gann formula) GannValue = (H + L + C) / 3 ' Rolling max/min of GannValue over NormPeriod bars GannMax = HHV(GannValue, NormPeriod) GannMin = LLV(GannValue, NormPeriod) If (GannMax > GannMin) Then GannNorm = 2 * ((GannValue - GannMin) / (GannMax - GannMin)) - 1 Else GannNorm = 0 End If ' 100-bar high and low of price PriceHigh100 = HHV(H, HLPeriod) PriceLow100 = LLV(L, HLPeriod) Plot("NormGann", GannNorm) Plot("High100", PriceHigh100) Plot("Low100", PriceLow100) Return GannNorm ########################################### You need to declare parameters and variables, then compute the normalized Gann value (GannNorm) and the 100-bar price high/low. HHV(GannValue, NormPeriod) and LLV(GannValue, NormPeriod) find the recent high/low of the Gann series; then scale (GannValue – GannMin)/(GannMax – GannMin) to [–1,1]. Separately, HHV(H,100) and LLV(L,100) give the 100-bar highest high and lowest low of the price. Finally use Plot(...) to display the normalized oscillator and the price high/low lines. This OmniLanguage code can be placed in a System or Indicator in OmniTrader to produce the desired outputs, with values consistently scaled between –1 and +1 and the 100-bar price range plotted. Let me know how you go with this or if you have any questions around these suggestions. Cheers Etherist [Edited by Etherist on 5/30/2025 6:28 PM] |