Search code examples
pine-scriptpine-script-v5tradingalgorithmic-trading

Getting the 75% value of a candle


If the candle open is 10 and the close is 8. The value at 50% would be 9, how to algorithm the value at other percentages such as 75%/80%/85%..etc?


Solution

  • without knowing the exact syntax of this function, the calculation inside this function should be like this

    
    price(percentage) => (open > close) ? (close+(open-close)*percentage/100) : (open+(close-open)*percentage/100)
    

    or

    if (open > close) then
     return (close+(open-close)*percentage/100)
    else
     return (open+(close-open)*percentage/100)
    

    percentage as float value between 0...100