Demark Trendline code

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #239064 quote
    oyinloyeaoyinloyea
    Participant
    Veteran

    Please help with this code. It is coming up with errors

     

    // Parameters
    lookbackPeriod = 10

    // Number of bars to look back for pivot highs and lows

    // Variables to store pivot points
    pivotHighPrice = 0
    pivotLowPrice = 0

    // Find Pivot High (downtrend)
    for i = 1 to LookbackPeriod do
    if high[i] > high[i+1] and high[i] > high[i-1] then
    pivotHighPrice = high[i]
    break
    endif
    next

    // Find Pivot Low (uptrend)
    for i = 1 to LookbackPeriod do
    if low[i] < low[i+1] and low[i] < low[i-1] then
    pivotLowPrice = low[i]
    break
    endif
    next

    // DeMark Trendline Logic
    // For Uptrend: connecting pivot low to subsequent lower low
    if pivotLowPrice= 0 then
    lineUp =DRAWLINE(pivotLowPrice, Date[pivotLowBar], low, Date[0])
    endif

    // For Downtrend: connecting pivot high to subsequent higher high
    if pivotHighPrice = 0 then
    lineDown = DRAWLINE(pivotHighPrice, Date[pivotHighBar], high, Date[0])
    endif

    RETURN lineUp AS “DeMark Up Trendline”, lineDown AS “DeMark Down Trendline”

    #239067 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    DrawLine is a graphical instruction, not to be used in expressions.

    Use:

    DRAWLINE(pivotLowPrice, Date[pivotLowBar], low, Date[0])

    and

    DRAWLINE(pivotHighPrice, Date[pivotHighBar], high, Date[0])

    Bear in mind that DrawLine (https://www.prorealcode.com/documentation/drawline/) requires BARINDEX1,PRICE1,BARINDEX2,PRICE2 to draw a line between two points.

    Iván González thanked this post
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

Demark Trendline code


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
oyinloyea @oyinloyea Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
1 year, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/16/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...