IC Markets

Optimal 1-Minute Stochastic Settings: Ditching 14,3,3 for High-Frequency Precision

Optimize MetaTrader 4, MetaTrader 5, cTrader, and TradingView for speed. Discuss Level II Market Depth (DOM), custom hotkeys, and volume indicators.
FTtrader
Posts: 309
Joined: Mon Aug 03, 2026 2:43 pm

Re: Optimal 1-Minute Stochastic Settings: Ditching 14,3,3 for High-Frequency Precision

Post by FTtrader »

Key Pine Script Specifics:

calc_on_every_tick=false: This line at the very top is the Pine Script equivalent of locking the script to Bar Close only. It prevents repainting and mid-bar false signals, ensuring the strategy only fires when the 1-minute candle locks in the Stochastic crossover.

ta.stoch + ta.sma smoothing: TradingView calculates standard Stochastics slightly differently than MetaTrader by default. By taking ta.stoch and wrapping it in two ta.sma functions using your smooth and d_len parameters, this code exactly mirrors the underlying math of the MT4/5 default oscillator.

Forex Pip Normalization: TradingView reads raw tick sizes. The variable pip_mult = syminfo.mintick * 10 automatically converts your 3 and 5 pip inputs into the correct fractional decimal size required to place accurate bracket orders on your chart.
FTtrader
Posts: 309
Joined: Mon Aug 03, 2026 2:43 pm

Re: Optimal 1-Minute Stochastic Settings: Ditching 14,3,3 for High-Frequency Precision

Post by FTtrader »

To upgrade this to a Professional-Grade Algorithmic System, we need to move beyond simple crossovers and add the institutional infrastructure that actual quantitative traders use to protect capital and maximize expectancy on the 1-minute chart.

Here is the "Pro" Pine Script v5 version. I have added four major institutional upgrades:

Dynamic Risk Management: Instead of fixed lots, it sizes positions automatically based on a % Risk per Trade relative to your dynamic account equity.

Session "Kill Zones": M1 strategies get destroyed in low-liquidity environments. The script now includes a time-filter to only trade during peak institutional volume (e.g., London/New York overlap).

Volatility Filter (ATR): It calculates the Average True Range. If the market is completely flat (volatility drops below a threshold), it blocks entries to prevent spread-bleed.

Advanced Trade Management: Added Trailing Stops to secure profits on runners, replacing the rigid static Take Profit limits.

HUD Dashboard: A real-time visual table on your chart showing current trend bias, session status, and market volatility.
FTtrader
Posts: 309
Joined: Mon Aug 03, 2026 2:43 pm

Re: Optimal 1-Minute Stochastic Settings: Ditching 14,3,3 for High-Frequency Precision

Post by FTtrader »

The PRO Pine Script (v5)

Copy and paste this into your TradingView Pine Editor:

Code: Select all

//@version=5
strategy("Institutional M1 Scalper PRO", shorttitle="M1 Stoch PRO", overlay=true, calc_on_every_tick=false, initial_capital=10000, commission_type=strategy.commission.cash_per_order, commission_value=3)

// =========================================================================
// 1. INPUT PARAMETERS & GROUPS
// =========================================================================
grp_stoch = "--- 1. Stochastic Engine ---"
k_len   = input.int(5, title="%K Period", group=grp_stoch)
d_len   = input.int(3, title="%D Period", group=grp_stoch)
smooth  = input.int(3, title="Slowing", group=grp_stoch)
ob      = input.float(80, title="Overbought Level", group=grp_stoch)
os      = input.float(20, title="Oversold Level", group=grp_stoch)

grp_trend = "--- 2. Market Filters ---"
ema_len   = input.int(50, title="Trend Filter (EMA)", group=grp_trend)
atr_len   = input.int(14, title="ATR Period", group=grp_trend)
atr_min   = input.float(1.5, title="Min Volatility (Pips)", group=grp_trend, tooltip="Minimum ATR required to trade. Filters out flat/dead markets.")

grp_session = "--- 3. Institutional Kill Zones ---"
use_sess = input.bool(true, title="Use Session Times?", group=grp_session)
sess_rng = input.session("0800-1130", title="Trading Session (EST)", group=grp_session, tooltip="Default: NY Morning Session. M1 strategies require high liquidity.")
sess_tz  = input.string("America/New_York", title="Time Zone", group=grp_session)

grp_risk = "--- 4. Risk & Trade Management ---"
risk_pct = input.float(1.0, title="Risk Per Trade (%)", group=grp_risk, step=0.1, tooltip="Auto-sizes lots so you only lose this % of equity on a Stop Loss.")
sl_pips  = input.float(4.0, title="Stop Loss (Pips)", group=grp_risk)
use_trail = input.bool(true, title="Use Trailing Stop?", group=grp_risk)
tp_pips  = input.float(10.0, title="Take Profit (Pips) [If Trail is False]", group=grp_risk)
trail_act = input.float(3.0, title="Trail Activation (Pips)", group=grp_risk, tooltip="How many pips in profit before Trailing Stop engages.")
trail_off = input.float(1.5, title="Trail Offset (Pips)", group=grp_risk, tooltip="Distance to trail behind price once activated.")

// Normalize pip values for Forex vs Crypto/Indices
is_forex = syminfo.type == "forex"
pip_mult = is_forex ? syminfo.mintick * 10 : syminfo.mintick

// =========================================================================
// 2. INDICATORS & LOGIC
// =========================================================================
// Session Filter
in_session = use_sess ? not na(time(timeframe.period, sess_rng, sess_tz)) : true
bgcolor(in_session ? color.new(color.blue, 95) : na, title="Session Background")

// Trend & Volatility
ema_val = ta.ema(close, ema_len)
atr_val = ta.atr(atr_len) / pip_mult
is_volatile = atr_val >= atr_min

plot(ema_val, color=color.new(color.white, 0), title="Institutional EMA", linewidth=2)

// Stochastic Math
raw_k = ta.stoch(close, high, low, k_len)
k_line = ta.sma(raw_k, smooth)
d_line = ta.sma(k_line, d_len)

// Conditions
is_uptrend   = close > ema_val
is_downtrend = close < ema_val

was_os = k_line[1] < os and d_line[1] < os
was_ob = k_line[1] > ob and d_line[1] > ob

bull_cross = ta.crossover(k_line, d_line)
bear_cross = ta.crossunder(k_line, d_line)

// =========================================================================
// 3. DYNAMIC POSITION SIZING
// =========================================================================
// Formula: Risk Amount = Equity * (Risk%)
// Qty = Risk Amount / (SL Ticks * Point Value)
risk_amt = strategy.equity * (risk_pct / 100)
sl_ticks = sl_pips * (is_forex ? 10 : 1)
trade_qty = risk_amt / (sl_ticks * syminfo.mintick * syminfo.pointvalue)

// =========================================================================
// 4. EXECUTION
// =========================================================================
buy_cond  = in_session and is_volatile and is_uptrend and was_os and bull_cross
sell_cond = in_session and is_volatile and is_downtrend and was_ob and bear_cross

if buy_cond and strategy.position_size == 0
    strategy.entry("Long", strategy.long, qty=trade_qty)
    
if sell_cond and strategy.position_size == 0
    strategy.entry("Short", strategy.short, qty=trade_qty)

// Advanced Trade Management
sl_val = sl_pips * (is_forex ? 10 : 1)
tp_val = tp_pips * (is_forex ? 10 : 1)
trail_act_val = trail_act * (is_forex ? 10 : 1)
trail_off_val = trail_off * (is_forex ? 10 : 1)

if strategy.position_size > 0
    if use_trail
        strategy.exit("Trail Exit", "Long", stop=strategy.position_avg_price - (sl_val * syminfo.mintick), trail_points=trail_act_val, trail_offset=trail_off_val)
    else
        strategy.exit("TP/SL Exit", "Long", stop=strategy.position_avg_price - (sl_val * syminfo.mintick), limit=strategy.position_avg_price + (tp_val * syminfo.mintick))

if strategy.position_size < 0
    if use_trail
        strategy.exit("Trail Exit", "Short", stop=strategy.position_avg_price + (sl_val * syminfo.mintick), trail_points=trail_act_val, trail_offset=trail_off_val)
    else
        strategy.exit("TP/SL Exit", "Short", stop=strategy.position_avg_price + (sl_val * syminfo.mintick), limit=strategy.position_avg_price - (tp_val * syminfo.mintick))

// =========================================================================
// 5. HUD DASHBOARD
// =========================================================================
var table hud = table.new(position.top_right, 2, 4, border_width=1, border_color=color.gray, frame_width=1, frame_color=color.gray)

if barstate.islast
    table.cell(hud, 0, 0, "SYSTEM STATUS", bgcolor=color.new(color.black, 30), text_color=color.white)
    table.cell(hud, 1, 0, "VALUE", bgcolor=color.new(color.black, 30), text_color=color.white)
    
    table.cell(hud, 0, 1, "Session Active", bgcolor=color.new(color.black, 80), text_color=color.white)
    table.cell(hud, 1, 1, in_session ? "YES" : "NO", bgcolor=in_session ? color.new(color.green, 70) : color.new(color.red, 70), text_color=color.white)

    table.cell(hud, 0, 2, "Trend Bias", bgcolor=color.new(color.black, 80), text_color=color.white)
    table.cell(hud, 1, 2, is_uptrend ? "LONG" : is_downtrend ? "SHORT" : "FLAT", bgcolor=is_uptrend ? color.new(color.green, 70) : color.new(color.red, 70), text_color=color.white)

    table.cell(hud, 0, 3, "Volatility (ATR)", bgcolor=color.new(color.black, 80), text_color=color.white)
    table.cell(hud, 1, 3, is_volatile ? "HIGH" : "LOW", bgcolor=is_volatile ? color.new(color.green, 70) : color.new(color.red, 70), text_color=color.white)
FTtrader
Posts: 309
Joined: Mon Aug 03, 2026 2:43 pm

Re: Optimal 1-Minute Stochastic Settings: Ditching 14,3,3 for High-Frequency Precision

Post by FTtrader »

Pro Features Explained:

Dynamic Percent Sizing: You no longer enter 0.10 lots. You enter 1.0 (for 1%). The algorithm automatically looks at your account balance, measures the distance to your 4-pip Stop Loss, and calculates the exact fractional lot size needed so that if you are stopped out, you lose exactly 1% of your account.

Session Kill Zones (Highlighted Background): I set the default to 0800-1130 EST (The "New York Morning" session). This is when institutional order flow overlaps between London and NY, providing the liquidity needed for rapid M1 continuation. The chart background will highlight blue during active hours, and the bot will completely ignore setups outside of this window to prevent spread-bleed during the Asian drift.

Trailing Stop Activation: By default, I turned off a hard Take Profit and turned on the Trailing Stop. The logic is set so that once the trade is 3 pips in profit, a trailing stop is triggered 1.5 pips behind price. This means if the M1 momentum pushes in your favor, the stop trails up with it, ensuring you lock in a break-even trade early and capture the full run of the breakout.

Heads-Up Display (HUD): A real-time data table will appear in the top-right corner of your chart. It instantly tells you if the script currently views the market as long/short, if you are inside an active trading session, and if volatility is high enough to risk a trade.
Post Reply