Double Dynamic Zone RSX [Loxx]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx

//@version=5
indicator("Double Dynamic Zone RSX [Loxx]",
     shorttitle='DDZRSX [Loxx]', 
     overlay = false, 
     timeframe="", 
     timeframe_gaps = true)
     
import loxx/loxxrsx/1
import loxx/loxxdynamiczone/3
greencolor = #2DD204
redcolor = #D2042D 



per = input.int(14, "Period", group = "Basic Settings") 
src = input.source(hlc3, "Source", group = "Basic Settings")  
dzper = input.int(70, "Dynamic Zone Period", group = "Basic Settings") 

buy1  = input.float(0.1 , "Dynamic Zone Buy Probability Level 1", group = "Levels Settings", maxval = 0.49)
buy2  = input.float(0.25 , "Dynamic Zone Buy Probability Level 2", group = "Levels Settings", maxval = 0.49)
sell1 = input.float(0.1 , "Dynamic Zone Sell Probability Level 1", group = "Levels Settings", maxval = 0.49)
sell2 = input.float(0.25 , "Dynamic Zone Sell Probability Level 2", group = "Levels Settings", maxval = 0.49)

rsx = loxxrsx.rsx(src, per)

buylout1 = loxxdynamiczone.dZone("buy", rsx, buy1, dzper)
buylout2 = loxxdynamiczone.dZone("buy", rsx, buy2, dzper)
sellout1 = loxxdynamiczone.dZone("sell", rsx, sell1, dzper)
sellout2 = loxxdynamiczone.dZone("sell", rsx, sell2, dzper)

midl = loxxdynamiczone.dZone("sell", rsx, 0.5, dzper)

plot(buylout1, "buy lvl 1", color = greencolor)
plot(buylout2, "buy lvl 2", color = bar_index % 2 ? greencolor : na)
plot(sellout1, "sell lvl 1", color = redcolor)
plot(sellout2, "sell lvl 1", color = bar_index % 2 ? redcolor : na)
plot(midl, "mid lvl", color = bar_index % 2 ? color.gray : na)

colorout = rsx < buylout1 ? greencolor : rsx > sellout1 ? redcolor : color.gray
plot(rsx, "RSX", color = colorout, linewidth = 2)


