ATR by candlestick type

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

    Hi, was wondering if someone could help please. Is it possible to code the atr by candlestick type e.g. for the past 10 bars, only calculate the atr for green bars?

    #121023 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    // Calculation of ATR
    p       = 10
    Bullish = close >  open
    MyTR = max(Range,max(abs(high - close[1]),abs(low - close[1])))
    IF BarIndex < p THEN
       IF Bullish THEN
          MyATR = MyTR
       ELSE
          MyATR = MyATR[1]
       ENDIF
    ELSE
       IF Bullish THEN
          MyATR = ((MyATR[1] * (p - 1)) + MyTR) / p
       ELSE
          MyATR = MyATR[1]
       ENDIF
    ENDIF
    RETURN MyATR AS "Atr"
    jayvee and Paul thanked this post
    #121050 quote
    jayveejayvee
    Participant
    Average

    Thank you Roberto – you are great!

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

ATR by candlestick type


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
jayvee @jayvee Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/03/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...