Renko boxsize in percent?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #147885 quote
    Moose
    Participant
    New

    Hi!

    I’ve been searching for examples of this code but can’t find it.

    In PRT-charts it is possible to get the Renko boxes in % price movements. For example, 0.1 % is set as default. In the examples that I found of automated trading strategies or indicators using Renko, they are all written with a boxsize in pips. I can’t figure out how to code a boxsize in % of price. Is there a friendly soul that knows how and would like to share?

    #147893 quote
    Nicolas
    Keymaster
    Master

    The below code is plotting renko boxes with a dynamic size in percentage of the current Close:

    percent = 0.1
    
    boxsize = close*(percent/100)
    
    once renkoMax = ROUND(close / boxSize) * boxSize
    once renkoMin = renkoMax - boxSize
    
    IF close crosses over renkoMax + boxSize THEN
    WHILE close > renkoMax + boxSize
    renkoMax = renkoMax + boxSize
    renkoMin = renkoMin + boxSize
    iclose = renkomax
    WEND
    ELSIF close crosses under renkoMin - boxSize THEN
    WHILE close < renkoMin - boxSize
    renkoMax = renkoMax - boxSize
    renkoMin = renkoMin - boxSize
    iclose = renkomin
    WEND
    ENDIF
    
    if iclose=renkomax then
    r=0
    g=255
    else
    r=255
    g=0
    endif
    
    
    RETURN renkomax coloured(r,g,0) as "UP Box", renkomin coloured(r,g,0) as "DOWN Box"

    Choose the percent value in line 1 by adjusting the “percent” variable.

    If you want the box size to be set only at first bar and therefore fixed for the rest of the history, change the line boxsize with:

    ONCE boxsize = close*(percent/100)
    Moose thanked this post
    #147927 quote
    Moose
    Participant
    New

    Thank you Nicolas! Great code! This have helped me understand the Renko better.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Renko boxsize in percent?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Moose @doctormoose Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Moose
5 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/20/2020
Status: Active
Attachments: No files
Logo Logo
Loading...