[r4stl1n] Laser Trend Indicator

0 308 Views No Comments 4 months ago
  • Laser Trend Indicator

    Its a simple 1 MA and 2 EMA indicator.

    Source: https://www.forexstrategiesresources.com/scalping-system-iv/576-laser-trend/

    HaasScript Code
    -- [r4stl1n] Laser Trend Indicator
    -- This indicator is part of my bored and programming series where i pick different public forex strategies 
    -- and implement them into the haasscripts format to be used as examples.
    -- This is a starting version of the strategy expand it to add the stop loss and take profit
    -- Source: https://www.forexstrategiesresources.com/scalping-system-iv/576-laser-trend/
    -- You are on your own with this script
    -- ~Bored and programming series~
    -- Define command
    DefineCommand('LaserTrend', 'Laser Trend indicator')
    -- Define command parameters.
    local chartIndex = DefineParameter(NumberType, 'chartIndex', 'The index on which to chart', true, 0, 'Number')
    local name = DefineParameter(StringType, 'name', 'Unique name of the indicator.', false, '', 'Text')
    local interval = DefineParameter(NumberType, 'interval', 'Used interval for price data. Default is 0 and the main interval will be used.', false, 0, 'Number,InputInterval')
    -- This will improve our backtest speed when using the command.
    -- Input fields for the indicator.
    -- Calculate the indicator
    local prices = ClosePrices(interval)
    -- Moving Averages
    local emaShort = EMA(prices, 5)
    local emaLong = EMA(prices, 12)
    local sma = SMA(prices, 40)
    -- Determine the signal.
    local signal = SignalNone
    -- Plot the indicator Use the chartIndex parameter.
    Plot(0, 'LTEMAS', emaShort, Red)
    Plot(0, 'LTEMAL', emaLong, Green)
    Plot(0, 'LTSMA', sma, SkyBlue)
    if emaShort < emaLong and emaLong < sma then
        signal = SignalLong
    if emaShort > emaLong and emaLong > sma then
        signal = SignalShort
    --Return the custom signal.
    DefineOutput(EnumType, signal, 'Signal result', 'TradeBotContainer, IndicatorContainer, Signal Helpers')
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free