Hi. Its it possible to creta a stradegy from this indicator
Buy when candle is green an signal is crossing under close
sellshort when candle is red and signal is crossing over close
Linear Regression Candles
JSParticipant
Veteran
Hi,
What do you mean by “Buy when the candle is green and the signal is crossing the close”…
The
indicator consists of the “LinearRegressionCandles“ (which are red or green) and the “Signal Line“… but there‘s no “Close“ in it…
Do
you mean “Buy when the candle is green and the candle crosses over the signal line“ or “SellShort when the candle is red and the candle crosses under the signal line“…???
Hi
Here you have the code
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
JSParticipant
Veteran
That’s right, that’s the system… 😉