defparam cumulateorders=false
///////////////////////////////////////////////////////
//------------------Inputs------------------------------
signallength = 11 //integer//Signal Smoothing
smasignal = 1 //boolean // Simple MA (Signal Line)
linreg = 1 //boolean//Linear Regression
linreglength = 11//integer//Linear Regression Length
//------------------------------------------------------
//-------------Candle definition------------------------
if linreg then
bopen = LinearRegression[linreglength](open)
bhigh = LinearRegression[linreglength](high)
blow = LinearRegression[linreglength](low)
bclose = LinearRegression[linreglength](close)
else
bopen = open
bhigh = high
blow = low
bclose = close
endif
//--------------------------------------------------------
//--------------Color candles-----------------------------
green=bopen < bclose
red=bopen>=bclose
//---------------------------------------------------------
//---------------Signal definition-------------------------
if smasignal then
signal = average[signallength](bclose)
else
signal = average[signallength,1](bclose)
endif
//---------------------------------------------------------
if green and bclose crosses over signal then
buy 1 contract at market
endif
if red and bclose crosses under signal then
sellshort 1 contract at market
endif