Mr.Tools could you see if please you could fix the accurate range for the renko bricks ? The ai says this needs to be done, but that's just a theory lol
Here's a breakdown of how to make the ATR bars on the chart display the accurate range of the ATR range size in the code:
1. Normalize ATR Values:
Before using ATR values for calculations, normalize them to match the point value of the instrument using NormalizeDouble(atrValue * pt, Digits).
This ensures accurate comparison and calculation, as ATR values are in pips while price values are in points.
2. Calculate Box Size Based on ATR:
Use functions like iATR to obtain the ATR value for the desired timeframe and period.
Set the RenkoBoxSize input parameter to a multiple of the normalized ATR value, as each Renko box will represent a multiple of the ATR.
3. Scale High and Low Values:
When determining Renko box formation, scale high and low values based on the normalized ATR using MathFloor(Close/BoxPoints)*BoxPoints.
This ensures that boxes are formed based on ATR multiples and not raw price points.
4. Draw Renko Bars:
Use the FileWriteDouble function to write the high and low values of the Renko boxes to the hst file.
Ensure these values are scaled based on ATR using the BoxPoints variable.
5. Display ATR Value in Comments:
Add a comment to the chart using Comment or a custom function like AddRenkoComment.
Display the current normalized ATR value in pips within this comment.
Additional Considerations:
Adjust for Digits: If the instrument has digits other than 5, adjust normalization accordingly.
Use Consistent Point Value: Maintain a consistent pt variable for correct calculations.
Apply ATR Box Size: Ensure the calculated BoxSize is used for box formation and commenting.
Update Chart Accurately: Trigger chart updates with UpdateChartWindow after writing new bar data.
Example Code Modifications:
Code: Select all
// ... existing code ...
// OnTick function:
BoxPoints = NormalizeDouble(BoxSize * pt, Digits); // Normalize ATR-based box size
// ... rest of OnTick code ...
// AddRenkoComment function:
text = text + " (" + DoubleToStr(BoxPoints/pt,1) + " pips ATR)\n"; // Display ATR in comments
// ... rest of AddRenkoComment code ...
cheers
-simon
#fs