Minimum distance from Support or resistance

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #197890 quote
    Stocks008Stocks008
    Participant
    Average

    Good day,

    I am trying to code an indicator that will take support and resistance into account. I am struggling with the minimum distance from support or resistance part. Let’s say the support or resistance will be given by the 30 SMA and 100 SMA. The indicator should only draw instruction if the support or resistance ( 30 and 100 averages) is further away than 10 points from the current candle’s open price. Is there a way to do this and always get a positive value in points?

    I hope I made enough sense in my question.

    Thank you,

    Kind Regards

    #197892 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    ONCE Distance = 10 * PipSize
    MySupport     = average[30,0](close)
    MyResistance  = average[100,0](close)
    Signal        = 0
    IF open >= (MySupport + Distance) THEN
       Signal = -1
    ELSIF open <= (MyResistance - Distance) THEN
       Signal = 1
    ENDIF
    RETURN Signal AS "Signal"
    Stocks008 thanked this post
    #197899 quote
    Stocks008Stocks008
    Participant
    Average

    Thank you very much, I appreciate your help. 🙂

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

Minimum distance from Support or resistance


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Stocks008 @jd008 Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/25/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...