Mix
Mix
// Input parameters
adx_length = input.int(14, title="ADX Length")
adx_threshold = input.int(25, title="ADX Threshold")
// Strategy logic
long_condition = adx > adx_threshold and ta.crossover(PDI, NDI)
short_condition = adx > adx_threshold and ta.crossunder(PDI, NDI)
// Plot ADX
plot(adx, color=color.blue, title="ADX")
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
atr_length = input.int(14, title="ATR Length")
atr_multiplier = input.float(2.0, title="ATR Multiplier")
// Calculate ATR
atr = ta.atr(atr_length)
// Strategy logic
long_condition = close > ta.sma(close, atr_length) + atr_multiplier * atr
short_condition = close < ta.sma(close, atr_length) - atr_multiplier * atr
// Plot ATR
plot(atr, color=color.blue, title="ATR")
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
length = input.int(20, title="BB Length")
mult = input.float(2.0, title="BB Multiplier")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Strategy logic
long_condition = ta.crossover(close, lower_band)
short_condition = ta.crossunder(close, upper_band)
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
length = input.int(20, title="Length")
overbought_level = input.float(0.3, title="Overbought Level")
oversold_level = input.float(-0.3, title="Oversold Level")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Calculate Money Flow Multiplier (MFM) and Money Flow Volume (MFV)
typical_price = (high + low + close) / 3
money_flow = typical_price * volume
positive_money_flow = ta.sma(money_flow * (ta.change(typical_price) > 0 ? 1 : 0),
length)
negative_money_flow = ta.sma(money_flow * (ta.change(typical_price) < 0 ? 1 : 0),
length)
// Strategy logic
long_condition = ta.crossover(cmf_value, oversold_level)
short_condition = ta.crossunder(cmf_value, overbought_level)
// Plot CMF
plot(cmf_value, color=color.blue, title="CMF")
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
fib_level = input.float(1.618, title="Fibonacci Level")
length = input.int(10, "Length of Historical Candles")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Strategy logic
long_condition = ta.crossover(close, fib_1618)
short_condition = ta.crossunder(close, fib_1618)
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
fib_levels = input.bool(true, title="Show Fibonacci Levels")
n = input.int(20, title="Number of Historical Candles")
// Strategy logic
long_condition = ta.crossover(close, fib618)
short_condition = ta.crossunder(close, fib382)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
ma_length = input.int(20, title="Moving Average Length")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Strategy logic
long_condition = trend_up and trend_up[1] == false
short_condition = trend_down and trend_down[1] == false
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
strategy("Half Trend Strategy", overlay=true)
// Input parameters
ma_length = input.int(20, title="Moving Average Length")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Determine trend
trend_up = close > ma
trend_down = close < ma
// Strategy logic
long_condition = trend_up and trend_up[1] == false
short_condition = trend_down and trend_down[1] == false
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Input parameters
ma_length = input.int(20, title="Moving Average Length")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Determine trend
trend_up = close > ma
trend_down = close < ma
// Strategy logic
long_condition = trend_up and trend_up[1] == false
short_condition = trend_down and trend_down[1] == false
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
conversion_period = input.int(9, title="Conversion Line Period")
base_period = input.int(26, title="Base Line Period")
lagging_span2_period = input.int(52, title="Lagging Span 2 Period")
displacement = input.int(26, title="Displacement")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Strategy logic
long_condition = close > senkou_span_a and close > senkou_span_b
short_condition = close < senkou_span_a and close < senkou_span_b
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
fast_length = input.int(9, title="Fast MA Length")
slow_length = input.int(21, title="Slow MA Length")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Strategy logic
long_condition = ta.crossover(fast_ma, slow_ma)
short_condition = ta.crossunder(fast_ma, slow_ma)
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
strategy("MACD Strategy", overlay=true)
// Input parameters
fast_length = input.int(12, title="Fast EMA Length")
slow_length = input.int(26, title="Slow EMA Length")
signal_length = input.int(9, title="Signal Line Length")
// Calculate MACD
[macd_line, signal_line, _] = ta.macd(close, fast_length, slow_length,
signal_length)
// Strategy logic
long_condition = ta.crossover(macd_line, signal_line)
short_condition = ta.crossunder(macd_line, signal_line)
// Plot MACD
plot(macd_line, color=color.blue, title="MACD Line")
plot(signal_line, color=color.red, title="Signal Line")
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
length = input.int(14, title="Length")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Calculate OBV
obv_value := nz(obv_value[1]) + (close - close[1]) * (volume > volume[1] ? 1 :
volume < volume[1] ? -1 : 0)
// Strategy logic
long_condition = ta.crossover(obv_value, ta.sma(obv_value, length))
short_condition = ta.crossunder(obv_value, ta.sma(obv_value, length))
// Plot OBV
plot(obv_value, color=color.blue, title="OBV")
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
af_start = input.float(0.02, title="Acceleration Factor Start")
af_increment = input.float(0.02, title="Acceleration Factor Increment")
af_maximum = input.float(0.2, title="Acceleration Factor Maximum")
// Strategy logic
long_condition = ta.crossover(close, sar)
short_condition = ta.crossunder(close, sar)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
rsi_length = input.int(14, title="RSI Length")
overbought_level = input.int(70, title="Overbought Level")
oversold_level = input.int(30, title="Oversold Level")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Calculate RSI
rsi = ta.rsi(close, rsi_length)
// Strategy logic
long_condition = ta.crossover(rsi, oversold_level)
short_condition = ta.crossunder(rsi, overbought_level)
// Plot RSI
plot(rsi, color=color.blue, title="RSI")
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
k_period = input.int(14, title="K Period")
d_period = input.int(3, title="D Period")
overbought_level = input.int(80, title="Overbought Level")
oversold_level = input.int(20, title="Oversold Level")
// Strategy logic
long_condition = ta.crossover(k, d) and k < oversold_level
short_condition = ta.crossunder(k, d) and k > overbought_level
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
length = input.int(14, title="TEMA Length")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Calculate TEMA
ema1 = ta.ema(close, length)
ema2 = ta.ema(ema1, length)
ema3 = ta.ema(ema2, length)
tema = 3 * ema1 - 3 * ema2 + ema3
// Strategy logic
long_condition = ta.crossover(close, tema)
short_condition = ta.crossunder(close, tema)
// Plot TEMA
plot(tema, color=color.blue, title="TEMA")
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Inputs
emaLength = input.int(21, title="EMA Length")
vwapSource = input.source(defval=hlc3, title='VWAP Source')
stopLossPoints = input.float(100, title="Stop Loss (points)")
targetPoints = input.float(200, title="Target (points)")
session = input.session("0950-1430", title='Only take entry during')
exit = input.session(defval='1515-1525', title='Exit Trade')
// Entry Conditions
longCondition = close > vwapValue and close > ema and volume > volume[1] and close
> open and tradein
shortCondition = close < vwapValue and close < ema and volume > volume[1] and open
> close and tradein
// Exit Conditions
longExitCondition = ta.crossunder(close, vwapValue) or ta.crossunder(close, ema) or
close - strategy.position_avg_price >= targetPoints or close -
strategy.position_avg_price <= -stopLossPoints or exit_time
shortExitCondition = ta.crossover(close, vwapValue) or ta.crossover(close, ema) or
strategy.position_avg_price - close >= targetPoints or strategy.position_avg_price
- close <= -stopLossPoints or exit_time
// Plotting
plot(vwapValue, color=color.blue, title="VWAP")
plot(ema, color=color.green, title="EMA")
// Strategy
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.entry("Short", strategy.short)
if longExitCondition
strategy.close('Long', immediately=true)
if shortExitCondition
strategy.close("Short", immediately=true)
// Input parameters
length = input.int(14, title="VWAP Length")
// Calculate VWAP
vwap = ta.vwap(volume, length)
// Strategy logic
long_condition = ta.crossover(close, vwap)
short_condition = ta.crossunder(close, vwap)
// Plot VWAP
plot(vwap, color=color.blue, title="VWAP")
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)
// Input parameters
length = input.int(14, title="Williams %R Length")
overbought_level = input.int(-20, title="Overbought Level")
oversold_level = input.int(-80, title="Oversold Level")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")
// Calculate Williams %R
hh = ta.highest(high, length)
ll = ta.lowest(low, length)
williams_r = (hh - close) / (hh - ll) * -100
// Strategy logic
long_condition = williams_r < oversold_level
short_condition = williams_r > overbought_level
// Plot Williams %R
plot(williams_r, color=color.blue, title="Williams %R")
// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)