PRC_SuperTrend Extended: buy and sell signals

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #121144 quote
    bullbearbullbear
    Participant
    Senior

    I wonder how to code so that you can get a signal when the buy and sell arrow comes up in the graph.

    Does not work when I code with PRC_SuperTrend Extended (:

    /B

    #121147 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    This is modified to be added below the price chart (like Macd,…) and will return 1 or -1:

    //PRC_SuperTrend Extended | indicator
    //31.10.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
     
    // --- settings
    multiplier=2.236
    period=66
    type=1 //1 = use ATR , 2 = Use standard deviation , 3 = Use standard error
    midperiod=10
    // --- end of settings
     
    type=max(1,type)
    if type=1 then
    moy=averagetruerange[period](close)
    elsif type=2 then
    moy=std[period](close)
    elsif type=3 then
    moy=ste[period](close)
    endif
     
    price=(highest[midperiod](high)+lowest[midperiod](low))/2
    up=price+multiplier*moy
    dn=price-multiplier*moy
    once trend=1
    if close>up[1] then
    trend=1
    elsif close<dn[1] then
    trend=-1
    endif
    if trend<0 and trend[1]>0 then
    flag=1
    else
    flag=0
    endif
    if trend>0 and trend[1]<0 then
    flagh=1
    else
    flagh=0
    endif
    if trend>0 and dn<dn[1] then
    dn=dn[1]
    endif
    if trend<0 and up>up[1] then
    up=up[1]
    endif
    if flag=1 then
    up=price+multiplier*moy
    endif
    if flagh=1 then
    dn=price-multiplier*moy
    endif
    if trend=1 then
    //mysupertrend=dn
    //offset=moy
    //color1=0
    //color2=191
    //color3=255
    else
    //mysupertrend=up
    //offset=-moy
    //color1=255
    //color2=69
    //color3=0
    endif
     
    //drawcandle(mysupertrend,mysupertrend+offset,mysupertrend,mysupertrend+offset) coloured(color1,color2,color3,50)bordercolor(100,100,100,0)
    Signal = 0
    if trend=1 and trend[1]<>1 then
    Signal = 1
    //drawarrowup(barindex,mysupertrend) coloured(color1,color2,color3)
    endif
    if trend=-1 and trend[1]<>-1 then
    Signal = -1
    //drawarrowdown(barindex,mysupertrend) coloured(color1,color2,color3)
    endif
     
    return Signal
    #121148 quote
    bullbearbullbear
    Participant
    Senior

    It works šŸ™‚

    Thanks Roberto!!

Viewing 3 posts - 1 through 3 (of 3 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

PRC_SuperTrend Extended: buy and sell signals


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
bullbear @bullbear Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by bullbearbullbear
6 years, 7 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/04/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...