logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
gorachand  
#1 Posted : Wednesday, January 28, 2015 3:09:26 PM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 106

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)

On many Metastock formulas posted on the net you come across the Cum(1) code. What exactly is it used for?

For eg  Cum(1) = Min( p1c, p2c); or Cum(1)=H=L etc I have experimented  by deleting that part of the code and the result is the same. But the persons who posted it in the first place are knowledgeable persons and must have a reason. I would like to know the reason. 

Any help---anybody?

Regards,

Dr.Chatterjee

MS Support  
#2 Posted : Wednesday, January 28, 2015 7:03:40 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,971

Thanks: 94 times
Was thanked: 156 time(s) in 151 post(s)
Answering why based on tiny code fragments would be difficult although something like Cum(1)=H=L seems like nonsense to me.

The function simply takes a cumulative sum of whatever "condition" you specify over the life of the chart.

In the case of cum(1) it essentially takes a cumulative sum of 1 for each price plot in the chart, giving you the total number of bars at any given point in the chart.

Hence, if there are 500 price points in the chart, it would cumulate "1" 500 times, giving you a value of 500 as the last value. You would just see a diagonally sloping line.

 

If you use the function in a condition such as Cum(1) = 50 which would cause the indicator to "spike" up on the 50th bar in the chart.  This could be useful for identifying very specific bars in the chart.

Obviously you can get more advanced than this, comparing the cumulative sum to other values, or taking a cumulative sum of other things.

Edit:  Looks like Roy was answering at the same time as I was, thanks Roy!

Edited by user Wednesday, January 28, 2015 7:13:34 PM(UTC)  | Reason: Not specified

mstt  
#3 Posted : Wednesday, January 28, 2015 7:08:12 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi gorachand. Cum(1) returns the cumulative number of bars in a chart or data array. Create a new indicator with just Cum(1) in it and place it on any chart. You will see a straight line that plots 1 on the first bar, and on the last bar the indicator will plot the total number of bars. Cum(1) is simply a counter that increments from 1 on the first data bar to "N" on the "Nth" data bar. Cum(1)=1; is often used to mark or identify the first data bar. If you wanted to inhibit the result of a function, formula or line of code for 20 bars then the Cum() function could be used to do that as shown below, the cum() function inhibiting the result until there are 20 bars on the chart rather than 10 as for just Mov(C,10,E). ValueWhen(1, Cum(1)>20 ,Mov(C,10,E)); Roy
gorachand  
#4 Posted : Thursday, January 29, 2015 6:44:51 AM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 106

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)

Thank you Metastock support and Mr.Roy for your replies.

Could you give a few more illustrative examples of the  Cum/Cum(1) function?

For example

dateA:=Year()=2006 AND Month()=7; dateA:=If(LastValue(Cum(dateA))=0, Year()=LastValue(Year())-1 from http://www.metastocktool...taStock/2plot.txt---what exactly is the Cum function doing here?

Also,
Could you name a book more detailed than the Metastock formula primer for MSFL programming?

Regards,

Dr.Chatterjee

 

mstt  
#5 Posted : Thursday, January 29, 2015 7:55:55 AM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi gorachand I don't think explaining Jose's formula would help you very much so I'm not going to go there - it seems to me that there are more challenges in understanding Jose's code than just the Cum() function. I'll come back to some examples of the function shortly. First, you should read the MetaStock Formula Primer, a document that used to be included with all MetaStock installations as a PDF file. I'm sure there are other books or documents that would also be useful. Have you looked up Cum() in the MetaStock User Manual? I have a document called the "MSTT Formula Language Tutorial.doc" that might help your MetaStock education along if you're prepared to put in the time to study it. Email me at rlarsen@quik.co.nz for a free copy if you're interested. The document introduces a few elementary MetaStock-related topics over the first 15 or so pages, and then over the next 30+ pages goes into some detail over most of the 70 lines of code forming the Trade Equity GV LE indicator. Only one variable uses the Cum() function, and then only for generating a single bar TRUE once all essential inputs to the equity calculation are known to be valid (the inputs don't return an N/A result). The Cum() function is simply a counter. However there are many ways that you can use that ability to count. Roy
Users browsing this topic
Guest (Hidden)
Similar Topics
CUM FUNCTION NOT WORKING IN METASTOCK 7.0 (Formula Assistance)
by kalyan 12/26/2010 7:40:33 AM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.