%Difference Price vs 20DMA

Forums ProRealTime English forum ProBuilder support %Difference Price vs 20DMA

  • This topic has 3 replies, 2 voices, and was last updated 2 days ago by avatarSagal.
Viewing 4 posts - 1 through 4 (of 4 total)
  • #250632

    Hello, it was something that somehow I was watching manually. However, on X Ole Hansen from Saxobank mentioned and displayed an indicator that mesure the % difference between the price and the 20DMA. For Gold, there has been some correction in the past when the difference is above 20%. As I’m not at all a programer I asked IA (DeepSeek) to produce a code. I think currently v. 13 beta is not working well for this kind of things, but anyway can one of you tell me if this code should do the work?

    //@version=13
    // Indicator: Price Deviation from 200 DMA
    // Based on concept described by Ole S. Hansen (Saxo Bank)

    // Input parameters
    DeviationThreshold = 20.0 // 20% threshold
    MALength = 200 // 200-period moving average

    // Calculate 200-period Simple Moving Average
    MA200 = average[200](close)

    // Calculate percentage deviation from the MA
    Deviation = (close / MA200 – 1) * 100

    // Plot the deviation line
    RETURN Deviation AS “Deviation (%)”

    // Draw horizontal lines for the thresholds
    DRAWHLINE(DeviationThreshold) AS “Overbought Line”
    DRAWHLINE(-DeviationThreshold) AS “Oversold Line”
    DRAWHLINE(0) AS “Zero Line”

    // Color the background based on the deviation
    IF Deviation >= DeviationThreshold THEN
    DRAWONCE(1, color(200,0,0,80)) AS “Overbought Warning”
    ELSIF Deviation <= -DeviationThreshold THEN
    DRAWONCE(1, color(0,150,0,80)) AS “Oversold Warning”
    ENDIF

    #250635

    I wanted to say 200DMA

    #250636
    JS

    Hi,

    Try this one (the messages are realtime)…

    2 users thanked author for this post.
    #250648

    Thanks a lot! it is working properly, the IA I use is unable to properly convert pinestreet code into PRT code

    1 user thanked author for this post.
    avatar JS
Viewing 4 posts - 1 through 4 (of 4 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login