'3 White Soldiers

This is a script for 3 White soldiers.

  1. I have this issue:- Pine version is not specified, compiling script as Pine v1. If you want to use another version, add '//@version={version_number}' to the beginning of the script Script 'Three White Soldiers' has been saved

Do I simply add this ( //@version=5 ) at the after this line ( // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ )

So it looks like this:-

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 //Three White Soldiers :D

  1. How would you change this to look for 2 candles not 3 in a row?

This is a three candlestick bullish reversal pattern following a downtrend. // Each successive candlestick opens lower than the previous close and then closes // higher than the previous close.

study(title = "Three White Soldiers", overlay = true) barcolor(close > open ? close[1] > open[1] ? close[2] > open[2] ? close > high[1] ? close[1] > high[2] ? open < close[1] ? open[1] < close[2] ? (high - close ) * 3 < close - open ? (high[1] - close[1]) * 3 < close[1] - open[1] ? (high[2] - close[2]) * 3 < close[2] - open[2] ? yellow : na : na : na : na : na : na:na : na : na : na)

  1. For a alert do I add this line:- alertcondition(Three White Soldiers, title='WS', message='WS')

Whole code

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 //Three White Soldiers :D

// Each successive candlestick opens lower than the previous close and then closes // higher than the previous close.

study(title = "Three White Soldiers", overlay = true) barcolor(close > open ? close[1] > open[1] ? close[2] > open[2] ? close > high[1] ? close[1] > high[2] ? open < close[1] ? open[1] < close[2] ? (high - close ) * 3 < close - open ? (high[1] - close[1]) * 3 < close[1] - open[1] ? (high[2] - close[2]) * 3 < close[2] - open[2] ? yellow : na : na : na : na : na : na:na : na : na : na)

alertcondition(Three White Soldiers, title='WS', message='WS')

Cheers



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source