Climax Indicator

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #39709 quote
    phoenix1914
    Participant
    New

    Hello all

    I am new to programming with pro-real code, so I need your help with the below.

    I try to create an indicator of the buy/sell climax. In theory a buy climax occurs if a stock has a new 52 week high but then closes below previous week’s close. In my first approach to the code I tried to compile only the first part – meaning to check if a stock has a new 52 week high (then I will think the rest). I put the following code.

    My result is that bclimax is always 0, although I would expect to have 1 also in many days that had high. What am I missing here?

    IF DHigh(0) > Highest[365] THEN
    bclimax = 1
    ELSE
    bclimax = 0
    ENDIF
    
    return bclimax AS "Buy Climax"
    
    #39710 quote
    Nicolas
    Keymaster
    Master

    Because you are trying to check a condition that can’t exist. The current High cannot be superior to the Highest high, it is the Highest high 🙂 So you’ll have to check is the current High is above the highest one, 1 bar ago, like in this code:

    IF DHigh(0) > Highest[365][1] THEN
    bclimax = 1
    ELSE
    bclimax = 0
    ENDIF
    
    return bclimax AS "Buy Climax"

    EDIT: there is no 365 trading days in year. You should adapt this lookback period to get something near the real value.

    #39758 quote
    phoenix1914
    Participant
    New

    Thank you!!! Also for noticing the 365 – I am so used from calculating interest rates and didn’t even think of it :/

    It worked (i think it works at least for now) amending the code as follows – from some sample data looks like it works as expected

    Again appreciated

    IF  DHigh(0) > Highest[260][1] THEN
    IF Dclose(0) < Highest[5][1] THEN
    bclimax = 1
    ELSE
    bclimax = 0
    ENDIF
    ELSE
    bclimax=0
    ENDIF
    
    return bclimax AS "Buy Climax"
    Nicolas thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Climax Indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by phoenix1914
8 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/03/2017
Status: Active
Attachments: No files
Logo Logo
Loading...