Hi Everyone I am new to Optuma and very much to scripting and have been struggling with this for a while now so hope someone can help.
I would like to have a column script to show me the increase or decrease in percentage of the OBV over the last 5 bars.
I have the below so far and although working to a degree it very often returns a positive percentage when it fact it should be negative. I don’t appear to be able to get around it. I will put some examples below the script. Thanks for the help in advance. BNL was an increase but showing a decrease and the opposite for SMR
// Calculate the current OBV
CurrentOBV = OBV(); // Get the current On-Balance Volume
// Calculate the OBV from 5 bars ago
PreviousOBV = OFFSET(OBV(), OFFSET=5); // Get the OBV value from 5 bars ago
// Calculate the percentage increase in OBV
PercentageIncrease = ((CurrentOBV - PreviousOBV) / PreviousOBV) * 100; // Calculate the percentage increase
// Output the result
PercentageIncrease; // Show the final percentage increase