How to get or determine the barIndex or number by the cross point

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #264992 quote
    thomas2004ch
    Participant
    Senior

    Assumed 6 days ago and 12 days ago there were MACD crossover. How can I get or determine their barIndex, so I can get the value of the MACD Line?

    cross.png cross.png
    #264994 quote
    robertogozzi
    Moderator
    Legend

    Use BarsSince (https://www.prorealcode.com/documentation/barssince/):

    CrossOver  = MACD[12,26,9](close) crosses over 0
    CossingBar = BarsSince(CrossOver)
    

    CossingBar contains the bar ID where the crossover occurred.



    thomas2004ch thanked this post
    #265000 quote
    thomas2004ch
    Participant
    Senior


    robertogozzi wrote: Use BarsSince (https://www.prorealcode.com/documentation/barssince/): CrossOver = MACD[12,26,9](close) crosses over 0 CossingBar = BarsSince(CrossOver) Copy CossingBar contains the bar ID where the crossover occurred. thomas2004ch thanked this post

    Many thanks!


    I simply use the example code here: https://www.prorealcode.com/documentation/barssince/


    But how can I understand the values? Here is a screenshot. The “previous occurrence” is 5 and the “last occurrence” is 0. By the second screenshot, the “previous occurrence” is 8 and the “last occurrence” is still 0

    RSI_Crossover.png RSI_Crossover.png RSI_Crossover_2.png RSI_Crossover_2.png
    #265002 quote
    robertogozzi
    Moderator
    Legend

    I can’t figure out why your data seem to be wrong.

    Mine are correct as you can see from my attached picture.

    I remind you that 0 is the current bar, 1 is the first bar preceding the current bar, …. 7 is the seventh bar prior to the current one. So 0 means the crossover occurred on the CURRENT bar.



    x-1.jpg x-1.jpg
    #265004 quote
    thomas2004ch
    Participant
    Senior


    robertogozzi wrote: I can’t figure out why your data seem to be wrong. Mine are correct as you can see from my attached picture. I remind you that 0 is the current bar, 1 is the first bar preceding the current bar, …. 7 is the seventh bar prior to the current one. So 0 means the crossover occurred on the CURRENT bar.

    Ok, now I got it. Many thanks!

    robertogozzi thanked this post
    RSI_Crossover-1.png RSI_Crossover-1.png
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

How to get or determine the barIndex or number by the cross point


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by thomas2004ch
5 hours, 13 minutes ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 09/08/2026
Status: Active
Attachments: 5 files
Logo Logo
Loading...