Prorealcode for standard PRT stochastic and RSI

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #189450 quote
    mwilkens111
    Participant
    New

    When adding indicators in PRT, the standard stochastic is a good starting point. Is the prorealcode for this standard indicator as included in PRT available?

    Would like to expand on it, but need code to get started.

    Markus

    #189453 quote
    robertogozzi
    Moderator
    Master

    This is the standard formula:

    //--------------------------------------------------------------------------------------
    // Formula:
    //
    // https://en.wikipedia.org/wiki/Stochastic_oscillator
    // https://www.investopedia.com/terms/s/stochasticoscillator.asp
    //
    DEFPARAM CalculateOnLastBars = 2000
    //        settings for Stochastic 10,5,3)
    // Periods = 10
    // Kline   = 5
    // Dline   = 3
    // AvgType = 1     //Ema
    K = average[Kline,AvgType](((close - lowest[Periods](low)) / (highest[Periods](high) - lowest[Periods](low)))  * 100)
    D = average[Dline,AvgType](K)
    RETURN K AS "%K",D AS "%D"
    mwilkens111 thanked this post
    #189466 quote
    mwilkens111
    Participant
    New

    Perfect, thanks a lot!

    It seems with Stochstic there is also a “slow” one, will this only relate to the “K” number of days to average?

    Thank you for the super fast assistance!

    Markus

    #189467 quote
    robertogozzi
    Moderator
    Master

    Yes, slow and fast are determined by settings only.

    #189577 quote
    mwilkens111
    Participant
    New

    is there also a chance to get the code for the standard PRT RSI indicator with a few variables to play with period and average Type?

    Markus

    #189605 quote
    robertogozzi
    Moderator
    Master

    Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.

    Your request will be addressed asap.

    Thank you 🙂

    #189618 quote
    robertogozzi
    Moderator
    Master

    There you go:

    // RSI indicator
    //
    // Formula:
    //
    //    (https://www.prorealcode.com/topic/indicatore-rsi/#post-51250)
    //    (https://www.investopedia.com/terms/r/rsi.asp)
    //
    p         = 14                          //periods
    Ob        = 70                          //OverBought
    Os        = 100 - Ob                    //OverSold
    //
    Bullish   = MAX(0, CLOSE - CLOSE[1])
    Bearish   = MAX(0, CLOSE[1] - CLOSE)
    //
    mmBullish = WILDERAVERAGE[p](Bullish)
    mmBearish = WILDERAVERAGE[p](Bearish)
    //
    RS        = mmBullish / mmBearish
    myRSI     = 100 - (100 / (1 + RS))
    //
    RETURN MyRSI AS "Rsi",Os AS "Os",Ob AS "Ob"
    #189635 quote
    mwilkens111
    Participant
    New

    thank you! very helpful indeed.

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

Prorealcode for standard PRT stochastic and RSI


Platform Support: Charts, Data & Broker Setup

New Reply
Author
Summary

This topic contains 7 replies,
has 2 voices, and was last updated by mwilkens111
3 years, 11 months ago.

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