Here’s my latest command, an MA-based trend detection system.
This one utilizes only 1 moving average and price action!
Idea for the command was taken from this video: https://www.youtube.com/watch?v=bXOXc49IbCI
So basically, the system waits for a candle that is separated from the moving average. This is where the system starts to expect a possible reversal and records the high or the low of this candle. The reversal is confirmed once one of the next candles CLOSES above the recorded high or below the recorded low.
Simple as that! But effective AF!
The command outputs an object that has 2 values: “trend” and “step”.
The “trend” will tell you the direction of the trend: 0 == no trend, 1 == uptrend and -1 == downtrend.
The “step” will tell you whether we are waiting for a confirmation or not: 0 == not waiting/fullon, 1 == waiting for confirmation/possible reversal forming.
local threshold = PriceStep() local matds = CC_MATDS( threshold, -- threshold 100, -- MA length SmaType, -- MA type false, -- use ADX 14, -- ADX length 25, -- ADX confirmation level 60, -- interval 1, -- system type (0 or 1) false, -- use high-speed prices true, -- use plot true -- use logs ) local trend = matds local step = matds if trend == 1 and step == 0 then DoBuy() elseif trend == -1 and step == 0 then DoSell() end
I sincerely hope you like this wonderful piece of code and/or can benefit from it.
-= May the profits be with you =-