Ref() function

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by Seer Seer 8 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3243

    waterstreet
    Member

    i am trying to REF to a historical number. i understand the example given

    ref(Close,-1); # which shows the last close of a bar.

    but what if i want to show the last value of a indicator for example

     my $mom =Momentum(Close,50);
      my $mom1 = ref($mom,-1);

    i tried that but it gave me the error ” Too many arguments for reference-type operator ”

    #3245
    Seer
    Seer
    Keymaster

    The best way to get the last value from a column/indicator in an event is with Now:

    Output Now(Momentum(Close,50)); #return the value for Momentum(Close,50) for the current bar

    and if you want to go futher bar in time, you can use Ago:

    Output Ago(Momentum(Close,50),5); #return the value for Momentum(Close,50) 5 bars ago

    Both Now and Ago return a value, while Ref returns a column and you would typically use Ref when building indicators.

    The error, ”Too many arguments for reference-type operator ” is due to you using “ref” rather than “Ref”.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.