Trading Platform Software for backtesting & auto trading, for stock, futures and forex trading systems › Forums › General Questions › Ref() function
This topic contains 1 reply, has 2 voices, and was last updated by Seer 8 years, 11 months ago.
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 ”
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”.
You must be logged in to reply to this topic.