Highest and Second highest point in last X bars if current close is lower

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #164651 quote
    JanC20
    Participant
    Average

    Good day, This is my first time trying….

    I want to create an indicator that could identify:

    1. The highert point in the last X bars then
    2. From that point of the highest bar, to the current bar, I would like to calculate the second highest bar.

    But I constantly get an error message: “un parametre de type entier positif est attendu avec highest”

    Here is the code, and I do not understand the reason, as the defenition is a full number??? Could anyone help?

    bars = 70
    Y1 = highest[bars] (high[1])
    
    if high <Y1 or high [1]<Y1 then
    
    for i = bars downto 1 do
    if high [i] = Y1 then
    X1 = i-1
    DRAWTEXT("#X1#", barindex [X1], high [x1])
    break
    endif
    next
    
    Y2 = highest[X1] (high[1])
    
    for n = X1 downto 0 do
    if high [n] = Y2 then
    X2 = n
    DRAWTEXT("#X2#", barindex [n], high [n])
    break
    endif
    next
    
    endif
    
    return
    #164658 quote
    JC_Bywan
    Moderator
    Master

    Hello, moderation messages :

    • you posted in English in french forum, please see rules in yellow box below about choosing the right forum. No need to repost we’ll move this topic now
    • you posted code without formatting it, please see image attached to locate the “insert PRT code” button as this is your first time. Again no need to repost, we’ll reformat your code in above message now
    Rules_InsertPRTcode-1.png Rules_InsertPRTcode-1.png
    #164668 quote
    JC_Bywan
    Moderator
    Master

    Your first “for to next” loop ending with i=1, x1=i-1 will be =0 when i=1, and the error message “entier positif” (positive integer) for X1 in highest[x1](…) means X1 has to be at least 1, not 0… so either make sure X1 can’t be zero, or use something bigger than X1 with highest

    #164686 quote
    JanC20
    Participant
    Average

    Thanks you for pointing this out!  It was a great help

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

Highest and Second highest point in last X bars if current close is lower


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
JanC20 @janc20 Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by JanC20
4 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/19/2021
Status: Active
Attachments: 1 files
Logo Logo
Loading...