[pshaiCmd] MA-based Trend Detection System

3 686 Views No Comments 3 years ago
  • Hello!

    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.

    Example script:

    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[1]
    local step = matds[2]
    if trend == 1 and step == 0 then
    elseif trend == -1 and step == 0 then

    I sincerely hope you like this wonderful piece of code and/or can benefit from it.

    -= May the profits be with you =-

    HaasScript Code
    Sign in or Register to download for free
  • Phemex x HaasOnline Promotion Type: contest Expires: May 31, 2024 Exclusive
    Receive up to 1,200 USDT! The more you trade, the more you earn.
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free