Best delta gridTrading
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bitouns

//@version=5

indicator(title="Best delta gridTrading", shorttitle="BDGT%", overlay=false)
length =  input(10, title="length")
takerfees =  input(0.0665, title="exchange taker fees in %")

bestDeltaGridTrading = math.max(ta.sma(ta.tr*100/close[1], length)/2*close[1]/100,2*takerfees/100*close[1])
plot(bestDeltaGridTrading, color=color.red)
