Search code examples
pine-scriptalgorithmic-tradingtradingpine-script-v4

PineScript - Double Top-Bottom Confirmation Points (Variables)


new to PineScript!

I wanted to add entry/close strategy to my script using this indicator (https://www.tradingview.com/script/a0vTLaS6-Double-Top-Bottom-Ultimate-OS/), but I cannot find the variables for these points. enter image description here

So I would need the variables for Double bottom confirmation point and double top confirmation point, so I can add them to my strategy.entry and strategy.close. Also,The script was more than 300 lines so I figured it'd be better to share the original indicator.

cheers!


Solution

  • The calculate_double_pattern function (lines 78-117) returns 2 variables - doubleTop and doubleBottom which are declared in line 244 :[doubleTop, doubleBottom] = calculate_double_pattern()

    You can visualize the trigger on the chart by using the barcolor:

    bgcolor(doubleTop ? color.red : na)
    bgcolor(doubleBottom ? color.green : na)
    

    Note, however, that the original script offset the Double Top/Bottom label to the pivot point after confirmation of the pattern. As can bee seen below, the green backgound indicates the time of actualdoubleBottom variable trigger and the green label printed N bars earlier below the HL pivot point:

    enter image description here