How to check current candle is bigger than previous n candles or not?

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

    Hi,

    I’d like to know how to write a code which allow to check if current candle has a larger body than previous n candles or not. This checking keep repeating when next candle starts.

    Thanks

    #72848 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    This should do

    ONCE n      = 20
    Body        = abs(close - open)
    HighestBody = (Body = highest[n](Body))
    RETURN HighestBody
    Nicolas and chichihang thanked this post
    #72860 quote
    VonasiVonasi
    Moderator
    Master

    That code can also be adapted easily to look for the largest range in n candles.

    Numcandles = 20
    
    Rnge = abs(High - Low)
    LargestRange = (Rnge = highest[NumCandles](Rnge))
    
    RETURN LargestRange
    

    and also sometimes it is interesting to know when a candle has the smallest body or range in n candles. Quite useful to get out of the market with your profit when the market has gone a bit flat.

    NumCandles = 20
    
    Body = abs(close - open)
    SmallestBody = (Body = lowest[NumCandles](Body))
    
    Rnge = abs(High - Low)
    SmallestRange = (Rnge = lowest[NumCandles](Rnge))
    
    Nicolas and chichihang thanked this post
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

How to check current candle is bigger than previous n candles or not?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
chichihang @chichihang Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/11/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...