Count 5-10candle sticks that closes above 50 ema

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

    Hi,

     

    I want to count how many candles (before a bearish engulfing candle) that closes above the exponential moving average. I just cant figure out how to code it. I tried For-do-next and failed. can anyone help me with this?

    #99256 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    Bullish   = close > open
    Bearish   = close < open
    Opposite  = (Bearish AND Bullish[1]) OR (Bearish[1] AND Bullish)
    Body      = abs(close - open)
    Engulfing = (Body > Body[1]) AND Opposite
    BearishEng= Engulfing AND Bearish AND (Open >= close[1]) AND (close <= open[1])
    MyEma     = average[50,1](close)
    BarCount  = 0
    If BearishEng THEN
       FOR i = BarIndex - 1 DOWNTO 1
          x = BarIndex - i
          IF close[x] > MyEma[x] THEN
             BarCount = BarCount + 1
          ELSE
             BREAK
          ENDIF
       NEXT
    ENDIF
    RETURN BarCount
    #99289 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I just edited line 6.

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

Count 5-10candle sticks that closes above 50 ema


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Jehsgo @jehson_go Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/23/2019
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...