74 lines
1.7 KiB
Plaintext
74 lines
1.7 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center Swing Stop Losses Indicator
|
|
// ---------------------------------------------
|
|
// saherelm implementation of above indicator ...
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
|
|
//
|
|
//@version=5
|
|
indicator(title="SaherElm Swing Stop Losses Indicator", shorttitle = "XS_SWSL_IND", overlay = true)
|
|
|
|
//
|
|
// START Inputs ....
|
|
//
|
|
swingLoopback = input.int(defval = 7, title = "Swing Loopback Period")
|
|
|
|
showLongStopLoss = input.bool(defval = true, title = "Show Long Stop Losses")
|
|
showShortStopLoss = input.bool(defval = true, title = "Show Short Stop Losses")
|
|
//
|
|
// END Inputs ....
|
|
//
|
|
|
|
//
|
|
// START Functions ....
|
|
//
|
|
//
|
|
// END Functions ....
|
|
//
|
|
|
|
//
|
|
// START Calculations ....
|
|
//
|
|
//
|
|
lastMarketLowest = ta.lowest(low, swingLoopback)
|
|
lastMarketLowest2 = ta.lowest(low, swingLoopback * 2)
|
|
lastMarketLowest3 = ta.lowest(low, swingLoopback * 3)
|
|
|
|
//
|
|
lastMarketHighest = ta.highest(high, swingLoopback)
|
|
lastMarketHighest2 = ta.highest(high, swingLoopback * 2)
|
|
lastMarketHighest3 = ta.highest(high, swingLoopback * 3)
|
|
//
|
|
// END Calculations ....
|
|
//
|
|
|
|
//
|
|
// START Plots ....
|
|
//
|
|
//
|
|
// Stop Losses ...
|
|
plot(series = showLongStopLoss ? lastMarketLowest : na, color = color.fuchsia, linewidth = 1, style = plot.style_stepline, title = "Long Stop Loss")
|
|
plot(series = showShortStopLoss ? lastMarketHighest : na, color = color.aqua, linewidth = 1, style = plot.style_stepline, title = "Short Stop Loss")
|
|
//
|
|
// END Plots ....
|
|
//
|
|
|
|
//
|
|
// START Alerts ...
|
|
//
|
|
//
|
|
// END Alerts ...
|
|
//
|
|
|
|
//////////////////////////////////////////////////////
|
|
// TODOS:
|
|
// -------
|
|
// - []
|
|
//////////////////////////////////////////////////////
|