Strategy · Pine Script v5 · On the chart

MTF EFI Strategy

by g-moe· code credited to goodgains

This strategy uses Elder Force Index on the price chart, combining price change with volume and a chosen moving-average smoother.

View on GitHub

Repaints

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code489
Settings40inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

489 lines of Pine Script v5 from Tradingview/mtf-efi-strategy.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

mtf-efi-strategy.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
strategy("MTF EFI Strategy", overlay=true, margin_long=100, margin_short=100)

// @keywords: mtf-efi, elder-force-index, multi-timeframe, volume-momentum, efi-threshold, ma-filter, long-short-strategy, timeframe-dashboard, aligned-signals, profit-target, stop-loss, session-filter, continuous-mode, inverse-signals, efi-crossover, strategy-entries, mtf-alignment, volume-force, signal-table, trade-management

// efi most have volume
var cumVol = 0.
cumVol += nz(volume)
if barstate.islast and cumVol == 0
    runtime.error("No volume is provided by the data vendor.")


// efi settings
efi_length = input.int(13, title = 'EFI Length',
 group = 'EFI Settings')

efi_type = input.string("EMA", title = 'EFI Smoothing',
 options = ['EMA', 'SMA', 'VWMA', 'RMA', 'HMA'],
 group = 'EFI Settings')


// signal settings
use_tf1 = input.bool(false, title = '', group='Signal Settings', inline = '1')
tf1 = input.timeframe("1", title = "", group='Signal Settings', inline = '1',
 tooltip = 'If the selected timeframe is less than the chart timeframe then it will cause a runtime error.')
_efibuy1 = input.int(0, title = '', group='Signal Settings', inline = '1')
_efisell1 = input.int(0, title = '', group='Signal Settings', inline = '1')

use_tf2 = input.bool(false, title = '', group='Signal Settings', inline = '2')
tf2 = input.timeframe("3", title = "", group='Signal Settings', inline = '2',
 tooltip = 'If the selected timeframe is less than the chart timeframe then it will cause a runtime error.')
_efibuy2 = input.int(0, title = '', group='Signal Settings', inline = '2')
_efisell2 = input.int(0, title = '', group='Signal Settings', inline = '2')

use_tf3 = input.bool(false, title = '', group='Signal Settings', inline = '3')
tf3 = input.timeframe("5", title = "", group='Signal Settings', inline = '3',
 tooltip = 'If the selected timeframe is less than the chart timeframe then it will cause a runtime error.')
_efibuy3 = input.int(0, title = '', group='Signal Settings', inline = '3')
_efisell3 = input.int(0, title = '', group='Signal Settings', inline = '3')

use_tf4 = input.bool(true, title = '', group='Signal Settings', inline = '4')
tf4 = input.timeframe("15", title = "", group='Signal Settings', inline = '4',
 tooltip = 'If the selected timeframe is less than the chart timeframe then it will cause a runtime error.')
_efibuy4 = input.int(0, title = '', group='Signal Settings', inline = '4')
_efisell4 = input.int(0, title = '', group='Signal Settings', inline = '4')

use_tf5 = input.bool(true, title = '', group='Signal Settings', inline = '5')
tf5 = input.timeframe("30", title = "", group='Signal Settings', inline = '5',
 tooltip = 'If the selected timeframe is less than the chart timeframe then it will cause a runtime error.')
_efibuy5 = input.int(0, title = '', group='Signal Settings', inline = '5')
_efisell5 = input.int(0, title = '', group='Signal Settings', inline = '5')

use_tf6 = input.bool(true, title = '', group='Signal Settings', inline = '6')
tf6 = input.timeframe("60", title = "", group='Signal Settings', inline = '6',
 tooltip = 'If the selected timeframe is less than the chart timeframe then it will cause a runtime error.')
_efibuy6 = input.int(0, title = '', group='Signal Settings', inline = '6')
_efisell6 = input.int(0, title = '', group='Signal Settings', inline = '6')

use_tf7 = input.bool(true, title = '', group='Signal Settings', inline = '7')
tf7 = input.timeframe("120", title = "", group='Signal Settings', inline = '7',
 tooltip = 'If the selected timeframe is less than the chart timeframe then it will cause a runtime error.')
_efibuy7 = input.int(0, title = '', group='Signal Settings', inline = '7')
_efisell7 = input.int(0, title = '', group='Signal Settings', inline = '7')

use_tf8 = input.bool(false, title = '', group='Signal Settings', inline = '8')
tf8 = input.timeframe("180", title = "", group='Signal Settings', inline = '8',
 tooltip = 'If the selected timeframe is less than the chart timeframe then it will cause a runtime error.')
_efibuy8 = input.int(0, title = '', group='Signal Settings', inline = '8')
_efisell8 = input.int(0, title = '', group='Signal Settings', inline = '8')

use_tf9 = input.bool(false, title = '', group='Signal Settings', inline = '9')
tf9 = input.timeframe("240", title = "", group='Signal Settings', inline = '9',
 tooltip = 'If the selected timeframe is less than the chart timeframe then it will cause a runtime error.')
_efibuy9 = input.int(0, title = '', group='Signal Settings', inline = '9')
_efisell9 = input.int(0, title = '', group='Signal Settings', inline = '9')

use_tf10 = input.bool(false, title = '', group='Signal Settings', inline = '10')
tf10 = input.timeframe("D", title = "", group='Signal Settings', inline = '10',
 tooltip = 'If the selected timeframe is less than the chart timeframe then it will cause a runtime error.')
_efibuy10 = input.int(0, title = '', group='Signal Settings', inline = '10')
_efisell10 = input.int(0, title = '', group='Signal Settings', inline = '10')


use_ma_filter1 = input.bool(false, title = "MA Filt", group = "Signal Settings", inline = '1')
use_ma_filter2 = input.bool(false, title = "MA Filt", group = "Signal Settings", inline = '2')
use_ma_filter3 = input.bool(false, title = "MA Filt", group = "Signal Settings", inline = '3')
use_ma_filter4 = input.bool(false, title = "MA Filt", group = "Signal Settings", inline = '4')
use_ma_filter5 = input.bool(false, title = "MA Filt", group = "Signal Settings", inline = '5')
use_ma_filter6 = input.bool(false, title = "MA Filt", group = "Signal Settings", inline = '6')
use_ma_filter7 = input.bool(false, title = "MA Filt", group = "Signal Settings", inline = '7')
use_ma_filter8 = input.bool(false, title = "MA Filt", group = "Signal Settings", inline = '8')
use_ma_filter9 = input.bool(false, title = "MA Filt", group = "Signal Settings", inline = '9')
use_ma_filter10 = input.bool(false, title = "MA Filt", group = "Signal Settings", inline = '10')

ma_type = input.string(title = "MA Type/Filter", defval = "SMA", options=['EMA', 'SMA', 'VWMA', 'RMA', 'HMA'], group="Signal Settings", inline = '11')
ma_filter_length = input.int(50, minval = 1, title = "", group = "Signal Settings", inline = '11')


// trading settings
useStrategyStart = input.bool(false, title = " ", group = "Trade Settings", inline = '1')
strategy_start = input.time(timestamp("01 January 2021 00:00:00 UTC-5"), "Strategy Start Date",
 group = "Trade Settings", inline = '1')

useStrategyEnd = input.bool(false, title = " ", group = "Trade Settings", inline = '2')
strategy_end = input.time(timestamp("01 January 2022 00:00:00 UTC-5"), "Strategy End Date  ",
 group = "Trade Settings", inline = '2')

useTradingHours = input.bool(false, title = " ", group = "Trade Settings", inline = '3')
trading_time = input.session("0930-1600", title = "Trading Time",
 tooltip = "This uses Eastern Time Zone or U.S. NY Market Hours.", group = "Trade Settings", inline = '3')
trading_hours_cond = not useTradingHours or time("",trading_time, "America/New_York")

long_trades = input.bool(true, title = "Long Trades" , group = "Trade Settings", inline = '5')
short_trades = input.bool(true, title = "Short Trades", group = "Trade Settings", inline = '5')
// trade_to_trade = input.bool(false, title = 'Trade to Trade', group = "Trade Settings", inline = '6')
inverse_signals = input.bool(false, title = "Inverse Signals", group = "Trade Settings", inline = '6')
continous_mode = input.bool(false, title = 'Continuous Mode', group = "Trade Settings", inline = '6')

use_tp = input.bool(false, title = 'Target          ', group = 'Trade Settings', inline = '7')
tp_amount = input.float(0.50, title = '', group = 'Trade Settings', inline = '7')
tp_type = input.string('Percent', title = '', options = ['Percent', 'Price'], group = 'Trade Settings', inline = '7')

use_sl = input.bool(false, title = 'Stop Loss      ', group = 'Trade Settings', inline = '8')
sl_amount = input.float(0.50, title = '', group = 'Trade Settings', inline = '8')
sl_type = input.string('Percent', title = '', options = ['Percent', 'Price'], group = 'Trade Settings', inline = '8')


// error checking
if barstate.isfirst and timeframe.in_seconds() > 
 math.min(timeframe.in_seconds(use_tf1 ? tf1 : "Y"), 
  timeframe.in_seconds(use_tf2 ? tf2 : "Y"),
  timeframe.in_seconds(use_tf3 ? tf3 : "Y"),
  timeframe.in_seconds(use_tf4 ? tf4 : "Y"),
  timeframe.in_seconds(use_tf5 ? tf5 : "Y"),
  timeframe.in_seconds(use_tf6 ? tf6 : "Y"),
  timeframe.in_seconds(use_tf7 ? tf7 : "Y"),
  timeframe.in_seconds(use_tf8 ? tf8 : "Y"),
  timeframe.in_seconds(use_tf9 ? tf9 : "Y"),
  timeframe.in_seconds(use_tf10 ? tf10 : "Y"))
    runtime.error("One of your selected timeframes is less than the main chart. This is not allowed.")


// efi function
f_efi(calc_bool) =>
    var float efi_value = na
    if calc_bool
        efi_value := switch efi_type
            "EMA" => ta.ema(ta.change(close[1]) * volume[1], efi_length)
            "SMA" => ta.sma(ta.change(close[1]) * volume[1], efi_length)
            "VWMA" => ta.vwma(ta.change(close[1]) * volume[1], efi_length)
            "RMA" => ta.rma(ta.change(close[1]) * volume[1], efi_length)
            "HMA" => ta.hma(ta.change(close[1]) * volume[1], efi_length)


// ma function
f_ma(calc_bool) =>
    var float ma_value = na
    var int return_bool = 0
    if calc_bool
        ma_value := switch ma_type
            "EMA" => ta.ema(close[1], ma_filter_length)
            "SMA" => ta.sma(close[1], ma_filter_length)
            "VWMA" => ta.vwma(close[1], ma_filter_length)
            "RMA" => ta.rma(close[1], ma_filter_length)
            "HMA" => ta.hma(close[1], ma_filter_length)

        return_bool := close[1] > ma_value ? 1 : close[1] < ma_value ? -1 : 0
    return_bool


// call efi function
efi_tf1 = math.round(request.security(syminfo.ticker, tf1, f_efi(use_tf1), lookahead = barmerge.lookahead_on),0)
efi_tf2 = math.round(request.security(syminfo.ticker, tf2, f_efi(use_tf2), lookahead = barmerge.lookahead_on),0)
efi_tf3 = math.round(request.security(syminfo.ticker, tf3, f_efi(use_tf3), lookahead = barmerge.lookahead_on),0)
efi_tf4 = math.round(request.security(syminfo.ticker, tf4, f_efi(use_tf4), lookahead = barmerge.lookahead_on),0)
efi_tf5 = math.round(request.security(syminfo.ticker, tf5, f_efi(use_tf5), lookahead = barmerge.lookahead_on),0)
efi_tf6 = math.round(request.security(syminfo.ticker, tf6, f_efi(use_tf6), lookahead = barmerge.lookahead_on),0)
efi_tf7 = math.round(request.security(syminfo.ticker, tf7, f_efi(use_tf7), lookahead = barmerge.lookahead_on),0)
efi_tf8 = math.round(request.security(syminfo.ticker, tf8, f_efi(use_tf8), lookahead = barmerge.lookahead_on),0)
efi_tf9 = math.round(request.security(syminfo.ticker, tf9, f_efi(use_tf9), lookahead = barmerge.lookahead_on),0)
efi_tf10 = math.round(request.security(syminfo.ticker, tf10, f_efi(use_tf10), lookahead = barmerge.lookahead_on),0)


// call ma function
ma_tf1 = request.security(syminfo.ticker, tf1, f_ma(use_tf1 and use_ma_filter1), lookahead = barmerge.lookahead_on)
ma_tf2 = request.security(syminfo.ticker, tf2, f_ma(use_tf2 and use_ma_filter2), lookahead = barmerge.lookahead_on)
ma_tf3 = request.security(syminfo.ticker, tf3, f_ma(use_tf3 and use_ma_filter3), lookahead = barmerge.lookahead_on)
ma_tf4 = request.security(syminfo.ticker, tf4, f_ma(use_tf4 and use_ma_filter4), lookahead = barmerge.lookahead_on)
ma_tf5 = request.security(syminfo.ticker, tf5, f_ma(use_tf5 and use_ma_filter5), lookahead = barmerge.lookahead_on)
ma_tf6 = request.security(syminfo.ticker, tf6, f_ma(use_tf6 and use_ma_filter6), lookahead = barmerge.lookahead_on)
ma_tf7 = request.security(syminfo.ticker, tf7, f_ma(use_tf7 and use_ma_filter7), lookahead = barmerge.lookahead_on)
ma_tf8 = request.security(syminfo.ticker, tf8, f_ma(use_tf8 and use_ma_filter8), lookahead = barmerge.lookahead_on)
ma_tf9 = request.security(syminfo.ticker, tf9, f_ma(use_tf9 and use_ma_filter9), lookahead = barmerge.lookahead_on)
ma_tf10 = request.security(syminfo.ticker, tf10, f_ma(use_tf10 and use_ma_filter10), lookahead = barmerge.lookahead_on)


// calculate efi tf side 
var int efi_side1 = 0
var int efi_side2 = 0
var int efi_side3 = 0
var int efi_side4 = 0
var int efi_side5 = 0
var int efi_side6 = 0
var int efi_side7 = 0
var int efi_side8 = 0
var int efi_side9 = 0
var int efi_side10 = 0

efi_side1 := not use_tf1 ? 99 : (efi_tf1 > _efibuy1 and ma_tf1 >= 0) ? 1 : (efi_tf1 < _efisell1 and ma_tf1 <= 0) ? -1 : 0
efi_side2 := not use_tf2 ? 99 : (efi_tf2 > _efibuy2 and ma_tf2 >= 0) ? 1 : (efi_tf2 < _efisell2 and ma_tf2 <= 0) ? -1 : 0
efi_side3 := not use_tf3 ? 99 : (efi_tf3 > _efibuy3 and ma_tf3 >= 0) ? 1 : (efi_tf3 < _efisell3 and ma_tf3 <= 0) ? -1 : 0
efi_side4 := not use_tf4 ? 99 : (efi_tf4 > _efibuy4 and ma_tf4 >= 0) ? 1 : (efi_tf4 < _efisell4 and ma_tf4 <= 0) ? -1 : 0
efi_side5 := not use_tf5 ? 99 : (efi_tf5 > _efibuy5 and ma_tf5 >= 0) ? 1 : (efi_tf5 < _efisell5 and ma_tf5 <= 0) ? -1 : 0
efi_side6 := not use_tf6 ? 99 : (efi_tf6 > _efibuy6 and ma_tf6 >= 0) ? 1 : (efi_tf6 < _efisell6 and ma_tf6 <= 0) ? -1 : 0
efi_side7 := not use_tf7 ? 99 : (efi_tf7 > _efibuy7 and ma_tf7 >= 0) ? 1 : (efi_tf7 < _efisell7 and ma_tf7 <= 0) ? -1 : 0
efi_side8 := not use_tf8 ? 99 : (efi_tf8 > _efibuy8 and ma_tf8 >= 0) ? 1 : (efi_tf8 < _efisell8 and ma_tf8 <= 0) ? -1 : 0
efi_side9 := not use_tf9 ? 99 : (efi_tf9 > _efibuy9 and ma_tf9 >= 0) ? 1 : (efi_tf9 < _efisell9 and ma_tf9 <= 0) ? -1 : 0
efi_side10 := not use_tf10 ? 99 : (efi_tf10 > _efibuy10 and ma_tf10 >= 0) ? 1 : (efi_tf10 < _efisell10 and ma_tf10 <= 0) ? -1 : 0

var bool efi_buy = false
var bool efi_sell = false

efi_buy := (efi_side1 == 99 or efi_side1 == 1)
 and (efi_side2 == 99 or efi_side2 == 1)
 and (efi_side3 == 99 or efi_side3 == 1)
 and (efi_side4 == 99 or efi_side4 == 1)
 and (efi_side5 == 99 or efi_side5 == 1)
 and (efi_side6 == 99 or efi_side6 == 1)
 and (efi_side7 == 99 or efi_side7 == 1)
 and (efi_side8 == 99 or efi_side8 == 1)
 and (efi_side9 == 99 or efi_side9 == 1)
 and (efi_side10 == 99 or efi_side10 == 1)

efi_sell := (efi_side1 == 99 or efi_side1 == -1)
 and (efi_side2 == 99 or efi_side2 == -1)
 and (efi_side3 == 99 or efi_side3 == -1)
 and (efi_side4 == 99 or efi_side4 == -1)
 and (efi_side5 == 99 or efi_side5 == -1)
 and (efi_side6 == 99 or efi_side6 == -1)
 and (efi_side7 == 99 or efi_side7 == -1)
 and (efi_side8 == 99 or efi_side8 == -1)
 and (efi_side9 == 99 or efi_side9 == -1)
 and (efi_side10 == 99 or efi_side10 == -1)

var int last_efi = 0
last_efi := efi_buy ? 1 : efi_sell ? -1 : last_efi[1]
// barcolor(efi_buy ? color.lime : efi_sell ? color.red : na)

// calculate tradingsignals
var bool in_trade = false
var int trade_side = 0
var int last_trade = na

var float target = 99999999.99
var float stop = 0.000000
var float entry_price = 0.00

var bool long_entry = false
var bool short_entry = false

var bool tgt_hit = false
var bool stop_hit = false

var bool long_exit = false
var bool short_exit = false


// entry signals
is_trade_sess = time(timeframe.period, str.format('{0}:1234567', trading_time), 'America/New_York') 
 or not useTradingHours

long_trade_side = not continous_mode ? (last_trade == -1 or na(last_trade)) : trade_side != 1 
short_trade_side = not continous_mode ? (last_trade == 1 or na(last_trade)) : trade_side != -1

long_conditions = is_trade_sess and (efi_buy and not efi_buy[1])
short_conditions = is_trade_sess and (efi_sell and not efi_sell[1])

long_entry := long_trades and (inverse_signals ? short_conditions : long_conditions) and long_trade_side and not long_entry[1]
short_entry := short_trades and (inverse_signals ? long_conditions : short_conditions) and short_trade_side and not short_entry[1]


// define position
entry_price := long_entry[1] or short_entry[1] ? open :  in_trade == true ? entry_price[1] : na
trade_side := long_entry[1] ? 1 : short_entry[1] ? -1 : in_trade == false ? 0 : trade_side[1]
last_trade := (trade_side != 0 and trade_side != trade_side[1]) ? trade_side : last_trade[1]


// define targets
if use_tp
    target := trade_side == 1 ? 
     (tp_type == 'Percent' ? (entry_price + (entry_price * (tp_amount/100))) : entry_price + tp_amount ) 
     : trade_side == -1 ? 
     (tp_type == 'Percent' ? (entry_price - (entry_price * (tp_amount/100))) : entry_price - tp_amount ) : na
else
    target := na


// define stops
if use_sl    
    stop := trade_side == 1 ?  
     ( sl_type == 'Percent' ? (entry_price - (entry_price * (sl_amount/100))) : entry_price - sl_amount ) 
     : trade_side == -1 ? 
     ( sl_type == 'Percent' ? (entry_price + (entry_price * (sl_amount/100))) : entry_price + sl_amount ) : na
else    
    stop := na


// update position
tgt_hit := trade_side == 1 and high >= target or trade_side == -1 and low <= target
stop_hit := trade_side == 1 and low <= stop or trade_side == -1 and high >= stop

long_exit := ( (tgt_hit or stop_hit or not is_trade_sess or (not short_trades and short_conditions)) ) 
 and in_trade[1] == true and trade_side[1] == 1

short_exit := ( (tgt_hit or stop_hit or not is_trade_sess or (not long_trades and long_conditions)))
 and in_trade[1] == true and trade_side[1] == -1   

in_trade := long_entry or short_entry ? true : long_exit or short_exit ?  false : in_trade[1]

// barcolor(long_entry ? color.green
//  : short_entry ? color.red
//  : long_exit ? color.blue
//  : short_exit ? color.fuchsia
//  : na)


// send orders
time_to_backtest = ((useStrategyStart and time >= strategy_start) or not useStrategyStart)
 and ((useStrategyEnd and time < strategy_end) or not useStrategyEnd)
 ? true : false
if time_to_backtest and is_trade_sess

    // entry orders
    if long_entry
        strategy.entry(id="LE", comment = 'LE', direction = strategy.long)
    if short_entry
        strategy.entry(id="SS_E", comment = 'SS_E', direction = strategy.short)

    // exits | targets and stops
    if (strategy.position_size > 0)
        strategy.exit(id="LE", limit=target, stop=stop , comment = "TP/SL")
    if (strategy.position_size < 0)
        strategy.exit(id="SS_E", limit=target, stop=stop , comment = "TP/SL")

    // exit | no targets / stops
    if (not short_trades and short_conditions)
        strategy.close(id="LE", comment = 'LX', immediately = true)
    if (not long_trades and long_conditions)
        strategy.close(id="SS_E", comment = 'SS_X', immediately = true)
    
else
    strategy.close_all(comment = 'T_X', immediately = true)


// visual stuff
show_signals = input.bool(true, title = 'Show Signals', inline='1', group='Visual Settings')
show_lines = input.bool(true, title = 'Show Lines', inline='1', group='Visual Settings')
color_bg = input.bool(true, title = 'Color BG', inline='1', group='Visual Settings')

entry_color = input.color(color.blue, title = 'Entry Color', group = 'Visual Settings', inline = '4')
tgt_color = input.color(#27a69b, title = 'Tgt Color', group = 'Visual Settings', inline = '4')
stop_color = input.color(#b63632, title = 'Stop Color', group = 'Visual Settings', inline = '4')

panelbull_color = input.color(#27a69b, title='Bull Color', inline='5', group='Visual Settings')
panelbear_color = input.color(#b63632, title='Bear Color', inline='5', group='Visual Settings')
panelneutral_color = input.color(color.gray, title='Neutral Color', inline='5', group='Visual Settings')

dashboard_color = input.color(color.new(#131722, 0), title='BG Color', inline='6', group='Visual Settings')
dashboard_text = input.color(#ffffff, title='Text Color', inline='6', group='Visual Settings')
dashboard_bull = color.new(panelbull_color,40)
dashboard_bear = color.new(panelbear_color,40)

LabelSize = input.string(defval='Small', options=['Small', 'Medium', 'Large'],
 title='Dashboard Size', inline= '3', group='Dashboard Settings')
label_size = LabelSize == 'Small' ? size.small : LabelSize == 'Medium' ? size.normal 
 : LabelSize == 'Large' ? size.large : size.small
positioning = position.bottom_right 


plotshape(show_signals and long_entry[1] , style = shape.triangleup, location = location.belowbar,
 color=color.new(panelbull_color, 30), size=size.small, title = 'Long Entry')
plotshape(show_signals and short_entry[1] , style = shape.triangledown, location = location.abovebar,
 color=color.new(panelbear_color, 30), size=size.small, title = 'SS Entry')

plotshape(show_signals and short_exit, style = shape.triangleup, location = location.belowbar,
 color=color.new(dashboard_text, 30), size=size.small, title = 'SS Exit')
plotshape(show_signals and long_exit, style = shape.triangledown, location = location.abovebar,
 color=color.new(dashboard_text, 30), size=size.small, title = 'Long Exit')

plot(show_lines ? entry_price : na, title = 'Entry Line', color = entry_color, style = plot.style_circles, editable = false)
plot(show_lines ? target : na, title = 'Target Line', color = tgt_color, style = plot.style_circles, editable = false)
plot(show_lines ? stop : na, title = 'Stop Line', color = stop_color, style = plot.style_circles, editable = false)

bgcolor(not color_bg ? na : trade_side == 1 and in_trade[1] ? color.new(panelbull_color,80) 
 : trade_side == -1 and in_trade[1] ? color.new(panelbear_color,80) : na)


target_label = use_tp and trade_side != 0 ? str.tostring(math.round_to_mintick(target)) : ""
stop_label = use_sl and trade_side != 0 ? str.tostring(math.round_to_mintick(stop)) : ""


var color color_sym1_tf1 = na
var color color_sym1_tf2 = na
var color color_sym1_tf3 = na
var color color_sym1_tf4 = na
var color color_sym1_tf5 = na
var color color_sym1_tf6 = na
var color color_sym1_tf7 = na
var color color_sym1_tf8 = na
var color color_sym1_tf9 = na
var color color_sym1_tf10 = na

var string text_sym1_tf1 = na
var string text_sym1_tf2 = na
var string text_sym1_tf3 = na
var string text_sym1_tf4 = na
var string text_sym1_tf5 = na
var string text_sym1_tf6 = na
var string text_sym1_tf7 = na
var string text_sym1_tf8 = na
var string text_sym1_tf9 = na
var string text_sym1_tf10 = na

var table t = table.new(positioning, 1, 13, frame_color=color.new(color.black, 0),
 frame_width=1, border_color=color.new(dashboard_color, 100), border_width=1)
if true

    color_sym1_tf1 := efi_side1 == 1 ? panelbull_color : efi_side1 == -1 ? panelbear_color : dashboard_color
    color_sym1_tf2 := efi_side2 == 1 ? panelbull_color : efi_side2 == -1 ? panelbear_color : dashboard_color
    color_sym1_tf3 := efi_side3 == 1 ? panelbull_color : efi_side3 == -1 ? panelbear_color : dashboard_color
    color_sym1_tf4 := efi_side4 == 1 ? panelbull_color : efi_side4 == -1 ? panelbear_color : dashboard_color
    color_sym1_tf5 := efi_side5 == 1 ? panelbull_color : efi_side5 == -1 ? panelbear_color : dashboard_color
    color_sym1_tf6 := efi_side6 == 1 ? panelbull_color : efi_side6 == -1 ? panelbear_color : dashboard_color
    color_sym1_tf7 := efi_side7 == 1 ? panelbull_color : efi_side7 == -1 ? panelbear_color : dashboard_color
    color_sym1_tf8 := efi_side8 == 1 ? panelbull_color : efi_side8 == -1 ? panelbear_color : dashboard_color
    color_sym1_tf9 := efi_side9 == 1 ? panelbull_color : efi_side9 == -1 ? panelbear_color : dashboard_color
    color_sym1_tf10 := efi_side10 == 1 ? panelbull_color : efi_side10 == -1 ? panelbear_color : dashboard_color

    text_sym1_tf1 := tf1 == "" ? timeframe.period : tf1
    text_sym1_tf2 := tf2 == "" ? timeframe.period : tf2
    text_sym1_tf3 := tf3 == "" ? timeframe.period : tf3
    text_sym1_tf4 := tf4 == "" ? timeframe.period : tf4
    text_sym1_tf5 := tf5 == "" ? timeframe.period : tf5
    text_sym1_tf6 := tf6 == "" ? timeframe.period : tf6
    text_sym1_tf7 := tf7 == "" ? timeframe.period : tf7
    text_sym1_tf8 := tf8 == "" ? timeframe.period : tf8
    text_sym1_tf9 := tf9 == "" ? timeframe.period : tf9
    text_sym1_tf10 := tf10 == "" ? timeframe.period : tf10

    table.cell(t, 0, 0, text="MTF EFI", 
     width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)   

    if use_tf1
        table.cell(t, 0, 1, text= text_sym1_tf1, width=0, bgcolor=color_sym1_tf1, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
    if use_tf2
        table.cell(t, 0, 2, text= text_sym1_tf2, width=0, bgcolor=color_sym1_tf2, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
    if use_tf3
        table.cell(t, 0, 3, text= text_sym1_tf3, width=0, bgcolor=color_sym1_tf3, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
    if use_tf4
        table.cell(t, 0, 4, text= text_sym1_tf4, width=0, bgcolor=color_sym1_tf4, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
    if use_tf5
        table.cell(t, 0, 5, text= text_sym1_tf5, width=0, bgcolor=color_sym1_tf5, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
    if use_tf6
        table.cell(t, 0, 6, text= text_sym1_tf6, width=0, bgcolor=color_sym1_tf6, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
    if use_tf7
        table.cell(t, 0, 7, text= text_sym1_tf7, width=0, bgcolor=color_sym1_tf7, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
    if use_tf8
        table.cell(t, 0, 8, text= text_sym1_tf8, width=0, bgcolor=color_sym1_tf8, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
    if use_tf9
        table.cell(t, 0, 9, text= text_sym1_tf9, width=0, bgcolor=color_sym1_tf9, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
    if use_tf10
        table.cell(t, 0, 10, text= text_sym1_tf10, width=0, bgcolor=color_sym1_tf10, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)


    table.cell(t, 0, 11, text= "TP: " + target_label, width=0, bgcolor=dashboard_color, 
     text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
    table.cell(t, 0, 12, text= "SL: " + stop_label, width=0, bgcolor=dashboard_color, 
     text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
 

// alerts
// alertcondition(long_entry, title = 'Long Entry', message = 'Long Entry')
// alertcondition(short_entry, title = 'Short Entry', message = 'Short Entry')
// alertcondition(long_exit, title = 'Long Exit', message = 'Long Exit')
// alertcondition(short_exit, title = 'Short Exit', message = 'Short Exit')

Overview

Separate buy and sell thresholds can be enabled on up to seven timeframes, with 15, 30, 60 and 120 minutes on by default. Higher-timeframe values are requested with lookahead. A timeframe below the chart timeframe causes a runtime error, and the script stops when no volume is available. Exit, stop-loss and position-sizing rules are not shown in the supplied code.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

M1-M5, M15-H1

Risk Notes

  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
EFI Lengthint13efi_length
EFI SmoothingstringEMAefi_type
use_tf1boolfalseuse_tf1
tf1timeframe1tf1
_efibuy1int0_efibuy1
_efisell1int0_efisell1
use_tf2boolfalseuse_tf2
tf2timeframe3tf2
_efibuy2int0_efibuy2
_efisell2int0_efisell2
use_tf3boolfalseuse_tf3
tf3timeframe5tf3
Show all 40 settings
SettingTypeDefaultVariable
_efibuy3int0_efibuy3
_efisell3int0_efisell3
use_tf4booltrueuse_tf4
tf4timeframe15tf4
_efibuy4int0_efibuy4
_efisell4int0_efisell4
use_tf5booltrueuse_tf5
tf5timeframe30tf5
_efibuy5int0_efibuy5
_efisell5int0_efisell5
use_tf6booltrueuse_tf6
tf6timeframe60tf6
_efibuy6int0_efibuy6
_efisell6int0_efisell6
use_tf7booltrueuse_tf7
tf7timeframe120tf7
_efibuy7int0_efibuy7
_efisell7int0_efisell7
use_tf8boolfalseuse_tf8
tf8timeframe180tf8
_efibuy8int0_efibuy8
_efisell8int0_efisell8
use_tf9boolfalseuse_tf9
tf9timeframe240tf9
_efibuy9int0_efibuy9
_efisell9int0_efisell9
use_tf10boolfalseuse_tf10
tf10timeframeDtf10
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

106 stars

This strategy enters long on an outside bar when the candle is bullish, the Klinger Volume Oscillator is positive, and price is above a Hull moving average. It enters short on an inside bar when the candle is bearish, the oscillator is negative, and price is b

Strategy v4 Oscillators & momentumMoving averages Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of Advanced OutSide Forex strategy
105 stars

This overlay strategy looks for gold scalps from break of structure and change of character. It enters long when a bullish break, a bullish character change, and an optional volume filter align, and short on the opposite set. Optional RSI levels can block trad

Strategy v6 SMC / ICT / price actionOscillators & momentum Repaints

CombinedBinHAndClucV8

by viktors1982
36 stars

This strategy trades on the price chart using multiple indicators. It enters long positions when price dips meet conditions on Bollinger Bands 40 and 20, RSI, MFI, volume and other thresholds. It exits at custom ROI profit levels based on RSI or after timeout

Strategy v4 Oscillators & momentumMoving averages Repaints
Updated 2 years ago · None stated GitHub repository of CombinedBinHAndClucV8
13 stars

The Ruckard Cuneyt OBVRSI A002 strategy combines On-Balance Volume (OBV) and Relative Strength Index (RSI) thresholds to generate trade entries, DCA rebuys, and exits. Built primarily for crypto automation via Zignaly webhooks, it opens positions when OBV RSI

Strategy v5 Oscillators & momentumVolume
Updated 1 year ago · None stated GitHub repository of Ruckard Cuneyt OBVRSI A002
12 stars

This strategy plots on the price chart and looks for three-candle fair value gaps and inverse gaps on Bitcoin. It enters long when a wide enough bullish gap appears in an uptrend with RSI above 30 and volume above its average, and short on the opposite bearish

Strategy v6 SMC / ICT / price actionTrend Repaints
Updated 4 months ago · None stated GitHub repository of BTC 4h FVG/iFVG Strategy

Combined Strategy

by Dropio12
7 stars

This strategy plots buy and sell markers on the price chart by combining a fast and slow ALMA crossover with a simple close-to-close momentum check. A long marker appears when the fast ALMA crosses above the slow ALMA and momentum is positive. A short marker a

Strategy v5 TrendOscillators & momentum
Updated 2 years ago · None stated GitHub repository of Combined Strategy

More Oscillators & momentum scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers