Help on converting : Psychological line (PSY)

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #139697 quote
    BITE1437
    Participant
    Average

    Psychological line (PSY), as an indicator, is the ratio of the number of
    rising periods over the total number of periods. It reflects the buying
    power in relation to the selling power.

    If PSY is above 50%, it indicates that buyers are in control. Likewise,
    if it is below 50%, it indicates the sellers are in control. If the PSY
    moves along the 50% area, it indicates balance between the buyers and
    sellers and therefore there is no direction movement for the market.

    May I seek your assistance in converting the following tradingview code to prorealcode?

    // Psychological line (PSY), as an indicator, is the ratio of the number of
    // rising periods over the total number of periods. It reflects the buying
    // power in relation to the selling power.
    //
    // If PSY is above 50%, it indicates that buyers are in control. Likewise,
    // if it is below 50%, it indicates the sellers are in control. If the PSY
    // moves along the 50% area, it indicates balance between the buyers and
    // sellers and therefore there is no direction movement for the market.
    ////////////////////////////////////////////////////////////
    study(title=”Psychological line”)
    Length = input(20, minval=1)
    xPSY = sum(close > close[1],Length) / Length * 100
    clr = iff(xPSY >= 50, green, red)
    p1 = plot(50, color=black, title=”0″)
    p2 = plot(xPSY, color=blue, title=”PSY”)
    fill(p1, p2, color=clr)

    #139716 quote
    robertogozzi
    Moderator
    Master

    There you go:

    // Psychological Line (PSL or PSY) indicator
    //
    // https://www.prorealcode.com/topic/help-on-converting-psychological-line-psy/
    //
    // https://library.tradingtechnologies.com/trade/chrt-ti-psychological-line.html
    // https://blog.iqoption.com/en/psychological-line-indicator-trading-strategy-tips/
    // https://docs.anychart.com/Stock_Charts/Technical_Indicators/Psychological_Line_(PSY)
    //
    p    = 20
    p    = max(2,min(999,p))
    Up   = close > open
    Psl  = summation[p](Up) / p * 100
    RETURN Psl AS "PSL",50 AS "50"

    you can set colours with its properties.

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

Help on converting : Psychological line (PSY)


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
BITE1437 @bite1437 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
5 years, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/20/2020
Status: Active
Attachments: No files
Logo Logo
Loading...