Why Can't use or call some indicator?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #34756 quote
    Francesco
    Participant
    Average

    Hallo to all,

    I tried to write a simple screener using Schaff Trend Cycle Indicator, but when I try to build it, platform says “Selected indicator Is not available in ProBuilder Language. Select another indicator.”

    But STC is a built-in ProRealTime 10.3 indicator.

    I tried also to…

    Call “Schaff Trend Cycle”[10,23,50]

    But the result is the same.

    What’s the problem?

    #34806 quote
    Nicolas
    Keymaster
    Legend

    Some indicators can’t be used in “Simplified creation”, they need to be recoded into the screener directly.

    I found the Schaff trend cycle codes in these 2 posts: https://www.prorealcode.com/prorealtime-indicators/schaff-trend-cycle/

    and there: https://www.prorealcode.com/topic/dax-intraday-scalping-strategy/

    #34998 quote
    Francesco
    Participant
    Average

    Thank you for your answer Nicolas.

    I had already found indicators that You mention, but both of them draw a different graphic compared of Schaff Trend Cycle that comes with Prorelatime 10.3.

    I asked to Prorealtime support service and I’m waiting for an answer.

    However, in the meantime I found an interesting article here: http://traders.com/Documentation/FEEDbk_docs/2010/04/close.html

    In the article, the calculation method of STC is explained like this:

    *** Code Start ***

    SCHAFF TREND CYCLE EASYLANGUAGE CODE
    Inputs: TCLen (10), MA1 (23), MA2 (50);
     
    Plot1(_SchaffTC(TCLen,MA1,MA2), "Schaff_TLC");
    Plot2(25);
    Plot3 (75);
     
    Inputs: TCLen(NumericSimple), MA1(NumericSimple), MA2 (NumericSimple);
    Variables: XMAC(0), Frac1(0), PF(0), PFF(0), Frac2(0), Factor(.5);
     
    {Calculate a MACD Line}
    XMAC=MACD (c,MA1,MA2);
     
    {1st Stochastic: Calculate Stochastic of a MACD}
    Value1=Lowest (XMAC,TCLen);
    Value2=Highest (XMAC,TCLen) - Value1;
     
    {%Fast K of MACD}
    Frac1=IFF(Value2 > 0, ((XMAC-Value1)/Value2) * 100,Frac1[1]);
     
    {Smoothed Calculation for % Fast D of MACD}
    PF=IFF(CurrentBar <=1,Frac1,PF[1]+ (Factor * (Frac1-PF[1])));
     
    {2nd Stochastic: DCalculate Stochastic of smoothed Percent Fast D, 'PF', above}
    Value3=Lowest(PF,TCLen);
    Value4=Highest(PF,TCLen)-Value3;
     
    {% of Fast K of PF}
    FRAC2=IFF(Value4 > 0,((PF - Value3)/Value4) * 100,Frac2[1]);
     
    {Smoothed Calculation for %Fast D of PF}
    PFF=IFF(CurrentBar<=1,Frac2,PFF[1]+(Factor * (Frac2-PFF[1])));
     
    {The STC Function is the % Fast D of PF}
    _SchaffTC=PFF;

    *** Code end ***

    I tried to translate it, but I have 2 problems:

    1. In this formula: XMAC=MACD (c,MA1,MA2), the parameter c is not documented. It seems to be the cycle, but what is its default value?
    2. CurrentBar is a value that must be present in ProBuilder also. Maybe is it BarIndex?

    Thanks.

    #35003 quote
    Nicolas
    Keymaster
    Legend
    1. c = Close
    2. Yes you can translate this instruction with “BarIndex” in Probuilder
    #35009 quote
    Francesco
    Participant
    Average

    Thanks.

    #35019 quote
    Francesco
    Participant
    Average

    I translated the code, but my indicator plots nothing and I can’t find the error.

    
    //input parameters
    TCLen = 10
    MA1 = 23
    MA2 = 50
    
    Once Factor = 0.5
    
    //{Calculate a MACD Line}
    XMAC = ExponentialAverage[MA1](Close) - ExponentialAverage[MA2](Close)
    
    //{1st Stochastic: Calculate Stochastic of a MACD}
    Value1 = Lowest[TCLen](XMAC)
    Value2 = Highest[TCLen](XMAC) - Value1
    
    //{%Fast K of MACD}
    if Value2 > 0 then
    Frac1 =  ((XMAC - Value1)/Value2) * 100
    else
    Frac1 = Frac1[1]
    endif
    
    //{Smoothed Calculation for % Fast D of MACD}
    if BarIndex <=1 then
    PF = Frac1
    else
    PF = PF[1] + (Factor * (Frac1 - PF[1]))
    endif
    
    //{2nd Stochastic: DCalculate Stochastic of smoothed Percent Fast D, 'PF', above}
    Value3 = Lowest[TCLen](PF)
    Value4 = Highest[TCLen](PF) - Value3
    
    //{% of Fast K of PF}
    if Value4 > 0 then
    Frac2 = ((PF - Value3)/Value4) * 100
    else
    Frac2 = Frac2[1]
    endif
    
    //{Smoothed Calculation for %Fast D of PF}
    if BarIndex <= 1 then
    PFF = Frac2
    else
    PFF = PFF[1] + (Factor * (Frac2 - PFF[1]))
    endif
    
    //return PFF
    RETURN PFF
    
    #35367 quote
    Nicolas
    Keymaster
    Legend

    I think you should embed the whole code into a condition that test if enough barindex has passed to completely calculate the longer moving average. Tell me if I’m not clear enough 🙂

    #35720 quote
    Francesco
    Participant
    Average

    I reviewed code translation: “<=” operator needs to be inverted to “>=” on both code lines 24 and 42.

    The result is on the attached image: the first Schaff Trend Indicator is the ProRealTime built-in, the second “My Schaff Trend Cycle” is the translated indicator.

    Curves are a little bit different, but inversion points are the same.

    Now I can use it to build a screener.

    Nicolas thanked this post
    My-STC.png My-STC.png
    #42380 quote
    Nicolas
    Keymaster
    Legend

    I made some improvements from you code @Francesco, thanks for taking the time to translate it. Now the indicator seems almost identical than the one of the platform. I certainly add your indicator to the library, since the code of the Schaff trend cycle is an often query in the forums 🙂

    //input parameters
    TCLen = 10
    MA1 = 23
    MA2 = 50
    
    Once Factor = 0.5
    
    if barindex>MA2 then 
    //{Calculate a MACD Line}
    XMAC = ExponentialAverage[MA1](Close) - ExponentialAverage[MA2](Close)
    
    //{1st Stochastic: Calculate Stochastic of a MACD}
    Value1 = Lowest[TCLen](XMAC)
    Value2 = Highest[TCLen](XMAC) - Value1
    
    //{%Fast K of MACD}
    if Value2 > 0 then
    Frac1 =  ((XMAC - Value1)/Value2) * 100
    else
    Frac1 = Frac1[1]
    endif
    
    //{Smoothed Calculation for % Fast D of MACD}
    PF = PF[1] + (Factor * (Frac1 - PF[1]))
    
    //{2nd Stochastic: DCalculate Stochastic of smoothed Percent Fast D, 'PF', above}
    Value3 = Lowest[TCLen](PF)
    Value4 = Highest[TCLen](PF) - Value3
    
    //{% of Fast K of PF}
    if Value4 > 0 then
    Frac2 = ((PF - Value3)/Value4) * 100
    else
    Frac2 = Frac2[1]
    endif
    
    //{Smoothed Calculation for %Fast D of PF}
    PFF = PFF[1] + (Factor * (Frac2 - PFF[1]))
    endif
    
    RETURN PFF, 75 coloured(0,0,255) as "level 75", 25 coloured(0,0,255) as "level 25"

    NOW IN LIBRARY : Schaff Trend Cycle 

    #42454 quote
    Francesco
    Participant
    Average

    Thanks Nicolas.

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

Why Can't use or call some indicator?


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
Francesco @f-malagrida Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by Francesco
9 years, 1 month ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 05/07/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...