Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

How to create a function Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Neednbucks
Posted : Wednesday, August 4, 2010 9:01:34 AM
Registered User
Joined: 10/15/2005
Posts: 9
I'm new here and trying to pick up realcode.  I'd like to create a function which I can then use on custom indicators   As an example, I would like to be able to process a given indicator (such as RSI or Stochastic) to determine whether there has been a change in the rate of change  between the current bar and previous bar as compared to previous bar and the preceeding bar.

Presumably, this function could then be called like any other function (AVG, XAVG) for any other indicator.

Is this possible? 
Kuf
Posted : Wednesday, August 4, 2010 9:42:37 AM


Administration

Joined: 9/18/2004
Posts: 3,522
You cannot currently make your own global functions. (like AVG, XAVG).  This is functionality we would like to include in a future release.

Ken Gilb (Kuf)
Chief Software Engineer - Worden Brothers Inc.
Try/Catch - My RealCode Blog
jas0501
Posted : Wednesday, August 4, 2010 10:29:24 AM
Registered User
Joined: 12/31/2005
Posts: 2,499
You can however write a general function and then cut and paste it into the class modude and call it from your condition or indicator

place code witn class module like so:

function whatever(current as single, previous as single, preceeeding as single) as single
dim val
    '
    '  insert logic here
    '
    whatever = val
end function

end class

and then just make calls to the function

    
value = whatever(RSI.value,RSI.value(1),RSI.value(2))
Neednbucks
Posted : Wednesday, August 4, 2010 11:47:57 AM
Registered User
Joined: 10/15/2005
Posts: 9
Bingo.  Exactly what I was looking for.  Thanks all.
Users browsing this topic
Guest-1

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.