Indicator · Pine Script v5 · On the chart

MTF EFI Test

by g-moe· code credited to goodgains

This overlay indicator calculates a smoothed Elder Force Index and compares it across up to seven user-selected timeframes.

View on GitHub

Repaints

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code663
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 indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

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

mtf-efi-test.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
indicator("MTF EFI TEST", overlay=true)

// @keywords: mtf-efi, elder-force-index, multi-timeframe, efi-oscillator, mtf-signals, ma-filter, long-entry, short-entry, trading-hours, inverse-signals, continuous-mode, take-profit, stop-loss, efi-smoothing, timeframe-thresholds, candle-highlight, signal-dashboard, volume-required, hma-smoothing, efi-crossover

// 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.islast and timeframe.in_seconds() > 
 math.min(timeframe.in_seconds(use_tf1 ? tf1 : "M"), 
  timeframe.in_seconds(use_tf2 ? tf2 : "M"),
  timeframe.in_seconds(use_tf3 ? tf3 : "M"),
  timeframe.in_seconds(use_tf4 ? tf4 : "M"),
  timeframe.in_seconds(use_tf5 ? tf5 : "M"),
  timeframe.in_seconds(use_tf6 ? tf6 : "M"),
  timeframe.in_seconds(use_tf7 ? tf7 : "M"),
  timeframe.in_seconds(use_tf8 ? tf8 : "M"),
  timeframe.in_seconds(use_tf9 ? tf9 : "M"),
  timeframe.in_seconds(use_tf10 ? tf10 : "M"))
    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
    var float high_efi_value = na
    var float low_efi_value = na
    if calc_bool
        efi_value := switch efi_type
            "EMA" => math.round(ta.ema(ta.change(close[1]) * volume[1], efi_length),0)
            "SMA" => math.round(ta.sma(ta.change(close[1]) * volume[1], efi_length),0)
            "VWMA" => math.round(ta.vwma(ta.change(close[1]) * volume[1], efi_length),0)
            "RMA" => math.round(ta.rma(ta.change(close[1]) * volume[1], efi_length),0)
            "HMA" => math.round(ta.hma(ta.change(close[1]) * volume[1], efi_length),0)

        high_efi_value := ta.highest(volume[1],2000)
        low_efi_value := ta.lowest(volume[1],2000)

    [efi_value, high_efi_value, low_efi_value]
        


// 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, ma_value]


// call efi function
[efi_tf1, high_efi_tf1, low_efi_tf1] = request.security(syminfo.ticker, tf1, f_efi(use_tf1), lookahead = barmerge.lookahead_on)
[efi_tf2, high_efi_tf2, low_efi_tf2]  = request.security(syminfo.ticker, tf2, f_efi(use_tf2), lookahead = barmerge.lookahead_on)
[efi_tf3, high_efi_tf3, low_efi_tf3]  = request.security(syminfo.ticker, tf3, f_efi(use_tf3), lookahead = barmerge.lookahead_on)
[efi_tf4, high_efi_tf4, low_efi_tf4]  = request.security(syminfo.ticker, tf4, f_efi(use_tf4), lookahead = barmerge.lookahead_on)
[efi_tf5, high_efi_tf5, low_efi_tf5]  = request.security(syminfo.ticker, tf5, f_efi(use_tf5), lookahead = barmerge.lookahead_on)
[efi_tf6, high_efi_tf6, low_efi_tf6]  = request.security(syminfo.ticker, tf6, f_efi(use_tf6), lookahead = barmerge.lookahead_on)
[efi_tf7, high_efi_tf7, low_efi_tf7]  = request.security(syminfo.ticker, tf7, f_efi(use_tf7), lookahead = barmerge.lookahead_on)
[efi_tf8, high_efi_tf8, low_efi_tf8]  = request.security(syminfo.ticker, tf8, f_efi(use_tf8), lookahead = barmerge.lookahead_on)
[efi_tf9, high_efi_tf9, low_efi_tf9]  = request.security(syminfo.ticker, tf9, f_efi(use_tf9), lookahead = barmerge.lookahead_on)
[efi_tf10, high_efi_tf10, low_efi_tf10]  = request.security(syminfo.ticker, tf10, f_efi(use_tf10), lookahead = barmerge.lookahead_on)


// call ma function
[ma_tf1, ma_value1] = request.security(syminfo.ticker, tf1, f_ma(use_tf1 and use_ma_filter1), lookahead = barmerge.lookahead_on)
[ma_tf2, ma_value2] = request.security(syminfo.ticker, tf2, f_ma(use_tf2 and use_ma_filter2), lookahead = barmerge.lookahead_on)
[ma_tf3, ma_value3] = request.security(syminfo.ticker, tf3, f_ma(use_tf3 and use_ma_filter3), lookahead = barmerge.lookahead_on)
[ma_tf4, ma_value4] = request.security(syminfo.ticker, tf4, f_ma(use_tf4 and use_ma_filter4), lookahead = barmerge.lookahead_on)
[ma_tf5, ma_value5] = request.security(syminfo.ticker, tf5, f_ma(use_tf5 and use_ma_filter5), lookahead = barmerge.lookahead_on)
[ma_tf6, ma_value6] = request.security(syminfo.ticker, tf6, f_ma(use_tf6 and use_ma_filter6), lookahead = barmerge.lookahead_on)
[ma_tf7, ma_value7] = request.security(syminfo.ticker, tf7, f_ma(use_tf7 and use_ma_filter7), lookahead = barmerge.lookahead_on)
[ma_tf8, ma_value8] = request.security(syminfo.ticker, tf8, f_ma(use_tf8 and use_ma_filter8), lookahead = barmerge.lookahead_on)
[ma_tf9, ma_value9] = request.security(syminfo.ticker, tf9, f_ma(use_tf9 and use_ma_filter9), lookahead = barmerge.lookahead_on)
[ma_tf10, ma_value10] = 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')
//     if (not long_trades and long_conditions)
//         strategy.close(id="SS_E", comment = 'SS_X')
    
// 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.middle_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 int column_tf1 = na
var int column_tf2 = na
var int column_tf3 = na
var int column_tf4 = na
var int column_tf5 = na
var int column_tf6 = na
var int column_tf7 = na
var int column_tf8 = na
var int column_tf9 = na
var int column_tf10 = na

var float efi_sums = 0.00
efi_sums := efi_tf1
 + efi_tf2
 + efi_tf3
 + efi_tf4
 + efi_tf5
 + efi_tf6
 + efi_tf7
 + efi_tf8
 + efi_tf9
 + efi_tf10


var float efi_max = 0.00
var float efi_min = 0.00

efi_max := math.max(
 math.abs(nz(efi_tf1*1000,0)),
 math.abs(nz(efi_tf2*1000,0)),
 math.abs(nz(efi_tf3*1000,0)),
 math.abs(nz(efi_tf4*1000,0)),
 math.abs(nz(efi_tf5*1000,0)),
 math.abs(nz(efi_tf6*1000,0)),
 math.abs(nz(efi_tf6*1000,0)),
 math.abs(nz(efi_tf8*1000,0)),
 math.abs(nz(efi_tf9*1000,0)),
 math.abs(nz(efi_tf10*1000,0)))


efi_min := math.min(
 math.abs(efi_tf1),
 math.abs(efi_tf2),
 math.abs(efi_tf3),
 math.abs(efi_tf4),
 math.abs(efi_tf5),
 math.abs(efi_tf6),
 math.abs(efi_tf7),
 math.abs(efi_tf8),
 math.abs(efi_tf9),
 math.abs(efi_tf10))

 
// xrange = xMax - xMin
// y = 100 * efi / xrange
tf1_mult = 100 * efi_tf1 / (high_efi_tf1 - low_efi_tf1)
tf2_mult = 100 * efi_tf2 / (high_efi_tf2 - low_efi_tf2)
tf3_mult = 100 * efi_tf3 / (high_efi_tf3 - low_efi_tf3)
tf4_mult = 100 * efi_tf4 / (high_efi_tf4 - low_efi_tf4)



// vp_barlocation = max right
// vp_location = min right
// math.min(math.floor(vp_barlocation - (vp_location * vp_mult)), vp_barlocation-1)


// start + (total_distance * mult)
// number_of_columns = 10
// column_tf1 := efi_side1 == 1 ? 5 + math.min(1, math.floor((4 * tf1_mult)))
//  : efi_side1 == -1 ? 4 - math.max(1, math.floor((4 * math.abs(tf1_mult))))
//  : na
// column_tf2 := math.min(math.floor(10 - (9 * tf2_mult)), 5)
// column_tf3 := math.min(math.floor(10 - (9 * tf3_mult)), 5)
// column_tf4 := math.min(math.floor(10 - (9 * tf4_mult)), 5)
// column_tf2 := math.min(5, math.floor(5 + (9 * (efi_tf2*1000 / efi_max))))
// column_tf3 := math.min(5, math.floor(5 + (9 * (efi_tf3*1000 / efi_max))))
// column_tf4 := math.max(5, math.floor(9- (9 * (efi_tf4 / efi_max))))
// column_tf5 := math.max(5, math.floor(9- (9 * (efi_tf5 / efi_max))))

// barcolor(efi_side1 == 1 ? color.green : efi_side1 == -1 ? color.red : na)
// test = request.security(syminfo.ticker, "15", ta.ema(ta.change(close) * volume, efi_length), lookahead = barmerge.lookahead_off)
// low volume cfds have shit volume and dont return correct values with request.security

var int column_tf1s = 0
var int column_tf1e = 0
column_tf1s := efi_side1 == 1 ? 5 
 : efi_side1 == -1 ? 4 - math.max(1, math.floor((4 * math.abs(tf1_mult))))
 : na

column_tf1e := efi_side1 == 1 ? 5 + math.min(1, math.floor((4 * tf1_mult)))
 : efi_side1 == -1 ? 3
 : na

var int column_tf2s = 0
var int column_tf2e = 0
column_tf2s := efi_side2 == 1 ? 5 
 : efi_side2 == -1 ? math.max(0, 4 - math.max(1, math.floor((4 * math.abs(tf2_mult)))))
 : na

column_tf2e := efi_side2 == 1 ? 5 + math.min(1, math.floor((4 * tf2_mult)))
 : efi_side2 == -1 ? 3
 : na

var int column_tf3s = 0
var int column_tf3e = 0
column_tf3s := efi_side3 == 1 ? 5 
 : efi_side3 == -1 ? math.max(0, 4 - math.max(1, math.floor((4 * math.abs(tf3_mult)))))
 : na

column_tf3e := efi_side3 == 1 ? 5 + math.min(1, math.floor((4 * tf3_mult)))
 : efi_side3 == -1 ? 3
 : na




 
// if barstate.islast
//     // label.new(bar_index+5, close, text=str.tostring(math.floor(((efi_tf1*1000 / efi_max)))))
//     label.new(bar_index+15, close, text=
//      str.tostring(column_tf2s) + '\n'
//      + str.tostring(column_tf2e) + '\n'
//      + str.tostring(column_tf3) + '\n'
//      + str.tostring(column_tf4) + '\n'
//      )




var table t = table.new(positioning, columns = 10, rows =13, frame_color=color.new(color.black, 0),
 frame_width=1, border_color=color.new(dashboard_color, 100), border_width=1)
if barstate.islast or barstate.islastconfirmedhistory

    table.clear(t, 0, 0, 9, 12)

    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_halign = text.align_center, text_size = label_size)
    table.merge_cells(t, start_column=0, start_row=0, end_column=9 , end_row=0)


    if use_tf1

        table.cell(t, 4, 1, text= text_sym1_tf1, width=0, bgcolor=color_sym1_tf1, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
        table.cell(t, column_tf1s, 1, text= ' ', width=0, bgcolor=color_sym1_tf1, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
        table.merge_cells(t, start_column=column_tf1s, start_row=1, end_column=column_tf1e, end_row=1)

    if use_tf2
        table.cell(t, 4, 2, text= text_sym1_tf2, width=0, bgcolor=color_sym1_tf2, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
        table.cell(t, column_tf2s, 2, text= ' ', width=0, bgcolor=color_sym1_tf2, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
        table.merge_cells(t, start_column=column_tf2s, start_row=2, end_column=column_tf2e, end_row=2)

    if use_tf3
        table.cell(t, 4, 3, text= text_sym1_tf3, width=0, bgcolor=color.teal, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
        table.cell(t, 5, 3, text= ' ', width=0, bgcolor=color.teal, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
        table.merge_cells(t, start_column=5, start_row=3, end_column=7, end_row=3)

    if use_tf4
        table.cell(t, 4, 4, text= text_sym1_tf4, width=0,  bgcolor=color_sym1_tf4, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
        // table.merge_cells(t, start_column=4, start_row=4, end_column=column_tf3, end_row=4)



    if use_tf5
        table.cell(t, 4, 5, text= text_sym1_tf5, width=0, bgcolor=color_sym1_tf5, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
    if use_tf6
        table.cell(t, 4, 6, text= text_sym1_tf6, width=0, bgcolor=color_sym1_tf6, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
    if use_tf7
        table.cell(t, 4, 7, text= text_sym1_tf7, width=0, bgcolor=color_sym1_tf7, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
    if use_tf8
        table.cell(t, 4, 8, text= text_sym1_tf8, width=0, bgcolor=color_sym1_tf8, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
    if use_tf9
        table.cell(t, 4, 9, text= text_sym1_tf9, width=0, bgcolor=color_sym1_tf9, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)
    if use_tf10
        table.cell(t, 4, 10, text= text_sym1_tf10, width=0, bgcolor=color_sym1_tf10, 
         text_color=dashboard_text, text_halign = text.align_center, text_size = label_size)






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

// 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

Each timeframe can be switched on or off and given separate buy and sell threshold values. The force index length and the smoothing method, including EMA, SMA, VWMA, RMA, and HMA, are adjustable. It draws on the price chart and stops with an error when the symbol supplies no volume. A selected timeframe below the chart timeframe causes a runtime error. The supplied risk read marks lookahead use.

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

Any timeframe

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

This overlay indicator screens a pasted list of up to forty symbols and draws a table on the price chart. It classifies bullish or bearish setups from the percent change between the current candle and the candle 250 bars back, then shows RSI with a simple movi

Indicator v5 Oscillators & momentumVolume
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup

LiqSpikeBounceLong Feb2026

by agutinbaigo28
147 stars

LiqSpikeBounceLong Feb2026 is an indicator designed to identify long bounce entries following high-volume liquidation cascades in bearish market contexts. It checks if price is below an exponential moving average, then detects large single-bar drops exceeding

Indicator v5 Volatility & bandsVolume
Updated 6 weeks ago · MIT GitHub repository of LiqSpikeBounceLong Feb2026

Aroon-based Strategy

by capissimo
114 stars

This indicator overlay generates buy and sell signals based on Aroon extreme levels combined with optional volume or volatility filters. It calculates Aroon Up and Aroon Down lines using localized high and low lookbacks, generating trade entries when Aroon rea

Indicator v4 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Aroon-based Strategy
92 stars

This indicator plots a volume-weighted average price of the typical price on the chart and colors that line by ADX strength. It draws a standard-deviation envelope around VWAP and tints the fill green when plus DI leads and red when minus DI leads. Triangle ma

Indicator v5 TrendOscillators & momentum
Updated 2 months ago · Custom licence GitHub repository of Moon Dev VWAP x ADX Explosion

RSI Div at dVWAP StDev

by cryptorife
75 stars

This indicator marks RSI divergences only when price trades beyond daily VWAP standard-deviation bands. It compares recent RSI extremes with price highs and lows over a lookback window, and it treats a divergence as valid only while RSI stays beyond overbought

Indicator v4 DivergenceOscillators & momentum Repaints
Updated 3 years ago · GPL-3.0 GitHub repository of RSI Div at dVWAP StDev

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