calculating with time

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #63390 quote
    odlaregodlareg
    Participant
    New

    Hello all,

    I want to make an indicator which is as follows: (((100- (number of periods since highest high))/100) * 100.

    However, I cannot translate the “number of periods since highest high” to prt code.

    Your help is much appreciated.

    Thank you very much.

    And best wishes,

    Geraldo

    #63405 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    First you have to define the number of previous bars you want to scan to find a “highest high”.

    If you want the highest high of the last 100 bars you may write:

    ONCE LookBack = 100
    HighestHigh   = -1
    HighestBar    = 0
    FOR i = 0 TO LookBack
       IF high > HighestHigh THEN
          HighesetHigh = high
    	  HighestBar   = i
       ENDIF
    NEXT

    At the end of which HighestHigh will hold the highest price found and HighestBar its bar ID, 0 to 100. So if it returns 23 you can reference that cadlestick with [23] (low[23], close[23,….).

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

calculating with time


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
odlareg @odlareg Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
8 years, 7 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/21/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...