TREMA didnt show correctly.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #226922 quote
    dipontdipont
    Participant
    Junior

    I have been searching for a long time for the code of TREMA in various languages. I tried using the code in the library. TRSMA seems to work correctly, but TREMA didn’t. I am trying to obtain the SPX price during Regular Trading Hours (RTH) as displayed on SPTRD SP500 charts. In Pine Script, it was easy to extract the EMA from another ticker. Could someone provide a hint on how to correctly implement this?

    // TREMA
    //
    // Time Range Exponential Moving Average
    //
    DEFPARAM CalculateOnLastBars = 20000
    Periods    = 200
    StartTime  = 153000
    EndTime    = 220000
    
    //
    Alpha = 2 / (Periods + 1)
    i     = 0
    TREMA = close
    FOR j = 0 TO 3000
    IF opentime[j] >= StartTime AND opentime[j] <= EndTime THEN
    i = i + 1
    TREMA = ((close[j] - TREMA) * Alpha) + TREMA
    IF i = Periods THEN
    BREAK
    ENDIF
    ENDIF
    NEXT
    IF TREMA = 0 THEN
    TREMA = close
    ENDIF
    Return TREMA AS "TREMA"
    
    Bildschirmfoto-2024-01-26-um-20.29.18.jpg Bildschirmfoto-2024-01-26-um-20.29.18.jpg Bildschirmfoto-2024-01-26-um-20.31.52.png Bildschirmfoto-2024-01-26-um-20.31.52.png
    #226933 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Calculations are made accord to the time range you selected.

    What do you think is not working?

    #226965 quote
    dipontdipont
    Participant
    Junior

    Just as I have attached two photos, you can see the difference. Essentially, if the TREMA only reacts within the time range that I have chosen, it should not change outside of this time range, right?”

    Bildschirmfoto-2024-01-26-um-20.31.52-1.png Bildschirmfoto-2024-01-26-um-20.31.52-1.png Bildschirmfoto-2024-01-26-um-20.29.18-1.jpg Bildschirmfoto-2024-01-26-um-20.29.18-1.jpg
    #227069 quote
    NicolasNicolas
    Keymaster
    Legend

    It changes because you set TREMA=close at line 13, even outside the desired time window.

    #227365 quote
    dipontdipont
    Participant
    Junior

    thanks a lot. without this line looks better. BUT, the ema is still not right… Please check the screenshot. the price was rising but ema not.

    Bildschirmfoto-2024-02-03-um-20.27.02.png Bildschirmfoto-2024-02-03-um-20.27.02.png
    #227675 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    An 800-period EMA will take 800 of the selected bars within the desired time range to be aware of that rise.

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

TREMA didnt show correctly.


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
dipont @dipont Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/26/2024
Status: Active
Attachments: 5 files
ProRealCode ProRealCode
Loading...