DRAW RECTANGLE – How to draw past 00:00 times

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #89753 quote
    Andyd3
    Participant
    New

    Hi, i’m using the draw rectangle code but i want to use this on different time frames that run through the 00:00 time

    eg 173000 – 060000

    when i set this the rectangle does not draw.

    is there a way to do this?

    thanks

    period = 20
    boxheight = 0.0020
    hh = highest[period](high)
    ll = lowest[period](low)
    
    if hh-ll <= boxheight then
      for i = 0 to period do
       if high[i]=hh then 
        x2 = barindex[i]
       endif
       if low[i]=ll then
        x1 = barindex[i]
       endif
     next
     if ABS(x2-x1) >= period then
       DRAWRECTANGLE(x1,ll,x2,hh)coloured(255,10,10)
     endif
    endif
    
    RETURN
    #89844 quote
    Nicolas
    Keymaster
    Master

    That code doesn’t use any time conditions to calculate and to plot. It only relies on period (bars quantity). So it should work at any time.

    #89851 quote
    Vonasi
    Moderator
    Master

    My guess would be that it has something to do with the boxheight (highest high – lowest low) needing to be <= 0.002 or the fact that line 15 expects the length of the box to be >= period which I am guessing is very unlikely.

    #90120 quote
    Nicolas
    Keymaster
    Master

    That code is good for me, it plots boxes only if the range is less or equal to 20 pips and if they have been formed for at least X periods.

    #90137 quote
    Vonasi
    Moderator
    Master

    … but you are finding the highest high and lowest low in the last 20 bars and then if they are have a difference of less than or equal to 20 pips then line 15 has a condition that only lets you draw a rectangle if the HH and LL are 20 or more bars apart. Surely this condition is very rarely going to be hit as they cannot be over 20 bars apart as that is your look back period to find them within! So in reality we are looking for a HH and LL less than 20 pips in difference where the HH and LL are exactly 20 bars apart.

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

DRAW RECTANGLE – How to draw past 00:00 times


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Andyd3 @andyd3 Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Vonasi
7 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/28/2019
Status: Active
Attachments: No files
Logo Logo
Loading...