PHP Code:
//@version=6
indicator('Neural Network Buy and Sell Signals', shorttitle = '.', overlay = true, max_lines_count = 100, max_labels_count=100, max_boxes_count = 100, max_bars_back = 100)
var string scalpHelperGroup = 'Scalp Helper Signal Settings'
enable_scalp_helper = input.bool(true, 'Enable Scalp Helper Signals', group = scalpHelperGroup)
signalCandleType = input.string('Candlesticks', 'Signal Candle Type', options = ['Candlesticks', 'Heikin Ashi', 'Linear Regression'], group = scalpHelperGroup, tooltip = 'Choose which candle type to use for signal calculations. This will not change what candlestick type is displayed.')
signal_trigger_mult = input.float(1.5, 'Signal Trigger Sensitivity', minval = 0.1, maxval = 10.0, step = 0.1, group = scalpHelperGroup, tooltip = 'Controls both buy and sell signal sensitivity. Lower values = more sensitive signals, higher values = less sensitive signals.')
stop_atr_mult = input.float(1.5, 'Stop Loss ATR Multiplier', minval = 0.1, maxval = 10.0, step = 0.1, group = scalpHelperGroup, tooltip = 'Once a signal is triggered this stop will be initiated to tell how long the signal is valid. Higher values = wider stops and less signals, lower values = tighter stops and more signals.')
var string candleGroup = 'Candlestick Settings'
candleType = input.string('Candlesticks', 'Candle Type', options = ['Candlesticks', 'Heikin Ashi', 'Linear Regression'], group = candleGroup, tooltip = 'Choose the type of candles to display. This does not impact signal calculations.')
lrcLength1 = input.int(6, 'Linear Regression Length', minval = 1, group = candleGroup, tooltip = 'Length for Linear Regression calculations. Lower values are more responsive but noisier.')
var string visualGroup = 'Display Settings'
signalOffset = input.float(1.05, 'Signal Distance from Candles', minval = 0.1, maxval = 3.0, step = 0.1, group = visualGroup, tooltip = 'Distance of buy/sell labels from candles (ATR multiplier)')
signalLabelSize = input.string('medium', 'Signal Label Size', options = ['tiny', 'small', 'medium', 'large'], group = visualGroup, tooltip = 'Size of the neural network signal labels')
buy_signal_length = 2
buy_atr_length = 18
sell_signal_length = 2
sell_atr_length = 18
buy_signal_use_close = false
buy_atr_use_close = true
sell_signal_use_close = false
sell_atr_use_close = true
amf_length = 14
amf_signal_length = 9
amf_smoothing = 3
amf_fast_length = 5
amf_slow_length = 21
amf_far_threshold = 0.3
amf_slope_fast_threshold = 0.03
h1_amf_weight = 1.2
h1_alma_weight = 0.4
h1_sr_weight = 0.5
h1_swing_weight = 0.4
h1_regime_weight = 0.7
h1_bias = 0.2
h2_amf_weight = 1.4
h2_alma_weight = 0.3
h2_sr_weight = 0.6
h2_swing_weight = 0.3
h2_regime_weight = 0.8
h2_bias = 0.15
h3_amf_weight = 1.6
h3_alma_weight = 0.4
h3_sr_weight = 0.4
h3_swing_weight = 0.5
h3_regime_weight = 0.6
h3_bias = 0.25
out_h1_weight = 0.4
out_h2_weight = 0.4
out_h3_weight = 0.4
out_bias = 0.3
enable_input_normalization = true
normalization_lookback = 50
outlier_clipping = true
clipping_threshold = 3.0
almaLength = 20
almaOffset = 0.85
almaSigma = 6.0
alma2Length = 20
alma2Offset = 0.77
alma2Sigma = 6.0
alma_wide_gap_threshold = 0.1
pivot_lookback = 10
sr_proximity_threshold = 0.5
sr_breakout_threshold = 0.2
swing_structure_length = 20
regime_lookback = 30
trending_threshold = 0.6
showScalpLabels = true
var float signalOpen = open
var float signalHigh = high
var float signalLow = low
var float signalClose = close
customBuyColor = color.new(#00FFFF, 0)
customSellColor = color.new(#FF0000, 0)
scalpLongColor = color.new(#00B3B3, 0)
scalpShortColor = color.new(#FF0000, 0)
textColor = color.new(color.white, 0)
f_ema_amf(source, len) =>
float alpha = 2.0 / (len + 1)
var float ema_val = na
if not na(source) and len > 0
ema_val := alpha * source + (1 - alpha) * nz(ema_val[1])
ema_val
f_dema_amf(source, len) =>
float ema1 = f_ema_amf(source, len)
float ema2 = f_ema_amf(ema1, len)
float dema_val = 2 * ema1 - ema2
dema_val
f_zlema_amf(source, len) =>
int lag = int((len - 1) / 2)
float lag_source = lag > 0 ? source[lag] : source
float adjusted_source = source + (source - lag_source)
float zlema_val = f_ema_amf(adjusted_source, len)
zlema_val
f_sum_amf(source, len) =>
float sum_val = 0.0
for i = 0 to len - 1
sum_val += nz(source[i], 0)
sum_val
f_calculate_amf(src, length, fast_len, slow_len, smooth_len) =>
float current_atr = ta.atr(14)
float avg_atr = ta.sma(current_atr, 50)
float volatility_ratio = avg_atr > 0 ? current_atr / avg_atr : 1.0
float volatility_sensitivity = 2.0
float raw_adaptive_lookback = float(length) / math.pow(volatility_ratio, volatility_sensitivity)
int adaptive_lookback = int(math.max(5, math.min(50, raw_adaptive_lookback)))
if adaptive_lookback < 1
adaptive_lookback := 1
int zlema_fast_len = adaptive_lookback
int dema_medium_len = int(adaptive_lookback * 1.5)
int dema_slow_len = int(adaptive_lookback * 2.5)
if dema_medium_len < 1
dema_medium_len := 1
if dema_slow_len < 1
dema_slow_len := 1
float zlema_fast = f_zlema_amf(src, zlema_fast_len)
float dema_medium = f_dema_amf(src, dema_medium_len)
float dema_slow = f_dema_amf(src, dema_slow_len)
float pv = 0.0
if src > src[1]
pv := volume
else if src < src[1]
pv := -volume
float vzo_sum = f_sum_amf(pv, length)
float vol_sum = f_sum_amf(volume, length)
float vzo_value = vol_sum != 0 ? 100 * (vzo_sum / vol_sum) : 0.0
float smoothed_vzo = ta.sma(vzo_value, 3)
float price_vs_fast_weight = 30.0
float fast_vs_medium_weight = 30.0
float medium_vs_slow_weight = 40.0
float vzo_weight = 20.0
float oscillator_score = 0.0
if src > zlema_fast
oscillator_score += price_vs_fast_weight
else if src < zlema_fast
oscillator_score -= price_vs_fast_weight
if zlema_fast > dema_medium
oscillator_score += fast_vs_medium_weight
else if zlema_fast < dema_medium
oscillator_score -= fast_vs_medium_weight
if dema_medium > dema_slow
oscillator_score += medium_vs_slow_weight
else if dema_medium < dema_slow
oscillator_score -= medium_vs_slow_weight
oscillator_score += (smoothed_vzo / 100) * vzo_weight
float max_possible_score = price_vs_fast_weight + fast_vs_medium_weight + medium_vs_slow_weight + vzo_weight
float normalized_score = max_possible_score != 0.0 ? (oscillator_score / max_possible_score) * 100.0 : 0.0
float final_amf = ta.ema(normalized_score / 100.0, smooth_len)
final_amf
f_amf_signal(amf_line, signal_length) =>
ta.ema(amf_line, signal_length)
// ===========================================================================================================
// CACHED CALCULATIONS
// ===========================================================================================================
cached_atr = ta.atr(14)
// ===========================================================================================================
// NORMALIZATION FUNCTIONS
// ===========================================================================================================
f_normalizeInput(value, lookback_period, enable_clipping, clip_threshold) =>
if not enable_input_normalization
value
else
mean_val = ta.sma(value, lookback_period)
variance = ta.sma(math.pow(value - mean_val, 2), lookback_period)
std_val = math.sqrt(variance)
normalized = std_val > 0 ? (value - mean_val) / std_val : 0.0
if enable_clipping
math.max(-clip_threshold, math.min(clip_threshold, normalized))
else
normalized
f_robustNormalize(value, lookback_period) =>
if not enable_input_normalization
value
else
ema_val = ta.ema(value, lookback_period)
abs_dev = math.abs(value - ema_val)
mad_approx = ta.ema(abs_dev, lookback_period) * 1.4826
mad_approx > 0 ? (value - ema_val) / mad_approx : 0.0
// ===========================================================================================================
// SIGNAL SCORING
// ===========================================================================================================
// Tanh approximation
f_tanh(x) =>
ex = math.exp(2 * x)
(ex - 1) / (ex + 1)
f_scoreSignal(amf_score, alma_score, sr_score, swing_score, regime_score) =>
hidden1 = f_tanh(h1_amf_weight*amf_score + h1_alma_weight*alma_score + h1_sr_weight*sr_score + h1_swing_weight*swing_score + h1_regime_weight*regime_score + h1_bias)
hidden2 = f_tanh(h2_amf_weight*amf_score + h2_alma_weight*alma_score + h2_sr_weight*sr_score + h2_swing_weight*swing_score + h2_regime_weight*regime_score + h2_bias)
hidden3 = f_tanh(h3_amf_weight*amf_score + h3_alma_weight*alma_score + h3_sr_weight*sr_score + h3_swing_weight*swing_score + h3_regime_weight*regime_score + h3_bias)
raw_output = out_h1_weight*hidden1 + out_h2_weight*hidden2 + out_h3_weight*hidden3 + out_bias
1.0 / (1.0 + math.exp(-raw_output))
f_scoreSignalNormalized(amf_norm, alma_norm, sr_norm, swing_norm, regime_norm) =>
input_scale = 0.8
scaled_amf = amf_norm * input_scale
scaled_alma = alma_norm * input_scale
scaled_sr = sr_norm * input_scale
scaled_swing = swing_norm * input_scale
scaled_regime = regime_norm * input_scale
hidden1 = f_tanh(h1_amf_weight*scaled_amf + h1_alma_weight*scaled_alma +
h1_sr_weight*scaled_sr + h1_swing_weight*scaled_swing + h1_regime_weight*scaled_regime + h1_bias)
hidden2 = f_tanh(h2_amf_weight*scaled_amf + h2_alma_weight*scaled_alma +
h2_sr_weight*scaled_sr + h2_swing_weight*scaled_swing + h2_regime_weight*scaled_regime + h2_bias)
hidden3 = f_tanh(h3_amf_weight*scaled_amf + h3_alma_weight*scaled_alma +
h3_sr_weight*scaled_sr + h3_swing_weight*scaled_swing + h3_regime_weight*scaled_regime + h3_bias)
raw_output = out_h1_weight*hidden1 + out_h2_weight*hidden2 + out_h3_weight*hidden3 + out_bias
temperature = 1.2
1.0 / (1.0 + math.exp(-raw_output / temperature))
f_getSignalGrade(score) =>
if score >= 0.80
">80"
else if score >= 0.76
"76"
else if score >= 0.65
"65"
else if score >= 0.40
"40"
else if score >= 0.32
"32"
else
"<32" // (< 0.32)
f_getScoreColor(score) =>
var color result_color = color.maroon
if score >= 0.76
result_color := customBuyColor
else if score >= 0.65
result_color := color.new(customBuyColor, 20)
else if score >= 0.40
result_color := color.new(#00FFFF, 30)
else if score >= 0.32
result_color := color.new(#FFB000, 0)
else
result_color := customSellColor
result_color
// AMF Analysis Functions
f_analyzeAMF(amf_line, signal_line, is_buy, is_sell, cached_atr) =>
amf_vs_signal = amf_line - signal_line
crossing_up = amf_line > signal_line and amf_line[1] <= signal_line[1]
crossing_down = amf_line < signal_line and amf_line[1] >= signal_line[1]
normalized_distance = math.abs(amf_vs_signal) / cached_atr
is_far = normalized_distance > amf_far_threshold
signal_slope = (signal_line - signal_line[1]) / cached_atr
slope_fast_falling = signal_slope < -amf_slope_fast_threshold
slope_fast_rising = signal_slope > amf_slope_fast_threshold
var float amf_score = 0.0
if is_buy
if crossing_up or amf_line > signal_line
amf_score := 1.0
else if amf_line < signal_line
if is_far
amf_score := -0.8
else
amf_score := -0.4
else
amf_score := 0.0
if slope_fast_falling
amf_score := amf_score - 0.3
else if is_sell
if crossing_down or amf_line < signal_line
amf_score := 1.0
else if amf_line > signal_line
if is_far
amf_score := -0.8
else
amf_score := -0.4
else
amf_score := 0.0
if slope_fast_rising
amf_score := amf_score - 0.3
else
amf_score := 0.0
math.max(-1.0, math.min(1.0, amf_score))
f_analyzeALMA(fast_alma, slow_alma, is_buy, is_sell, cached_atr) =>
alma_gap = fast_alma - slow_alma
normalized_gap = math.abs(alma_gap) / cached_atr
is_wide_gap = normalized_gap > alma_wide_gap_threshold
crossing_up = fast_alma > slow_alma and fast_alma[1] <= slow_alma[1]
crossing_down = fast_alma < slow_alma and fast_alma[1] >= slow_alma[1]
var float alma_score = 0.0
if is_buy
if crossing_up or fast_alma > slow_alma
alma_score := 0.5
else if fast_alma < slow_alma
if is_wide_gap
alma_score := -0.8
else
alma_score := -0.2
else
alma_score := 0.0
else if is_sell
if crossing_down or fast_alma < slow_alma
alma_score := 0.5
else if fast_alma > slow_alma
if is_wide_gap
alma_score := -0.8
else
alma_score := -0.2
else
alma_score := 0.0
else
alma_score := 0.0
alma_score
f_analyzeSupportResistance(is_buy, is_sell, cached_atr, sig_high, sig_low, sig_close) =>
pivot_high = ta.pivothigh(sig_high, pivot_lookback, pivot_lookback)
pivot_low = ta.pivotlow(sig_low, pivot_lookback, pivot_lookback)
var float nearest_resistance = na
var float nearest_support = na
if not na(pivot_high)
nearest_resistance := pivot_high
if not na(pivot_low)
nearest_support := pivot_low
resistance_distance = nearest_resistance > 0 ? math.abs(sig_close - nearest_resistance) / cached_atr : 999
support_distance = nearest_support > 0 ? math.abs(sig_close - nearest_support) / cached_atr : 999
near_resistance = resistance_distance <= sr_proximity_threshold
near_support = support_distance <= sr_proximity_threshold
recent_resistance_break = nearest_resistance > 0 and sig_close > nearest_resistance and sig_close[5] <= nearest_resistance
recent_support_break = nearest_support > 0 and sig_close < nearest_support and sig_close[5] >= nearest_support
var float sr_score = 0.0
if is_buy
if recent_resistance_break
sr_score := 0.8
else if near_support
sr_score := 0.5
else if near_resistance
sr_score := -0.6
else
sr_score := 0.0
else if is_sell
if recent_support_break
sr_score := 0.8
else if near_resistance
sr_score := 0.5
else if near_support
sr_score := -0.6
else
sr_score := 0.0
else
sr_score := 0.0
sr_score
f_analyzeSwingStructure(is_buy, is_sell, sig_high, sig_low) =>
recent_high = ta.highest(sig_high, swing_structure_length)
recent_low = ta.lowest(sig_low, swing_structure_length)
previous_high = ta.highest(sig_high[swing_structure_length], swing_structure_length)
previous_low = ta.lowest(sig_low[swing_structure_length], swing_structure_length)
making_higher_highs = recent_high > previous_high
making_higher_lows = recent_low > previous_low
making_lower_highs = recent_high < previous_high
making_lower_lows = recent_low < previous_low
bullish_structure = making_higher_highs and making_higher_lows
bearish_structure = making_lower_highs and making_lower_lows
mixed_structure = not bullish_structure and not bearish_structure
var float swing_score = 0.0
if is_buy
if bullish_structure
swing_score := 0.6
else if bearish_structure
swing_score := -0.7
else
swing_score := -0.1
else if is_sell
if bearish_structure
swing_score := 0.6
else if bullish_structure
swing_score := -0.7
else
swing_score := -0.1
else
swing_score := 0.0
swing_score
f_analyzeMarketRegime(is_buy, is_sell, sig_open, sig_high, sig_low, sig_close) =>
tr1 = math.max(sig_high - sig_low, math.abs(sig_high - sig_close[1]))
tr = math.max(tr1, math.abs(sig_low - sig_close[1]))
plus_dm = sig_high - sig_high[1] > sig_low[1] - sig_low ? math.max(sig_high - sig_high[1], 0) : 0
minus_dm = sig_low[1] - sig_low > sig_high - sig_high[1] ? math.max(sig_low[1] - sig_low, 0) : 0
plus_di = 100 * ta.rma(plus_dm, regime_lookback) / ta.rma(tr, regime_lookback)
minus_di = 100 * ta.rma(minus_dm, regime_lookback) / ta.rma(tr, regime_lookback)
dx = math.abs(plus_di - minus_di) / (plus_di + minus_di) * 100
adx = ta.rma(dx, regime_lookback)
trending_market = adx >= trending_threshold * 100
ranging_market = not trending_market
bullish_trend = trending_market and plus_di > minus_di
bearish_trend = trending_market and minus_di > plus_di
var float regime_score = 0.0
if is_buy
if bullish_trend
regime_score := 0.7
else if bearish_trend
regime_score := -0.8
else
regime_score := -0.2
else if is_sell
if bearish_trend
regime_score := 0.7
else if bullish_trend
regime_score := -0.8
else
regime_score := -0.2
else
regime_score := 0.0
regime_score
// ===========================================================================================================
// CANDLE TYPE CALCULATIONS
// ===========================================================================================================
// Heikin Ashi
calculateHA111() =>
var haOpen = 0.0
var haHigh = 0.0
var haLow = 0.0
var haClose = 0.0
newHaClose = (open + high + low + close) / 4
newHaOpen = na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
newHaHigh = math.max(high, math.max(newHaOpen, newHaClose))
newHaLow = math.min(low, math.min(newHaOpen, newHaClose))
haClose := newHaClose
haOpen := newHaOpen
haHigh := newHaHigh
haLow := newHaLow
[newHaOpen, newHaHigh, newHaLow, newHaClose]
[oHA, hHA, lHA, cHA] = calculateHA111()
var float displayOpen = na
var float displayHigh = na
var float displayLow = na
var float displayClose = na
if candleType == 'Candlesticks'
displayOpen := open
displayHigh := high
displayLow := low
displayClose := close
else if candleType == 'Heikin Ashi'
displayOpen := oHA
displayHigh := hHA
displayLow := lHA
displayClose := cHA
else if candleType == 'Linear Regression'
displayOpen := ta.linreg(open, lrcLength1, 0)
displayHigh := ta.linreg(high, lrcLength1, 0)
displayLow := ta.linreg(low, lrcLength1, 0)
displayClose := ta.linreg(close, lrcLength1, 0)
// Determine coloring
isBullishCandle = displayClose > displayOpen
isBearishCandle = displayClose < displayOpen
// ===========================================================================================================
// SIGNAL DATA SOURCE SELECTION
// ===========================================================================================================
var float signalOpenCalc = na
var float signalHighCalc = na
var float signalLowCalc = na
var float signalCloseCalc = na
if signalCandleType == 'Candlesticks'
signalOpenCalc := open
signalHighCalc := high
signalLowCalc := low
signalCloseCalc := close
else if signalCandleType == 'Heikin Ashi'
signalOpenCalc := oHA
signalHighCalc := hHA
signalLowCalc := lHA
signalCloseCalc := cHA
else if signalCandleType == 'Linear Regression'
signalOpenCalc := ta.linreg(open, lrcLength1, 0)
signalHighCalc := ta.linreg(high, lrcLength1, 0)
signalLowCalc := ta.linreg(low, lrcLength1, 0)
signalCloseCalc := ta.linreg(close, lrcLength1, 0)
signalOpen := signalOpenCalc
signalHigh := signalHighCalc
signalLow := signalLowCalc
signalClose := signalCloseCalc
// ===========================================================================================================
// SCALP HELPER SIGNAL SYSTEM
// ===========================================================================================================
buy_signal_buySignal = false
sell_signal_sellSignal = false
buy_atr_sellSignal = false
sell_atr_buySignal = false
buy_atr_longStop = close
sell_atr_shortStop = close
var bool buy_atr_stop_active = false
var bool sell_atr_stop_active = false
if enable_scalp_helper
// ============================================================================
// BUY SIGNAL
// ============================================================================
buy_signal_atr = ta.atr(buy_signal_length) * signal_trigger_mult
buy_signal_longStop = (buy_signal_use_close ? ta.highest(signalClose, buy_signal_length) : ta.highest(signalHigh, buy_signal_length)) - buy_signal_atr
buy_signal_longStopPrev = nz(buy_signal_longStop[1], buy_signal_longStop)
buy_signal_longStop := signalClose[1] > buy_signal_longStopPrev ? math.max(buy_signal_longStop, buy_signal_longStopPrev) : buy_signal_longStop
buy_signal_shortStop = (buy_signal_use_close ? ta.lowest(signalClose, buy_signal_length) : ta.lowest(signalLow, buy_signal_length)) + buy_signal_atr
buy_signal_shortStopPrev = nz(buy_signal_shortStop[1], buy_signal_shortStop)
buy_signal_shortStop := signalClose[1] < buy_signal_shortStopPrev ? math.min(buy_signal_shortStop, buy_signal_shortStopPrev) : buy_signal_shortStop
var int buy_signal_dir = 1
buy_signal_dir := signalClose > buy_signal_shortStopPrev ? 1 : signalClose < buy_signal_longStopPrev ? -1 : buy_signal_dir
buy_signal_buySignal := buy_signal_dir == 1 and buy_signal_dir[1] == -1
// ============================================================================
// BUY ATR STOP
// ============================================================================
buy_atr_atr = ta.atr(buy_atr_length) * stop_atr_mult
buy_atr_longStop := (buy_atr_use_close ? ta.highest(signalClose, buy_atr_length) : ta.highest(signalHigh, buy_atr_length)) - buy_atr_atr
buy_atr_longStopPrev = nz(buy_atr_longStop[1], buy_atr_longStop)
buy_atr_longStop := signalClose[1] > buy_atr_longStopPrev ? math.max(buy_atr_longStop, buy_atr_longStopPrev) : buy_atr_longStop
buy_atr_shortStop = (buy_atr_use_close ? ta.lowest(signalClose, buy_atr_length) : ta.lowest(signalLow, buy_atr_length)) + buy_atr_atr
buy_atr_shortStopPrev = nz(buy_atr_shortStop[1], buy_atr_shortStop)
buy_atr_shortStop := signalClose[1] < buy_atr_shortStopPrev ? math.min(buy_atr_shortStop, buy_atr_shortStopPrev) : buy_atr_shortStop
var int buy_atr_dir = 1
buy_atr_dir := signalClose > buy_atr_shortStopPrev ? 1 : signalClose < buy_atr_longStopPrev ? -1 : buy_atr_dir
buy_atr_sellSignal := buy_atr_dir == -1 and buy_atr_dir[1] == 1
// ============================================================================
// SELL SIGNAL
// ============================================================================
sell_signal_atr = ta.atr(sell_signal_length) * signal_trigger_mult
sell_signal_longStop = (sell_signal_use_close ? ta.highest(signalClose, sell_signal_length) : ta.highest(signalHigh, sell_signal_length)) - sell_signal_atr
sell_signal_longStopPrev = nz(sell_signal_longStop[1], sell_signal_longStop)
sell_signal_longStop := signalClose[1] > sell_signal_longStopPrev ? math.max(sell_signal_longStop, sell_signal_longStopPrev) : sell_signal_longStop
sell_signal_shortStop = (sell_signal_use_close ? ta.lowest(signalClose, sell_signal_length) : ta.lowest(signalLow, sell_signal_length)) + sell_signal_atr
sell_signal_shortStopPrev = nz(sell_signal_shortStop[1], sell_signal_shortStop)
sell_signal_shortStop := signalClose[1] < sell_signal_shortStopPrev ? math.min(sell_signal_shortStop, sell_signal_shortStopPrev) : sell_signal_shortStop
var int sell_signal_dir = 1
sell_signal_dir := signalClose > sell_signal_shortStopPrev ? 1 : signalClose < sell_signal_longStopPrev ? -1 : sell_signal_dir
sell_signal_sellSignal := sell_signal_dir == -1 and sell_signal_dir[1] == 1
// ============================================================================
// SELL ATR STOP
// ============================================================================
sell_atr_atr = ta.atr(sell_atr_length) * stop_atr_mult
sell_atr_longStop = (sell_atr_use_close ? ta.highest(signalClose, sell_atr_length) : ta.highest(signalHigh, sell_atr_length)) - sell_atr_atr
sell_atr_longStopPrev = nz(sell_atr_longStop[1], sell_atr_longStop)
sell_atr_longStop := signalClose[1] > sell_atr_longStopPrev ? math.max(sell_atr_longStop, sell_atr_longStopPrev) : sell_atr_longStop
sell_atr_shortStop := (sell_atr_use_close ? ta.lowest(signalClose, sell_atr_length) : ta.lowest(signalLow, sell_atr_length)) + sell_atr_atr
sell_atr_shortStopPrev = nz(sell_atr_shortStop[1], sell_atr_shortStop)
sell_atr_shortStop := signalClose[1] < sell_atr_shortStopPrev ? math.min(sell_atr_shortStop, sell_atr_shortStopPrev) : sell_atr_shortStop
var int sell_atr_dir = 1
sell_atr_dir := signalClose > sell_atr_shortStopPrev ? 1 : signalClose < sell_atr_longStopPrev ? -1 : sell_atr_dir
sell_atr_buySignal := sell_atr_dir == 1 and sell_atr_dir[1] == -1
// ============================================================================
// SIGNAL STATE MANAGEMENT
// ============================================================================
if not buy_atr_stop_active
if buy_signal_buySignal
buy_atr_stop_active := true
else
if buy_atr_sellSignal
buy_atr_stop_active := false
if not sell_atr_stop_active
if sell_signal_sellSignal
sell_atr_stop_active := true
else
if sell_atr_buySignal
sell_atr_stop_active := false
// ===========================================================================================================
// CORE CALCULATIONS
// ===========================================================================================================
// AMF Calculations
amf_line = f_calculate_amf(signalClose, amf_length, amf_fast_length, amf_slow_length, amf_smoothing)
amf_signal = f_amf_signal(amf_line, amf_signal_length)
// Cached ATR
atr14 = ta.atr(14)
// ALMA calculations for neural network (Use Signal Candles for analysis)
alma200 = ta.alma(signalClose, almaLength, almaOffset, almaSigma)
alma2 = ta.alma(signalClose, alma2Length, alma2Offset, alma2Sigma)
// ===========================================================================================================
// NEURAL NETWORK
// ===========================================================================================================
is_buy_signal = buy_signal_buySignal
is_sell_signal = sell_signal_sellSignal
amf_context = f_analyzeAMF(amf_line, amf_signal, is_buy_signal, is_sell_signal, atr14)
alma_context = f_analyzeALMA(alma200, alma2, is_buy_signal, is_sell_signal, atr14)
sr_context = f_analyzeSupportResistance(is_buy_signal, is_sell_signal, atr14, signalHigh, signalLow, signalClose)
swing_context = f_analyzeSwingStructure(is_buy_signal, is_sell_signal, signalHigh, signalLow)
regime_context = f_analyzeMarketRegime(is_buy_signal, is_sell_signal, signalOpen, signalHigh, signalLow, signalClose)
amf_context_normalized = f_normalizeInput(amf_context, normalization_lookback, outlier_clipping, clipping_threshold)
alma_context_normalized = f_normalizeInput(alma_context, normalization_lookback, outlier_clipping, clipping_threshold)
sr_context_normalized = f_normalizeInput(sr_context, normalization_lookback, outlier_clipping, clipping_threshold)
swing_context_normalized = f_normalizeInput(swing_context, normalization_lookback, outlier_clipping, clipping_threshold)
regime_context_normalized = f_normalizeInput(regime_context, normalization_lookback, outlier_clipping, clipping_threshold)
signal_score = (is_buy_signal or is_sell_signal) ?
f_scoreSignalNormalized(amf_context_normalized, alma_context_normalized,
sr_context_normalized, swing_context_normalized, regime_context_normalized) : 0.5
signal_grade = f_getSignalGrade(signal_score)
score_color = f_getScoreColor(signal_score)
// ===========================================================================================================
// CANDLE PLOTTING
// ===========================================================================================================
candleColor = isBullishCandle ? customBuyColor : customSellColor
plotcandle(candleType != 'Candlesticks' ? displayOpen : na,
candleType != 'Candlesticks' ? displayHigh : na,
candleType != 'Candlesticks' ? displayLow : na,
candleType != 'Candlesticks' ? displayClose : na,
title = 'BAR',
color = candleType != 'Candlesticks' ? candleColor : na,
wickcolor = candleType != 'Candlesticks' ? candleColor : na,
bordercolor = candleType != 'Candlesticks' ? candleColor : na)
// ===========================================================================================================
// SCALP HELPER SIGNAL PLOTS
// ===========================================================================================================
atr_offset = signalOffset * atr14
show_buy_signal = enable_scalp_helper and buy_signal_buySignal and not buy_atr_stop_active[1]
show_sell_signal = enable_scalp_helper and sell_signal_sellSignal and not sell_atr_stop_active[1]
label_size = signalLabelSize == 'tiny' ? size.tiny :
signalLabelSize == 'small' ? size.small :
signalLabelSize == 'large' ? size.large : size.normal
if showScalpLabels and show_buy_signal
buy_label_text = signal_grade
label.new(bar_index, signalLow - atr_offset,
text = buy_label_text,
style = label.style_label_up,
size = label_size,
color = score_color,
textcolor = color.black)
if showScalpLabels and show_sell_signal
sell_label_text = signal_grade
label.new(bar_index, signalHigh + atr_offset,
text = sell_label_text,
style = label.style_label_down,
size = label_size,
color = score_color,
textcolor = color.black)
/////////////////////////////////////////////////////////////////////
// Kullanıcı Girişleri
slow_sar_set = input.float(0.3, 'Slow SAR', minval = 0.01, maxval = 0.3, group = 'SAR Settings')
sar_set = input.float(0.2, 'Normal SAR', minval = 0.01, maxval = 0.2, group = 'SAR Settings')
fast_sar_set = input.float(0.1, 'Fast SAR', minval = 0.01, maxval = 0.1, group = 'SAR Settings')
sar_avg_length = input.int(1, 'Hareketli Ortalama Uzunluğu', minval = 1, group = 'SAR Settings')
// Hesaplamalar
// ta.sar(baslangic, artis, maksimum) - sayı küçüldükçe değişim hızı artar
fast_sar = ta.sar(fast_sar_set, fast_sar_set, 0.1)
sar = ta.sar(sar_set, sar_set, 0.1)
slow_sar = ta.sar(slow_sar_set, slow_sar_set, 0.1)
// Hareketli Ortalama
sar_avg = ta.sma(sar, sar_avg_length)
// Çizimler
plot(fast_sar, title = '1Z', color = close > fast_sar ? #00ff0000 : #ffbbba00, style = plot.style_circles, linewidth = 1)
plot(sar, title = '2Z', color = close > sar ? #00b80000 : #ff010100, style = plot.style_circles, linewidth = 1)
plot(slow_sar, title = '3Z', color = close > slow_sar ? #14571500 : #aa000000, style = plot.style_circles, linewidth = 1)
///////////////////////////
// Ortak başlangıç değeri
start = 0.01
// 3 SAR (farklı hızlarda)
sar1 = ta.sar(start, 0.2, 0.2)
sar2 = ta.sar(start, 0.3, 0.3)
sar3 = ta.sar(start, 0.5, 0.5)
// 4. SAR ve EMA(5) ile yumuşatma
sar4_raw = ta.sar(start, 1, 1)
sar4_ema = ta.ema(sar4_raw, 5)
// SAR4 EMA çizgi rengi: fiyatın üstünde yeşil, altında kırmızı
sar4_color = close > sar4_ema ? color.white : color.fuchsia
plot(sar1, title = '1Y', color = close > sar1 ? #00ff0000 : #ffbbba00, style = plot.style_circles, linewidth = 1)
plot(sar2, title = '2Y', color = close > sar2 ? #00b80000 : #ff010100, style = plot.style_circles, linewidth = 1)
plot(sar3, title = '3Y', color = close > sar3 ? #14571500 : #aa000000, style = plot.style_circles, linewidth = 1)
// SAR4 EMA çizgisi (renkli)
//plot(sar4_ema, title = 'Z', color = sar4_color, style = plot.style_line, linewidth = 2)
/////////////////////////
// === SAR'lar
sar19 = ta.sar(0., 0.1, 0.1)
sar59 = ta.sar(0., 0.1, 0.1)
sar109 = ta.sar(0., 0.1, 0.1)
// === Gerçek eşitlik kontrolü
equalAll = sar19 == sar59 and sar59 == sar109
sort9 = (sar19 + sar59 + sar109) / 3
//plot(sort9, title = 'X', color = sar4_color, style = plot.style_stepline, linewidth = 1)
////////////////////////
price7 = hl2
tolerans7 = 0.001
// === SAR'lar ===
sar17 = ta.sar(0.001, 0.02, 0.2)
sar27 = ta.sar(0.001, 0.03, 0.3)
sar37 = ta.sar(0.001, 0.04, 0.4)
plot(sar17, title = '1X', color = close > sar17 ? #00ff0000 : #ffbbba00, style = plot.style_circles, linewidth = 1)
plot(sar27, title = '2X', color = close > sar27 ? #00b80000 : #ff010100, style = plot.style_circles, linewidth = 1)
plot(sar37, title = '3X', color = close > sar37 ? #14571500 : #aa000000, style = plot.style_circles, linewidth = 1)
// === SAR yakınlığı kontrolü ===
yakinsar7 = math.abs(sar17 - sar27) < tolerans7 or math.abs(sar17 - sar37) < tolerans7 or math.abs(sar27 - sar37) < tolerans7
longSignal7 = yakinsar7 and price7 > sar17
shortSignal7 = yakinsar7 and price7 < sar17
// === Sinyal üçgenleri ===
plotshape(longSignal7, location = location.belowbar, style = shape.triangleup, color = color.fuchsia, size = size.tiny)
plotshape(shortSignal7, location = location.abovebar, style = shape.triangledown, color = color.fuchsia, size = size.tiny)
//////////////////
// 5 SAR hesapla
sar18 = ta.sar(0.1, 0.1, 0.1)
sar28 = ta.sar(0.1, 0.3, 0.3)
sar38 = ta.sar(0.1, 0.5, 0.5)
sar48 = ta.sar(0.1, 0.7, 0.7)
sar58 = ta.sar(0.1, 1.0, 1.0)
// SAR ortalaması ve EMA(3) ile smooth
sarAvg8 = (sar18 + sar28 + sar38 + sar48 + sar58) / 5
smoothedSar8 = ta.ema(sarAvg8, 10)
// EMA(1) (fiyat çizgisi)
ema18 = ta.ema(close, 1)
// Çizgiler
//plot(smoothedSar8, title = 'Y', color = sar4_color, style = plot.style_stepline, linewidth = 1)
TREND789=(smoothedSar8+sort9+sar4_ema)/3
plot(TREND789, title = 'TR3', color = sar4_color, style = plot.style_stepline, linewidth = 1)
SAR7 = ta.sar(0.04, 0.04, 0.3)
SAR8 = ta.sar(0.03, 0.03, 0.25)
plot(SAR7, title = 'TR1', style = plot.style_line, linewidth = 1, color = sar4_color)
plot(SAR8, title = 'TR2', style = plot.style_line, linewidth = 1, color = sar4_color)
// === SAR sıkışma kontrolü ===
tolerance22 = input.float(0.0005, title = 'SAR Yakınlık Toleransı')
sar_near22 = math.abs(SAR7 - SAR8) < tolerance22
bgcolor(sar_near22 ? color.new(color.yellow, 75) : na, title = 'SAR Sıkışma Alanı')
// Sinyaller
longSignal8 = ta.crossover(ema18, smoothedSar8) // AL
shortSignal8 = ta.crossunder(ema18, smoothedSar8) // SAT
// Sinyal üçgenleri
plotshape(longSignal8, title = 'AL Sinyali', location = location.belowbar, style = shape.triangleup, color = color.lime, size = size.small)
plotshape(shortSignal8, title = 'SAT Sinyali', location = location.abovebar, style = shape.triangledown, color = color.red, size = size.small)
/////////////////////
/////////////////////////////////İMZA AT//////////////////////////////////////////////////
var table logo = table.new(position.bottom_center, 1, 1)
if barstate.islast
table.cell(logo, 0, 0, '@yörük@ EĞİTİM ÇALIŞMASIDIR.', text_size = size.normal, text_color = color.rgb(218, 241, 5))
// === Girişler ===
uz1 = input(1, title = 'Periyot (lowest/highest)')
atr1 = input(10, title = 'ATR Periyodu')
az1 = input(1, title = 'ATR Katsayısı')
// === Stop seviyeleri ===
ss1 = ta.lowest(uz1) + az1 * ta.atr(atr1) // üstten takip
ll1 = ta.highest(uz1) - az1 * ta.atr(atr1) // alttan takip
// === İlk tanımlamalar ===
var float ssx1 = na
var float llx1 = na
ssx1 := na(ssx1[1]) ? ss1 : close > ssx1[1] ? ss1 : math.min(ss1, ssx1[1])
llx1 := na(llx1[1]) ? ll1 : close < llx1[1] ? ll1 : math.max(ll1, llx1[1])
// === Sinyaller ===
yunus1 = close >= ssx1[1] and close[1] < ssx1[1] ? 1 : 0
yusuf1 = close <= llx1[1] and close[1] > llx1[1] ? 1 : 0
// === Trend durumu ===
var int fato1 = 0
fato1 := fato1 <= 0 and bool(yunus1) ? 1 : fato1 >= 0 and bool(yusuf1) ? -1 : fato1
// === Gösterim ===
memo1 = fato1 > 0 ? llx1 : ssx1
plot(memo1, title = 'STOP', color = fato1 > 0 ? color.rgb(255, 255, 255, 100) : color.rgb(223, 64, 251, 100), linewidth = 2)
///////////////////ATR HESAPLA///////////////////////////////////////////////////////
var params = "Parameters"
src55 = nz(input.source(close, title = "Source", group = params))
len55 = input.int(10, title = "ATR Len", group = params)
multi55 = input.float(1.5, title = "Multi", step = 0.25, minval = 0, group = params)
var cols = "Colors"
up_col = input.color(color.rgb(255, 255, 255, 100), title = "Yükseliş", group = cols)
down_col = input.color(color.rgb(223, 64, 251, 100), title = "DÜşüş", group = cols)
flat_col = input.color(color.rgb(223, 64, 251, 100), title = "Flat ", inline = "3", group = cols)
rope_smoother(float _src55, float _threshold) =>
var float _rope = _src55
_move = _src55 - _rope //Movement from Rope
_rope += math.max(math.abs(_move) - nz(_threshold), 0) * math.sign(_move) //Directional Movement beyond the Threshold
[_rope,_rope+_threshold,_rope-_threshold] //[Rope, Upper, Lower]
///_____________________________________________________________________________________________________________________
//Calculating Rope
atr99 = ta.atr(len55)*multi55
[rope,upper,lower] = rope_smoother(src55,atr99)
//Directional Detection
var dir89 = 0
dir89 := rope > rope[1] ? 1 : rope < rope[1] ? -1 : dir89
if ta.cross(src55,rope)
dir89 := 0
//Directional Color Assignment
col = dir89 > 0 ? up_col : dir89 < 0 ? down_col : flat_col
//High and Low Output Lines
var float c_hi = na
var float c_lo = na
//Counters for Accumulating Averages
var float h_sum = 0
var float l_sum = 0
var int c_count = 0
//Flip-Flop
var ff = 1
if dir89 == 0
if dir89[1] != 0
h_sum := 0
l_sum := 0
c_count := 0
ff := ff * -1
h_sum += upper
l_sum += lower
c_count += 1
c_hi := h_sum/c_count
c_lo := l_sum/c_count
///
plot(rope, linewidth = 2, color = col, title = "ATR", force_overlay = true)
/////////////////////////////EN HIZLI SARLA BAR RENKLENDİR////////////////////
// —————————————————————————————————————————
f_colorNew(_color, _transp) =>
var _r = color.r(_color)
var _g = color.g(_color)
var _b = color.b(_color)
color _return = color.rgb(_r, _g, _b, _transp)
_return
//automatic higher timeframe chooser
f_autoHTF(str) =>
str == '1S' or str == '5S' or str == '10S' or str == '15S' or str == '20S' or str == '30S' or str == '40S' or str == '45S' or str == '50S' ? '1' : str == '1' or str == '2' or str == '3' or str == '4' ? '5' : str == '5' or str == '10' ? '15' : str == '15' or str == '20' ? '30' : str == '30' or str == '45' or str == '50' ? '60' : str == '60' or str == '90' or str == '100' ? '120' : str == '120' or str == '180' ? '240' : str == '240' ? 'D' : str == 'D' ? 'W' : str == 'W' ? '2W' : 'M'
var string ticker = syminfo.tickerid
var string tfp = timeframe.period
htf1 = f_autoHTF(tfp)
htf2 = f_autoHTF(htf1)
htf3 = f_autoHTF(htf2)
htf4 = f_autoHTF(htf3)
f_security(_sym, _res, _src, _rep) =>
request.security(_sym, _res, _src[not _rep and barstate.isrealtime ? 1 : 0])[_rep or barstate.isrealtime ? 0 : 1]
//PSAR inputs
grpin = '⚙=====-----'
grpout = '-----=====⚙'
grpPSAR = grpin + 'Dual PSAR Options:' + grpout
colorBull = input.color(defval = color.rgb(3, 7, 248, 70), group = grpPSAR, title = 'Bullish Color') //Light Blue
colorBear = input.color(defval = #fc07072f, group = grpPSAR, title = 'Bearish Color') //yellow
colorWait = input.color(defval = color.rgb(241, 191, 9, 70), group = grpPSAR, title = 'Wait Color') //grey
showRecolorCandles = input.bool(true, 'Show Trend Full-Candle Recoloring?', group = grpPSAR, tooltip = 'Recolor the full candle including wick and border with trend color.')
psar_start = input.float(defval = 0., group = grpPSAR, title = 'PSAR: Start', minval = 0., maxval = 2, step = 0.01)
psar_accel = input.float(defval = 0.1, group = grpPSAR, title = 'PSAR: Acceleration Factor', minval = 0.01, maxval = 2, step = 0.01)
psar_maximum = input.float(defval = 0.9, group = grpPSAR, title = 'PSAR: Extreme Point', minval = 0.01, maxval = 2)
f_psar() =>
ta.sar(psar_start, psar_accel, psar_maximum)
psar_ctf = f_psar()
psar_htf = f_security(ticker, htf1, f_psar(), false)
longZone = psar_ctf < low and psar_htf < low
shortZone = psar_ctf > high and psar_htf > high
waitZone = not longZone and not shortZone
trendSupportColor = longZone ? colorBull : shortZone ? colorBear : colorWait
plotcandle(showRecolorCandles ? open : na, high, low, close, color = trendSupportColor, wickcolor = trendSupportColor, bordercolor = trendSupportColor, title = 'BAR')
barcolor(trendSupportColor)
///////////////////SON BARI ATR İLE OLASILIK HESAPLA///////////////////////
// Inputs
length14 = input.int(title = 'ATR Length', defval = 1, minval = 1)
tradetype14 = input.string(defval = 'Long', title = 'Trade Type', options = ['Long', 'Short'])
takeprofit14 = input.float(1, 'Take Profit Times ATR', minval = 0.1)
stoploss14 = input.float(1.6, 'Stop Loss Times ATR', minval = 0.1)
index14 = input(0, 'Display Index')
// Functions
getMA(series, length14) =>
ta.rma(series, length14)
getTV(value) =>
math.round(value * 100000) / 100000
// Variables
atr148 = getMA(ta.tr(true), length14)[index14]
posTake = tradetype14 == 'Long' ? close[index14] + takeprofit14 * atr148 : close[index14] - takeprofit14 * atr148
posStop = tradetype14 == 'Long' ? close[index14] - stoploss14 * atr148 : close[index14] + stoploss14 * atr148
colorTake = color.new(color.lime, 50)
colorStop = color.new(color.red, 50)
// Plots
plotcandle(close[index14], posTake, close[index14], posTake, title = 'OLST', color = index14 == 0 ? colorTake : na, bordercolor = index14 == 0 ? colorTake : na, wickcolor = na, show_last = 1)
plotcandle(close[index14], close, posStop, posStop, title = 'OLSD', color = index14 == 0 ? colorStop : na, bordercolor = index14 == 0 ? colorStop : na, wickcolor = na, show_last = 1)
////////////////10 SAR HESAPLA VE 10NUDA LA VERİRSE ARKA PLANI YEŞİLLENDİR//////////////
// === PSAR Settings === //
abh97 = 0.001
abh96 = 0.1
// === Manually defined 10 PSARs === //
psar132 = ta.sar(abh97, 0.001, abh96)
psar232 = ta.sar(abh97, 0.002, abh96)
psar332 = ta.sar(abh97, 0.003, abh96)
psar432 = ta.sar(abh97, 0.004, abh96)
psar532 = ta.sar(abh97, 0.005, abh96)
psar632 = ta.sar(abh97, 0.006, abh96)
psar732 = ta.sar(abh97, 0.007, abh96)
psar832 = ta.sar(abh97, 0.008, abh96)
psar932 = ta.sar(abh97, 0.009, abh96)
psar1032 = ta.sar(abh97, 0.010, abh96)
// === PSAR Trend Alignment Check === //
allBelow32 = psar132 < close and psar232 < close and psar332 < close and psar432 < close and psar532 < close and
psar632 < close and psar732 < close and psar832 < close and psar932 < close and psar1032 < close
allAbove32 = psar132 > close and psar232 > close and psar332 > close and psar432 > close and psar532 > close and
psar632 > close and psar732 > close and psar832 > close and psar932 > close and psar1032 > close
// === Trend Signal === //
trendUp32 = allBelow32
trendDown32 = allAbove32
trendNeutral32 = not trendUp32 and not trendDown32
// === Background Color === //
bgcolor(trendUp32 ? color.new(color.green, 85) : na, title="Up Trend Background")
//////////////////////////
//////////////////////////EN HIZLI SAR İLE MTF HESAPLA TABLO YAP/////////////////////////////////////
start46 = input(0.)
increment46 = input(0.001)
maximum46 = input(0.01, "Max Value")
out55 = ta.sar(start46, increment46, maximum46)
plot_color = close > out55 ? color.rgb(5, 182, 64) : close < out55 ? color.rgb(169, 7, 7) : na
show_header = input(false, title="Show header?", group='Table Settings')
dashboard_position = input.string("Top center", title="Position", options=["Top right", "Top center", "Middle right"], group='Table Settings')
text_size = input.string('Normal', title="Size", options=["Tiny", "Small", "Normal", "Large"], group='Table Settings')
text_color = input.color(color.rgb(11, 68, 224), title="Text color", group='Table Settings')
table_color = input.color(color.purple, title="Border color", group='Table Settings')
uptrend_indicator = "🔵"
downtrend_indicator = "🟠"
tf11 = input.timeframe("1", title="Timeframe 1")
tf22 = input.timeframe("3", title="Timeframe 2")
tf33 = input.timeframe("5", title="Timeframe 3")
tf4 = input.timeframe("10", title="Timeframe 4")
tf5 = input.timeframe("15", title="Timeframe 5")
tf6 = input.timeframe("30", title="Timeframe 6")
tf7 = input.timeframe("60", title="Timeframe 7")
tf8 = input.timeframe("120", title="Timeframe 8")
tf9 = input.timeframe("240", title="Timeframe 9")
tf10 = input.timeframe("D", title="Timeframe 10")
var table_position = dashboard_position == 'Top center' ? position.middle_left :
dashboard_position == 'Top center' ? position.middle_left :
dashboard_position == 'Middle right' ? position.middle_right : position.middle_right
var table_text_size = text_size == 'Normal' ? size.normal :
text_size == 'Small' ? size.small : size.normal
var t = table.new(position=table_position, columns=3, rows=20, frame_color=#cdcbcb, frame_width=5, border_color=table_color, border_width=1,bgcolor =color.rgb(21, 21, 21) )
get_trend_status(trend_value) =>
is_uptrend = close > trend_value
candle_now = is_uptrend ? uptrend_indicator : downtrend_indicator
candle_now
//--------------------------------------------------------------------------------------
sar_1 = request.security(syminfo.tickerid, tf11, ta.sar(start46, increment46, maximum46))
sar_2 = request.security(syminfo.tickerid, tf22, ta.sar(start46, increment46, maximum46))
sar_3 = request.security(syminfo.tickerid, tf33, ta.sar(start46, increment46, maximum46))
sar_4 = request.security(syminfo.tickerid, tf4, ta.sar(start46, increment46, maximum46))
sar_5 = request.security(syminfo.tickerid, tf5, ta.sar(start46, increment46, maximum46))
sar_6 = request.security(syminfo.tickerid, tf6, ta.sar(start46, increment46, maximum46))
sar_7 = request.security(syminfo.tickerid, tf7, ta.sar(start46, increment46, maximum46))
sar_8 = request.security(syminfo.tickerid, tf8, ta.sar(start46, increment46, maximum46))
sar_9 = request.security(syminfo.tickerid, tf9, ta.sar(start46, increment46, maximum46))
sar_10 = request.security(syminfo.tickerid, tf10, ta.sar(start46, increment46, maximum46))
trend_indicator_1 = get_trend_status(sar_1)
trend_indicator_2 = get_trend_status(sar_2)
trend_indicator_3 = get_trend_status(sar_3)
trend_indicator_4 = get_trend_status(sar_4)
trend_indicator_5 = get_trend_status(sar_5)
trend_indicator_6 = get_trend_status(sar_6)
trend_indicator_7 = get_trend_status(sar_7)
trend_indicator_8 = get_trend_status(sar_8)
trend_indicator_9 = get_trend_status(sar_9)
trend_indicator_10 = get_trend_status(sar_10)
if tf11 == "60"
tf11 := "1H"
if tf11 == "120"
tf11 := "2H"
if tf11 == "180"
tf11 := "3H"
if tf11 == "240"
tf11 := "4H"
if tf22 == "60"
tf22 := "1H"
if tf22 == "120"
tf22 := "2H"
if tf22 == "180"
tf22 := "3H"
if tf22 == "240"
tf22 := "4H"
if tf33 == "60"
tf33 := "1H"
if tf33 == "120"
tf33 := "2H"
if tf33 == "180"
tf33 := "3H"
if tf33 == "240"
tf33 := "4H"
if tf4 == "60"
tf4 := "1H"
if tf4 == "120"
tf4 := "2H"
if tf4 == "180"
tf4 := "3H"
if tf4 == "240"
tf4 := "4H"
if tf5 == "60"
tf5 := "1H"
if tf5 == "120"
tf5 := "2H"
if tf5 == "180"
tf5 := "3H"
if tf5 == "240"
tf5 := "4H"
if tf6 == "60"
tf6 := "1H"
if tf6 == "120"
tf6 := "2H"
if tf6 == "180"
tf6 := "3H"
if tf6 == "240"
tf6 := "4H"
if tf7 == "60"
tf7 := "1H"
if tf7 == "120"
tf7 := "2H"
if tf7 == "180"
tf7 := "3H"
if tf7 == "240"
tf7 := "4H"
if tf8 == "60"
tf8 := "1H"
if tf8 == "120"
tf8 := "2H"
if tf8 == "180"
tf8 := "3H"
if tf8 == "240"
tf8 := "4H"
if tf9 == "60"
tf9 := "1H"
if tf9 == "120"
tf9 := "2H"
if tf9 == "180"
tf9 := "3H"
if tf9 == "240"
tf9 := "4H"
if tf10 == "60"
tf10 := "1H"
if tf10 == "120"
tf10 := "2H"
if tf10 == "180"
tf10 := "3H"
if tf10 == "240"
tf10 := "4H"
//---------------------------------------------------------------------------------------------
// Update table with trend data
//---------------------------------------------------------------------------------------------
if (barstate.islast)
table.cell(t, 0, 1, tf11, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 1, text="●", text_color=trend_indicator_1==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 1, str.tostring(sar_1, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 2, tf22, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 2, text="●", text_color=trend_indicator_2==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 2, str.tostring(sar_2, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 3, tf33, text_color=color.white, text_size=table_text_size,bgcolor= color.rgb(21, 21, 21))
table.cell(t, 1, 3, text="●", text_color=trend_indicator_3==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 3, str.tostring(sar_3, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 4, tf4, text_color=color.white, text_size=table_text_size, bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 4, text="●", text_color=trend_indicator_4==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 4, str.tostring(sar_4, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 5, tf5, text_color=color.white, text_size=table_text_size, bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 5, text="●", text_color=trend_indicator_5==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 5, str.tostring(sar_5, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 6, tf6, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 6, text="●", text_color=trend_indicator_6==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 6, str.tostring(sar_6, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 7, tf7, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 7, text="●", text_color=trend_indicator_7==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 7, str.tostring(sar_7, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 8, tf8, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 8, text="●", text_color=trend_indicator_8==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 8, str.tostring(sar_8, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 9, tf9, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 9, text="●", text_color=trend_indicator_9==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 9, str.tostring(sar_9, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 10, tf10, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 10, text="●", text_color=trend_indicator_10==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 10, str.tostring(sar_10, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t,0,0,"Periyot",text_color = color.white,bgcolor = color.rgb(21, 21, 21))
table.cell(t,1,0,"Trend",text_color = color.white,bgcolor = color.rgb(21, 21, 21))
table.cell(t,2,0,"Fiyat",text_color = color.white,bgcolor = color.rgb(21, 21, 21))
lookback = input.int(5, "Line Lookback Period", minval=1)
/////////////////////////////////////////////////////////////SAR HESAPLAMALARI YAP////////////////////////////
A111 = input(0.)
B111 = input(0.01)
C111 = input(0.1, ".")
ABC111 = ta.sar(A111, B111, C111)
plot(ABC111, "@yörük@", style=plot.style_cross, color=color.yellow, linewidth = 2)
////////////////////////////////////////////////////////////////////////////////////////////////////
// === INPUTS === //
atrLength33 = input.int(5, title="ATR Period")
mult33 = input.float(1.0, title="ATR Multiplier (DES/DİR)")
desLookback33 = input.int(1, title="DES/DİR Lookback Period")
psarConfirmCount33 = input.int(6, title="Minimum PSAR Sayısı (Sinyal için)")
// === PSAR Settings === //
start33 = 0.01
max33 = 0.1
// === 10 PSAR hesapla === //
psar133 = ta.sar(start33, 0.01, max33)
psar233 = ta.sar(start33, 0.02, max33)
psar333 = ta.sar(start33, 0.03, max33)
psar433 = ta.sar(start33, 0.04, max33)
psar533 = ta.sar(start33, 0.05, max33)
psar633 = ta.sar(start33, 0.06, max33)
psar733 = ta.sar(start33, 0.07, max33)
psar833 = ta.sar(start33, 0.08, max33)
psar933 = ta.sar(start33, 0.09, max33)
psar1033 = ta.sar(start33, 0.10, max33)
// === Kaç tanesi fiyatın altında/üstünde? === //
countBelow33 = 0
countBelow33 := countBelow33 + (psar133 < close ? 1 : 0)
countBelow33 := countBelow33 + (psar233 < close ? 1 : 0)
countBelow33 := countBelow33 + (psar333 < close ? 1 : 0)
countBelow33 := countBelow33 + (psar433 < close ? 1 : 0)
countBelow33 := countBelow33 + (psar533 < close ? 1 : 0)
countBelow33 := countBelow33 + (psar633 < close ? 1 : 0)
countBelow33 := countBelow33 + (psar733 < close ? 1 : 0)
countBelow33 := countBelow33 + (psar833 < close ? 1 : 0)
countBelow33 := countBelow33 + (psar933 < close ? 1 : 0)
countBelow33 := countBelow33 + (psar1033 < close ? 1 : 0)
countAbove33 = 10 - countBelow33
// === Trend sinyalleri === //
trendUp33 = countBelow33 >= psarConfirmCount33
trendDown33 = countAbove33 >= psarConfirmCount33
// === DES / DİR === //
atr33 = ta.atr(atrLength33)
dir33 = ta.lowest(desLookback33) + mult33 * atr33
des33 = ta.highest(desLookback33) - mult33 * atr33
plot(dir33, title="Direnç", color=color.rgb(223, 64, 251, 100), style=plot.style_linebr, linewidth=2)
plot(des33, title="Destek", color=color.rgb(0, 187, 212, 100), style=plot.style_linebr, linewidth=2)
////////
// === Ayarlar ===
leftBars47 = input(50, title = 'Pivot Left Bars')
rightBars47 = input(50, title = 'Pivot Right Bars')
projBars47 = input(50, title = 'Proj. Bars to the Right')
// === Pivot Noktaları ===
ph47 = ta.pivothigh(leftBars47, rightBars47)
pl47 = ta.pivotlow(leftBars47, rightBars47)
// === Destek/Direnç çizgileri oluştur ===
if not na(ph47)
line.new(bar_index - rightBars47, ph47, bar_index + projBars47, ph47, color = color.red, style = line.style_dashed, width = 2)
if not na(pl47)
line.new(bar_index - rightBars47, pl47, bar_index + projBars47, pl47, color = color.green, style = line.style_dashed, width = 2)
///////////////////////////////////////////////////////////
kombine edilmiş kodlar.... denemek isteyene....içinden istediğiniz kısmı silin atın.... şablon niyetine kullanılabilir....
Yer İmleri