Help with first indicator – 3% pullback with averages.

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

    Hi,

    I am new to writing the code and am struggling to get my first indicator to work.

    What I am trying to achieve is:

    • Based on daily closing prices
    • Close > 200 day simple moving average
    • Close has pulled back > 3% from the previous highest point
    • Close > 5 day simple moving average
    • Return 1

    Please could someone help me understand where to start with this.

    Thanks,
    Chris

    #118209 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go (I only tested it for syntax errors):

    HH = highest[100](high)                //100 lookback periods to find highest point
    c1 = close > average[200,0](close)     //close > sma200
    c2 = close <= (HH * 0.97)              //close at least equal to or less than 3% pullback
    c3 = close > average[5,0](close)       //close > sma5
    RETURN c1 AND c2 AND c3
    #118218 quote
    VonasiVonasi
    Moderator
    Master

    Here is an alternative. It resets the high to the current candle if the conditions are met so it can then look for a new drop from that fresh start.

    (not tested)

    hh = max(high,hh)            
    
    flag = 0
    if close < hh*0.97 and close > average[200,0](close) and close > average[5,0](close) then
    flag = 1
    hh = high
    endif
    
    RETURN flag

    Note: I have edited the title of your topic. Please try to use more meaningful titles that describe your topic rather than things like ‘Help needed’ otherwise we end up with a forum full of topics with meaningless titles! 🙂

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

Help with first indicator – 3% pullback with averages.


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
kalozo @kalozo Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/29/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...