Skip to main content

trading view pine script ( BTCUSDT 10 MIN REAL TIME DIRECTION INDICATOR SET ON TRADING VIEW FIRST STRATEGY)

//@version=5 strategy("BTCUSDT 10m Real-Time Direction (live forming 10m) - Fixed", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=1, initial_capital=10000) // ---------- INPUTS ---------- aggTF = input.timeframe("10", "Aggregation TF (minutes)") // keep "10" for 10-min useShorts = input.bool(true, "Enable Shorts") tpPct = input.float(0.25, "TP % (0.25 = 0.25%)", step=0.01) volMult = input.float(1.5, "Volume spike multiplier") momPeriod = input.int(5, "Momentum period") rsiLen = input.int(14, "RSI length") stochLen = input.int(14, "Stoch-RSI window") // ---------- REQUEST SECURITY (REAL-TIME FORMING HIGHER-TF) ---------- // Use named args for request.security options to get forming higher-TF bar gaps_mode = barmerge.gaps_off lookahead_mode = barmerge.lookahead_on // request aggregated series (open, high, low, close, volume) from aggTF as they form [o, h, l, c, v] = request.security(syminfo.tickerid, aggTF, [open, high, low, close, volume], gaps = gaps_mode, lookahead = lookahead_mode) // ---------- INDICATORS (ON AGGREGATED REAL-TIME 10m) ---------- ema5 = ta.ema(c, 5) ema20 = ta.ema(c, 20) rsiV = ta.rsi(c, rsiLen) // StochRSI on aggregated closes rsi_low = ta.lowest(rsiV, stochLen) rsi_high = ta.highest(rsiV, stochLen) stochRSI = (rsi_high - rsi_low) == 0 ? 0.0 : (rsiV - rsi_low) / (rsi_high - rsi_low) // Parabolic SAR on aggregated series via request.security (returning scalar) psar_v = request.security(syminfo.tickerid, aggTF, ta.sar(0.02, 0.02, 0.2), gaps = gaps_mode, lookahead = lookahead_mode) psar_dir = c > psar_v // VWAP: session VWAP on aggTF vwap_agg = request.security(syminfo.tickerid, aggTF, ta.vwap, gaps = gaps_mode, lookahead = lookahead_mode) // Momentum & Volume spike on aggregated series mom = c - nz(c[momPeriod], c) vol_avg = request.security(syminfo.tickerid, aggTF, ta.sma(volume, 10), gaps = gaps_mode, lookahead = lookahead_mode) vol_spike = v > vol_avg * volMult // ---------- SIGNAL LOGIC (same vote system) ---------- emaS = ema5 > ema20 ? 1 : -1 rsiS = rsiV > 55 ? 1 : (rsiV < 45 ? -1 : 0) stS = stochRSI > 0.8 ? -1 : (stochRSI < 0.2 ? 1 : 0) psS = psar_dir ? 1 : -1 vwS = c > vwap_agg ? 1 : -1 moS = mom > 0 ? 1 : -1 buyCount = (emaS>0 ? 1 : 0) + (rsiS>0 ? 1 : 0) + (stS>0 ? 1 : 0) + (psS>0 ? 1 : 0) + (vwS>0 ? 1 : 0) + (moS>0 ? 1 : 0) sellCount = (emaS<0 ? 1 : 0) + (rsiS<0 ? 1 : 0) + (stS<0 ? 1 : 0) + (psS<0 ? 1 : 0) + (vwS<0 ? 1 : 0) + (moS<0 ? 1 : 0) conf = math.round(100 * math.max(buyCount, sellCount) / 6.0) signal = buyCount >= 3 ? "BUY" : (sellCount >= 3 ? "SELL" : "NEUTRAL") targetPrice = signal == "BUY" ? c * (1 + tpPct/100.0) : (signal == "SELL" ? c * (1 - tpPct/100.0) : na) // ---------- PLOTS ---------- plotc = request.security(syminfo.tickerid, aggTF, close, gaps = gaps_mode, lookahead = lookahead_mode) // aggregated closing series for plotting plot(plotc, title="10m Close (forming)", linewidth=2) plot(targetPrice, title="Predicted Target", style=plot.style_line, linewidth=2) plot(ema5, title="EMA5", linewidth=1) plot(ema20, title="EMA20", linewidth=1) plot(vwap_agg, title="VWAP (agg session)", linewidth=1) // arrows for live signals (these mark based on forming agg bar) plotshape(signal=="BUY", title="Buy Arrow", style=shape.labelup, location=location.belowbar, text="BUY", textcolor=color.white, size=size.tiny) plotshape(signal=="SELL", title="Sell Arrow", style=shape.labeldown, location=location.abovebar, text="SELL", textcolor=color.white, size=size.tiny) // chart info var table info = table.new(position.top_right, 1, 5, border_width=1) if barstate.islast table.cell(info, 0, 0, "Signal: " + signal + " (" + str.tostring(conf) + "%)", text_size=size.small) table.cell(info, 0, 1, "Votes B/S: " + str.tostring(buyCount) + "/" + str.tostring(sellCount), text_size=size.small) table.cell(info, 0, 2, "10m Close: " + str.tostring(c, format.mintick), text_size=size.small) table.cell(info, 0, 3, "VWAP(agg): " + str.tostring(vwap_agg, format.mintick), text_size=size.small) table.cell(info, 0, 4, "Vol Spike: " + (vol_spike ? "YES" : "NO"), text_size=size.small) // ---------- STRATEGY (paper trade) ---------- longId = "LONG" shortId = "SHORT" if (signal == "BUY") if strategy.position_size == 0 strategy.entry(longId, strategy.long) strategy.exit("TP Long", from_entry=longId, limit=targetPrice) else if (signal == "SELL") if useShorts and strategy.position_size == 0 strategy.entry(shortId, strategy.short) strategy.exit("TP Short", from_entry=shortId, limit=targetPrice) else if strategy.position_size != 0 strategy.close_all(comment="Neutral close")

Comments

Popular posts from this blog

K

# app.py from flask import Flask, jsonify import numpy as np import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import LSTM, Dense import requests app = Flask(__name__) # Binance se last 60 minute price data fetch karna def fetch_binance_data(): url = "https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1m&limit=60" data = requests.get(url).json() closes = [float(item[4]) for item in data] return closes # LSTM input prepare karna sliding window ke form me def prepare_data(series, n_steps): X, y = [], [] for i in range(len(series) - n_steps): X.append(series[i:i+n_steps]) y.append(series[i+n_steps]) return np.array(X), np.array(y) # LSTM model train karna def train_model(series): n_steps = 10 X, y = prepare_data(series, n_steps) X = X.reshape((X.shape[0], X.shape[1], 1)) model = Sequential([ LSTM(50, activation='relu', input_shape=...

90% logic

Bahut solid point uthaya tune 🔥 — ye hi **core secret** hai market ka: *order book + synthetic interval + liquidity behavior* ka connection. Chalo ye ekdum **clear aur depth se** samajhte hain — “kyun candle ke andar jo price bhara hota hai wo sabse satik signal deta hai” aur “synthetic 10-min next direction ko kaise predict karta hai.” --- ## 🔹 1. Candle ke andar kya hota hai — “Order book ka sach” Ek 1-min ya 10-min candle sirf ek visual summary hoti hai: * **Open** = pehle trade ka price * **Close** = last trade ka price * **High/Low** = us interval me sabse bada aur chhota executed trade Lekin asal me, is candle ke **andar har second**, **order book** me kuch chije chal rahi hoti hain: * **Bid wall** (buyers ka volume cluster) * **Ask wall** (sellers ka volume cluster) * **Spoof orders** (fake liquidity — direction manipulate karne ke liye) * **Absorption** (jab ek side ke large orders absorb ho rahe hote hain) Ye sab data Binance ke order book (Level 2 feed) me hota hai —...

13A 10 m future pine script good working

//@version=5 indicator("10m Predictor Complete", overlay=true) // GET 10m DATA c10 = request.security(syminfo.tickerid, "10", close) h10 = request.security(syminfo.tickerid, "10", high) l10 = request.security(syminfo.tickerid, "10", low) atr10 = request.security(syminfo.tickerid, "10", ta.atr(14)) rsi10 = request.security(syminfo.tickerid, "10", ta.rsi(close, 14)) [macdLine, signalLine, histLine] = request.security(syminfo.tickerid, "10", ta.macd(close, 12, 26, 9)) stochK = request.security(syminfo.tickerid, "10", ta.stoch(close, high, low, 14)) // PREDICTIONS slope = ta.change(c10, 3) / 3 pred_close = c10 + slope pred_high = pred_close + atr10 pred_low = pred_close - atr10 // WEIGHTED SCORE rsiScore = rsi10 > 70 ? 2 : rsi10 > 50 ? 1 : rsi10 signalLine ? 2 : -2 stochScore = stochK > 80 ? 2 : stochK > 50 ? 1 : stochK 40 isBearish = weightedScore 50 ? "HIGH" : "LOW" macdS...