Possibility to count number of bars since a given condition

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #67465 quote
    kem2709kem2709
    Participant
    Junior

    Hello Everyone,

    I would like to ask for your help as for the following issue: is there any code that would let me calculating a number of bars since supertrend indicator was crossed by the price? The beginning of my code is:

    If close crosses over supertrend then “rise”

    Now the issue is that based on prorealtime handbook, i cannot use barindex to calculate the number of bars starting from the point when price crossed over supertrend.

    Thank you in advance for your help.

    Kind regards,

    Kemel

    #67470 quote
    LeoLeo
    Participant
    Veteran

    Hi, create a variable where to save the moment of crossing. That moment is BarIndex

    like:

    If close crosses over mySupertrend then
    CrossingPosition = barindex
    Endif
    
    DistanceToCrossingPosition=Barindex-CrossingPosition
    Midlanddave thanked this post
    #167816 quote
    DawadamDawadam
    Participant
    New

    Thanks

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

Possibility to count number of bars since a given condition


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
kem2709 @kem2709 Participant
Summary

This topic contains 2 replies,
has 1 voice, and was last updated by DawadamDawadam
5 years, 5 months ago.

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