Wave Chart Construction (NeoWave)
A wave chart plots each bar's high and low in the order they occurred, joined by straight lines. It is the input for all NeoWave counting.
These rules are the project standard. They are also in backend/CLAUDE.md section 4, so
backend work follows them. Each rule below is followed by how Range Analysis implements it.
1. Data
- Use cash/spot index data only (for example Nifty spot). Never futures.
In Range Analysis: /api/range-analysis/prices serves spot only.
- NSE: IEOD spot through
Con_Price_Getter. An index without spot data returns an error instead of falling back to futures. - MCX:
scr_mcxsp_eodspot. - BSE: mock prices, labelled as such.
2. Timeframes
- Every wave chart uses a Default Timeframe (DTF) and a Smaller Timeframe (STF).
- The STF must fit at least 5 bars inside one DTF bar.
| DTF | STF | Bars per DTF bar |
|---|---|---|
| Weekly | Daily | 5 |
| Daily | 75-min | 5 (375-min NSE session) |
| Monthly | Daily | ~20 (weekly gives only ~4.3, which is not allowed) |
In Range Analysis: the chart bar size (Tab 1 "Bar size") is the DTF. The order of each bar's high and low is decided from smaller base bars:
| Chart bar (DTF) | Data the order comes from | Bars per DTF bar |
|---|---|---|
| 5 min … 4 hour | 1-min | ≥ 5 |
| 75 min (added for this rule) | 1-min | 75 |
| Daily | 75-min | 5–6 |
| Weekly / Monthly | Daily, refined down to 75-min | 5 / ~20 |
| MCX (any) | Daily (no intraday MCX data) | — |
neoWaveStf() in rangeEngine.js names the STF shown on Tab 3. childBars() returns the STF
bars inside a selected bar, for the child chart.
3. Deciding which came first: high or low
For each DTF bar, find the STF bars that contain the high and the low.
If they are in different STF bars: the earlier STF bar gives the order.
If they are in the same STF bar, apply these rules first:
- Open > Close → high came first
- Open < Close → low came first
- Open = Close → the extreme closer to the open came first
Optional refinement: if smaller data (lower timeframe or tick data) is available, drill down into that bar to confirm the actual order. Repeat down to the smallest data available.
Mark every bar decided by the open/close rule (not confirmed by smaller data) as "assumed".
In Range Analysis: orderOf(parts) in rangeEngine.js.
- It finds the first part holding the high and the first part holding the low. If they differ, the order is confirmed.
- If they are the same part, it uses that part's own already-refined order when it has one.
Otherwise it applies the open/close rule and sets
assumed: true. - Because the parts are the smallest bars available, the refinement always goes all the way down.
Result on real data: NSE bars decided from 1-min data are almost never assumed. MCX bars are always assumed, because only daily data exists.
4. Plotting
- Plot two points per DTF bar: high and low, in the order found above.
- Join all points with straight lines.
- Keep time spacing even; use log scale for long periods.
In Range Analysis:
wavePoints(bars)gives two points per bar, at bar position ± 0.25.- The Wave view on Tab 2, Tab 3 and the child chart draws them as straight lines at even spacing: one slot per bar, whatever the calendar gap.
- Assumed bars get hollow amber markers and are labelled "(assumed)".
- Log scale is on by default for Daily, Weekly and Monthly bars.
5. Monowaves
- Each run in one direction until the line reverses is one monowave. It is the basic unit for NeoWave counting.
In Range Analysis: countMonowaves(bars, a, b) counts direction runs in the wave line.
Flat segments continue the current run. The count appears in Tab 3's details for the selected
range, or for the whole window.
6. Rule of use
- Build the wave chart this way for every timeframe before any wave counting.
In Range Analysis: the same orderOf / wavePoints path is used for the window bars
(Tab 2), the small-timeframe bars (Tab 3) and the child chart. So every level of the drill-down
follows the same construction.