[pshaiCmd] MA-based Trend Detection System

3 345 Views No Comments 1 year 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
        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 =-
    ~pshai

    • This topic was modified 1 year, 5 months ago by pshai.
    • This topic was modified 1 year, 5 months ago by pshai.
    • This topic was modified 1 year, 5 months ago by pshai. Reason: added ADX confirmation
    • This topic was modified 1 year, 5 months ago by pshai.
    HaasScript Code
    Sign in or Register to download for free
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free