Code to show percentage of close from high

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #153018 quote
    Sam Macy
    Participant
    Junior

    I have a screener that’s running well and I am looking to introduce a new line of code to give a percentage of how far the close is from the high of the day.

    The screener already has five conditions. one that the stock must have: close > open.

    My thinking is that the code will be the criteria to sort the filtered stocks.

    So far this is what I have:

    Total = high-low
    CloseDiff = high-close
    
    criteria = IF (close=high) THEN return close as "Bull" ELSE return (CloseDiff/Total) ENDIF
    
    SCREENER [condition1 and condition2 and condition3 and condition4 and condition5](criteria as "CloseRange")

    My syntax is wrong and I can’t figure out where I’m going wrong. Basically if the close is the high, I want to return “Bull” to signify that, otherwise I’d like to see the percentage the close is away from the day’s high.

    Any thoughts on where I’m going wrong? This is the first time I’ve tried an IF THEN ELSE statement.

    #153023 quote
    robertogozzi
    Moderator
    Master

    RETURN is a reserved keyword of ProBuilder (for indicators).

    a screener can only return conditions with the keyword SCREENER.

    I can’t understand exactly what you want to be returned, but I suggest that you try replacing lines 4-6 with:

    IF (close=high) THEN
       SCREENER [condition1 and condition2 and condition3 and condition4 and condition5](close as "Bull")
    ELSE
       SCREENER [condition1 and condition2 and condition3 and condition4 and condition5](CloseDiff/Total)
    ENDIF
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Code to show percentage of close from high


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
Sam Macy @iainhmclean Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
5 years, 3 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 12/09/2020
Status: Active
Attachments: No files
Logo Logo
Loading...