Custom Formula assistance, Please. 5 day % gain / loss

seek Custom Formula

5 day Price percent Gain / Loss of a stock .

to be used as a SetVar(@ 5day%, (???))

must be capable of showing a LOSS or a GAIN as a Negative or Positive percentage.

can this be done?

thanks…

Try SetVar(@ 5day%, 100 * (close(0) - close(5))/close(5)). Absolute(Abs) not needed because prices are always positive. However, (close(0) - close(5)) can be negative giving you the negative percent change. This will be trading days and not calendar days.

While I don’t think that % is used in the way that #,$, or @ are in P123, I’d still be generally cautious about including a special character in a variable name. Personally, I’d prefer @5yearper to @5year%.

ShowVar (@5day, 100 * (close(0) - close(5))/close(5))

works perfectly…

see updated documentation for ShowVar() & SetVar()

ShowVar works … SetVar does not

thanks for the help