Code issue with a new indicator

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

    hello, i am trying to create this indicator but this part of the code is not recognized => “Plot1(HighJump, “High Jump”, color.red)”

    any idea anyone? thanks

    // High Jump Indicator
    // Calculates the percentage distances from the high price to the 17, 50, and 200 day moving averages.

    period17 = 17
    period50 = 50
    period200 = 200

    // Calculate the moving averages
    MA17 = Average[period17](Close)
    MA50 = Average[period50](Close)
    MA200 = Average[period200](Close)

    // Calculate the percentage distance from the high price to each moving average
    dist17 = (High – MA17) / MA17 * 100
    dist50 = (High – MA50) / MA50 * 100
    dist200 = (High – MA200) / MA200 * 100

    // High Jump Indicator is the sum of the distances
    HighJump = dist17 + dist50 + dist200

    // Plot the High Jump Indicator (using Plot1)
    Plot1(HighJump, “High Jump”, color.red)

    // Optionally, you can add a threshold line to indicate when the stock might be over-extended
    threshold = 10 // Example threshold for caution flag
    Plot2(threshold, “Threshold”, color.green)

    #242986 quote
    Iván González
    Moderator
    Master

    Hi. You are using language not allowed in probuilder.
    To draw an indicator you have to write it in a last line starting with RETURN.

    // High Jump Indicator
    // Calculates the percentage distances from the high price to the 17, 50, and 200 day moving averages.
    
    period17 = 17
    period50 = 50
    period200 = 200
    
    // Calculate the moving averages
    MA17 = Average[period17](Close)
    MA50 = Average[period50](Close)
    MA200 = Average[period200](Close)
    
    // Calculate the percentage distance from the high price to each moving average
    dist17 = (High - MA17) / MA17 * 100
    dist50 = (High - MA50) / MA50 * 100
    dist200 = (High - MA200) / MA200 * 100
    
    // High Jump Indicator is the sum of the distances
    HighJump = dist17 + dist50 + dist200
    
    // Plot the High Jump Indicator (using Plot1)
    //Plot1(HighJump, "High Jump", color.red)
    
    // Optionally, you can add a threshold line to indicate when the stock might be over-extended
    threshold = 10 // Example threshold for caution flag
    //Plot2(threshold, "Threshold", color.green)
    return HighJump as "high Jump" coloured("red"), threshold as "Threshold" coloured("green")
    #243039 quote
    Fred76
    Participant
    New

    Makes sense
    thanks very much for this

    Fred

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

Code issue with a new indicator


Platform Support: Charts, Data & Broker Setup

New Reply
Author
author-avatar
Fred76 @fred76 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Fred76
1 year ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 01/23/2025
Status: Active
Attachments: No files
Logo Logo
Loading...