0% found this document useful (0 votes)
97 views

EngFilter LuaScript

This document defines an indicator for an engine trading strategy that uses moving averages, ATR, Aroon oscillator, and ADX to generate buy and sell signals. Input parameters can be configured for the MA period, ATR period, Aroon period, ADX period, and oscillator/indicator levels. Main and filter conditions are defined to identify entry signals and filter out false signals. Arrows will be plotted below/above bars when buy/sell signals are generated.

Uploaded by

Indigo Graficos
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views

EngFilter LuaScript

This document defines an indicator for an engine trading strategy that uses moving averages, ATR, Aroon oscillator, and ADX to generate buy and sell signals. Input parameters can be configured for the MA period, ATR period, Aroon period, ADX period, and oscillator/indicator levels. Main and filter conditions are defined to identify entry signals and filter out false signals. Arrows will be plotted below/above bars when buy/sell signals are generated.

Uploaded by

Indigo Graficos
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

instrument {

name = 'Eng+Filter',
short_name = 'Eng+Filter',
icon = 'https://cdn.pixabay.com/photo/2015/10/01/17/17/car-967387__340.png',
overlay = true
}

MaPeriod = input (5, "Ma Period", input.integer, 1)


MASource = input (1, "Ma Method", input.string_selection, averages.titles)

period = input (5, "Atr Period", input.integer, 1 )


fn = input (averages.ssma, "Atr Ma Method", input.string_selection,
averages.titles)

period1 = input (14, "Aroon Period", input.integer, 1, 200)


AroonValue = input (20, "Aroon Oscillator Level", input.double, 0.01, 100)

adx_period = input (14, "Adx Period", input.integer, 1)


di_period = adx_period
threshold = input (20, "Adx Level", input.double, 0, 100)

input_group {
"Buy",
colorBuy = input { default = "green", type = input.color},
}

input_group {
"Sell",
colorSell = input { default = "red", type = input.color},
}

----Start Aroon Oscillator


aroonOsc = ((bars_since_lowest (period1) - bars_since_highest (period1)) /
period1 )*100
----Finished Aroon Oscillator

----Start ATR
local avgTr = averages [fn]
local AtrX = avgTr(tr,period)
----Finished ATR

----Start MA
local avgMa = averages [MASource]
local MaX = avgMa(close,MaPeriod)
----Finished MA

----Start ADX
up_move = change (high)
down_move = -change (low)

pdm = iff (up_move > down_move and nz(up_move) > 0, up_move, 0)


mdm = iff (down_move > up_move and nz(down_move) > 0, down_move, 0)

atr = rma(tr, di_period)

pdi = 100 * rma (pdm / atr, di_period) -- DI+


mdi = 100 * rma (mdm / atr, di_period) -- DI-
adx = 100 * rma (abs (pdi - mdi) / (pdi + mdi), adx_period)
----Finished ADX

----Main Condition entry order


EngBuy = iff(close > open[1] and close > open and close[1] < open[1] and abs(close-
open) > abs(close[1]-open[1]) and abs(close-open) < abs(close[1]-open[1])*5 and
close > MaX ,true, false)
EngSell = iff(close < open[1] and close < open and close[1] > open[1] and
abs(close-open) > abs(close[1]-open[1]) and abs(close-open) < abs(close[1]-
open[1])*5 and close < MaX ,true, false)
----Finished Main Condition entry order

----Start filter fake signal


filterBuy = iff(abs(high-low) > AtrX and aroonOsc > AroonValue and adx > threshold
and adx[1] < adx,true,false)
filterSell = iff(abs(high-low) > AtrX and aroonOsc < -AroonValue and adx >
threshold and adx[1] < adx ,true,false)
----Finished filter fake signal

plot_shape(EngBuy == true and filterBuy == true,


"Call",
shape_style.arrowup,
shape_size.huge,
colorBuy,
shape_location.belowbar,
0,
"ENG",
colorBuy
)

plot_shape(EngSell == true and filterSell == true ,


"Put",
shape_style.arrowdown,
shape_size.huge,
colorSell,
shape_location.abovebar,
0,
"ENG",
colorSell
)

You might also like