Converting indicator Trend Trader Strategy

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #197355 quote
    mariamfimariamfi
    Participant
    New

    the following is a code of  Trend Trader Strategy from trading view

    I would like to convert it to use it in prorealtime

     

    //@version=4
    ////////////////////////////////////////////////////////////
    // Copyright by HPotter v1.0 21/01/2021
    // This is plots the indicator developed by Andrew Abraham
    // in the Trading the Trend article of TASC September 1998
    //
    // WARNING:
    // – For purpose educate only
    // – This script to change bars colors.
    ////////////////////////////////////////////////////////////
    study(title=”Trend Trader Strategy”, overlay = true)
    Length = input(21, minval=1),
    Multiplier = input(3, minval=0.000001)
    avgTR = wma(atr(1), Length)
    highestC = highest(Length)
    lowestC = lowest(Length)
    hiLimit = highestC[1]-(avgTR[1] * Multiplier)
    loLimit = lowestC[1]+(avgTR[1] * Multiplier)
    ret = 0.0
    pos = 0.0
    ret:= iff(close > hiLimit and close > loLimit, hiLimit,
    iff(close < loLimit and close < hiLimit, loLimit, nz(ret[1], close)))
    pos:= iff(close > ret, 1,
    iff(close < ret, -1, nz(pos[1], 0)))
    barcolor(pos == -1 ? color.red: pos == 1 ? color.green : color.blue )
    plot(ret, color= color.blue , title=”Trend Trader Strategy”)

    #199821 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    // Trend Trader Strategy (TTS)
    //
    // https://www.prorealcode.com/topic/converting-indicator-trend-trader-strategy/
    //
    // https://www.tradingview.com/script/j1etwXMQ-Trend-Trader-Strategy/
    //
    // @version=4
    ////////////////////////////////////////////////////////////
    // Copyright by HPotter v1.0 21/01/2021
    // This is plots the indicator developed by Andrew Abraham
    // in the Trading the Trend article of TASC September 1998
    //
    // WARNING:
    // - For purpose educate only
    // - This script to change bars colors.
    ////////////////////////////////////////////////////////////
    //ONCE Length     = 21
    //ONCE Multiplier = 3
    length     = max(1,min(999,length))
    multiplier = max(0,min(999,multiplier))
    MyATR      = AverageTrueRange[1](close)
    avgTR      = average[Length,2](MyATR)
    highestC   = highest[Length](close)
    lowestC    = lowest[Length](close)
    hilimit    = highestC[1] - (avgTR[1] * Multiplier)
    lolimit    = lowestC[1]  + (avgTR[1] * Multiplier)
    //
    ret        = 0
    pos        = 0
    //
    IF (close > hilimit) AND (close > lolimit) THEN
    ret = hilimit
    ELSE
    IF (close < lolimit) AND (close < hilimit) THEN
    ret = lolimit
    ELSE
    //IF ret[1] = 0 THEN
    ret = close
    //ENDIF
    ENDIF
    ENDIF
    //
    IF close > ret THEN
    pos = 1
    ELSE
    IF close < ret THEN
    pos = -1
    ELSE
    pos = pos[1]
    ENDIF
    ENDIF
    r = 0
    g = 128
    b = 0
    t = 155
    IF pos = -1 THEN
    r = 255
    g = 0
    t = 255
    ENDIF
    DrawCandle(Open,High,Low,Close) coloured(r,g,b,t)
    RETURN ret coloured(0,0,255,255) AS "Trend Trader Strategy"
    Nicolas and PLermite thanked this post
    Trend-Trader-Strategy-TTS.itf Trend-Trader-Strategy-TTS.jpg Trend-Trader-Strategy-TTS.jpg
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

Converting indicator Trend Trader Strategy


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
mariamfi @mariamfi Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
4 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/16/2022
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...