Hello,
I am starting to script a downside deviation/sortino based script via attached instructions. This script is incomplete as I got stuck on the step of removing positive returns.
Is there a way to look at a variable’s value and keep it if its a negative return, but over ride it and make it zero if its a positive return?
Ex: IF R1 is less than zero, keep its value; but if R1 is greater than zero then make R1 zero.
Here is what I have so far:
//Downside Deviation - Sortino //Set minimum acceptable rate of return ( MAR ) MAR = .01; //Setup periods M12020 = MONTHNUM() == 1 and YEARNUM() == 2020; M22020 = MONTHNUM() == 2 and YEARNUM() == 2020; M32020 = MONTHNUM() == 3 and YEARNUM() == 2020; //etc //Get end of month values V1 = VALUEWHEN(M12020); V2 = VALUEWHEN(M22020); V3 = VALUEWHEN(M32020); //etc //Calculate the returns and subtract MAR R1 = ((V2/V1)-1) - MAR; R2 = ((V3/V2)-1) - MAR; //Keep the negative return values; adjust positive return values to zero.
Jeff