how do i calculate the value of an indicator on Nth previous bar?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #175711 quote
    borderlineJimborderlineJim
    Participant
    Senior

    hello again

    I was wondering if any of the programming wizards could help with some simple code…

    I would like to calculate the value of an indicator (ATR) on a previous bar so that I can potentially open positions if the volatility is rising…  I was thinking of using just 2 bars for this.  This will act somewhat like a filter.

    Simply put:  if after 2 bars the volatility is rising based on the ATR value, then I will look to open a position on the 3 bar (using a trigger from a lower time-frame).  I hope this makes sense.

    Kind Regards

    Jim

    #175719 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Simply use [N] to refer to the previous Nth bar.

    ATR = AverageTrueRange[14](close)
    IF ATR[2] THEN    //check the ATR value 2 bars ago
     .
     .
    ENDIF
    borderlineJim thanked this post
    #175762 quote
    borderlineJimborderlineJim
    Participant
    Senior

    thanks again Roberto!

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 do i calculate the value of an indicator on Nth previous bar?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by borderlineJimborderlineJim
5 years, 1 month ago.

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