Support Board
Date/Time: Mon, 16 Jun 2025 23:34:54 +0000
Post From: ZigZag2 function not creating nodes at exact reversal amount
[2025-04-28 12:39:33] |
Theodore01 - Posts: 6 |
Hello, I've identified an issue with the ZigZag study when applied to FlexRenko charts. When the price movement equals exactly the specified reversal amount, nodes are not being created as expected. Example 1: - Renko brick size: $20 - ZigZag Reversal amount: $50 - From low point to 3rd green Renko close: exactly 2.5 bricks = $50 - Expected: A node should be created at the low point - Actual: No node is created - https://www.sierrachart.com/image.php?Image=1745590873605.png Example 2: - Renko brick size: $20 - ZigZag Reversal amount: $40 - From low point to 2nd green Renko close: exactly 2 bricks = $40 - Expected: A node should be created at the low point - Actual: No node is created - https://www.sierrachart.com/image.php?Image=1745591289741.png Settings used: - Zig Zag Input Data: Renko Close - Number of Bars Required for Reversal: 1 Workaround found: Using reversal amounts slightly less than the target value (e.g., 49.9 instead of 50, 39.9 instead of 40) creates nodes as expected. This suggests the ZigZag2 built-in function might be using a "greater than" comparison instead of "greater than or equal to" when checking if a price movement qualifies as a reversal. Could the ZigZag2 function be modified to recognize price movements that equal the exact reversal amount? This would make zigzag behavior more predictable when used with Renko charts where price movements occur in precise brick increments. This is the code block the calls the built-in ZigZag2 from Studies7.cpp : //Calculate and set the zigzag lines
switch (Input_CalculationMode.GetInt()) { case 1: sc.ZigZag( sc.BaseData[Input_DataHigh.GetInputDataIndex()], sc.BaseData[Input_DataLow.GetInputDataIndex()], Subgraph_ZigZagLine, CalcIndex, Input_ReversalPercent.GetFloat() * 0.01f, ZigZagStartIndex); break; case 2: sc.ZigZag2( sc.BaseData[Input_DataHigh.GetInputDataIndex()], sc.BaseData[Input_DataLow.GetInputDataIndex()], Subgraph_ZigZagLine, CalcIndex, Input_NumberBarsForReversal.GetInt(), Input_ReversalAmount.GetFloat(), ZigZagStartIndex); break; case 3: sc.ZigZag( sc.BaseData[Input_DataHigh.GetInputDataIndex()], sc.BaseData[Input_DataLow.GetInputDataIndex()], Subgraph_ZigZagLine, CalcIndex, 0.0f, Input_ReversalAmount.GetFloat(), ZigZagStartIndex); break; } Thank you! |