the indicator will apply the calculation and drawing to all (infinate) bars
1) Is there simple way to apply indicator to calculate according to options selected in indicator panel?
2) As a turnaround (not preferred)I coded below to limit the numbers to bars for calculation, and marker drawing. However the calucation and marker is drawn from the oldest to BarsToLookBack number of bars. How can I correct to draw and calculate for the bars from the latest?
l
atestprotected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 1) // Debugging statements to check values Print("BarsToLookBack: " + BarsToLookBack); Print("CurrentBar: " + CurrentBar); // Ensure the drawing logic respects the custom BarsToLookBack setting if (BarsToLookBack == -1 || CurrentBar < BarsToLookBack) // Use the custom property { Print("Entering drawing logic for CurrentBar: " + CurrentBar); // Ensure there are enough bars for the calculations if (BarsToLookBack != -1 && CurrentBar < 25) // Adjust this value based on the maximum BarsAgo you use return; Print("Entering drawing logic for CurrentBar: " + CurrentBar); // Iterate from the latest bar to the oldest bar within the lookback range for (int i = CurrentBar; i >= Math.Max(0, CurrentBar - BarsToLookBack + 1); i--) { // Cache repeated calculations bool deltaTickIncrease = DeltaTickLine1.BaseValue[1] > DeltaTickLine1.BaseValue[0]; bool deltaTickDecrease = DeltaTickLine1.BaseValue[1] < DeltaTickLine1.BaseValue[0]; if (Absoprtion){ if (deltaTickDecrease && deltaVolumeDecrease && deltaVolumeTickDiffIncrease && closeEqualOrDecrease){ DrawPlusDiamondp(this, "VnTnD_Diamond_1" + CurrentBar, false, 0, High[0] + (3 * TickSize), Brushes.Yellow, (float)MarkerSize, Brushes.Transparent); } else if (deltaTickIncrease && deltaVolumeIncrease && deltaVolumeTickDiffDecrease && closeIncrease){ DrawPlus.Diamondp(this, "VnTnD_Diamond_1" + CurrentBar, false, 0, Low[0] + (-3 * TickSize), Brushes.Yellow, (float)MarkerSize, Brushes.Transparent); } }
Comment