ATR by candlestick type

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #121021 quote
    jayvee
    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
    robertogozzi
    Moderator
    Master

    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
    jayvee
    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.

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 jayvee
5 years, 12 months ago.

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