Register Login
Forums    February 9, 2012
TradersStudio Forums
Counting occurances in a bar array
Last Post 08-25-2008 04:44 PM by mur ang. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Brandon Hicks
New Member
New Member
Posts:16

--
08-25-2008 01:46 PM

    If I build a bar array of data, is there a function or technique that would allow me to count the occurances of a specific value over a specific number of bars?

    Example:

    A bar array "data1" is built that stores a "1" if C>C[1] and a "0" if C<=C[1].  I want to count the number of occurances of "1" in the past 200 bars, basically telling me how many days the market has close positive from the previous day in the past 200 days.

    Example2:

    I want to count the number of occurances where data1<>data1[1], the number of times a change of direction has occured or number of "runs" in the series.

     

     

    mur ang
    Advanced Member
    Advanced Member
    Posts:525

    --
    08-25-2008 04:44 PM

    Use Summation function to count them up.

    It should be in your version if not here is the script , it's a general function.

     

    '*******************************************************************
    ' TradersStudio(r) 2004-2007 , All rights reserved
    'Description: Summation
    ' Adds all the values passed to in, also takes the [] syntax.
    '********************************************************************
    Function Summation(Price As BarArray, Length) as bararray
        Dim Counter
        Dim CSum As BarArray

        Counter = 0
        CSum = 0

        CSum = 0
        For Counter = 0 To Length - 1
            CSum = CSum + Price[Counter]
        Next
        Summation = CSum
    End Function

     

    You are not authorized to post a reply.


     TradersStudio, Inc. ® Copyright 2004-2012 All Rights Reserved   Terms Of Use  Privacy Statement