Support Board
Date/Time: Wed, 12 Feb 2025 11:44:44 +0000
Post From: How to count bars after certain conditions met
[2020-10-19 21:10:19] |
Luigi - Posts: 18 |
I am a newbie in SC ACSIL programming, so forgive me if it is a trivial question. What I try to achieve: Count n number of bars after certain indicator changed value and change bar color of nth bar. Problem: My data processing logic works when chart is loaded first time, but when live or replaying the function called at each price updates and my counter is not counting bars anymore, but the updates on the last bar. What would be the best way to solve this? Code snipet which works when chart is loaded: int& upCounter = sc.GetPersistentInt(1);
int& downCounter = sc.GetPersistentInt(2); if ((Subgraph_Avg[sc.Index] - Subgraph_Avg[sc.Index-1]) >= 0 ) { Subgraph_TTF_Trend[sc.Index] = 1; upCounter = upCounter +1; downCounter=0; } else { Subgraph_TTF_Trend[sc.Index] = -1; downCounter = downCounter +1; upCounter=0; } Date Time Of Last Edit: 2020-10-19 21:13:16
|