hi,
is there an accurate trend detention method out there?
thanks
If you can definite in logic what is a trend, then it can be possible to code an accurate method 🙂
when i look at i chart, i draw a straight line of best fit across all candles and if the angle with respect to the horizontal is greater than 0 then it is a uptrend. vice versus for downtrend.
i guess moving average is a good starter
Ok, so you are looking at regression line slope, so you’ll get the same with:
bullish = linearregressionslope[max(1,barindex)] > 0
bearish = linearregressionslope[max(1,barindex)] < 0
return bullish coloured(0,255,0) style(histogram), bearish coloured(255,0,0) style(histogram)
how does the return command work?
DEFPARAM CUMULATEORDERS = false
bullish = linearregressionslope[max(1,barindex)] > 0
bearish = linearregressionslope[max(1,barindex)] < 0
return bullish coloured(0,255,0) style(histogram), bearish coloured(255,0,0) style(histogram)
if bullish then
buy 1 contracts at market
endif
if bearish then
sellshort 1 contracts at market
endif
set stop ploss 30
set target profit 45
says there is some error on the return line
You have posted strategy code. RETURN is only used in indicators. Nicolas provided indicator code. Delete the RETURN line in your strategy.