
یہ حکمت عملی چلتی اوسط کے سنہری کراس اصول پر مبنی ہے۔ خاص طور پر ، یہ دو مختلف دورانیوں کی سادہ چلتی اوسط کا استعمال کرتا ہے ، یعنی 50 کی لائن اور 200 کی لائن۔ جب 50 کی لائن نیچے سے 200 کی لائن کو توڑتی ہے تو ، خریدنے کا اشارہ ہوتا ہے۔ جب 50 کی لائن اوپر سے 200 کی لائن کو توڑتی ہے تو ، فروخت کا اشارہ ہوتا ہے۔
یہ حکمت عملی پائن اسکرپٹ میں لکھی گئی ہے۔ اس کی بنیادی منطق یہ ہے:
یہاں SMA اشارے کا استعمال کرنے کی اہمیت یہ ہے کہ یہ مارکیٹ کے اعداد و شمار کے شور کو مؤثر طریقے سے ختم کرسکتا ہے۔ طویل مدتی رجحانات پر قبضہ کریں۔ تیز رفتار SMA لائنوں میں سست رفتار SMA لائنوں کو عبور کرنا ، جس سے یہ ظاہر ہوتا ہے کہ قلیل مدتی عروج نے طویل مدتی نزولی رجحان کو شکست دی ہے۔
اس حکمت عملی کے درج ذیل فوائد ہیں:
اس حکمت عملی کے کچھ خطرات بھی ہیں:
ممکنہ طور پر جعلی بریک ہوسکتی ہے ، جس سے حکمت عملی میں غلط سگنل پیدا ہوتا ہے۔ جعلی بریک کی امکان کو کم کرنے کے لئے دونوں ایس ایم اے پیرامیٹرز کو مناسب طریقے سے ایڈجسٹ کیا جاسکتا ہے۔
مختصر مدت کی مارکیٹوں کا جواب دینے کے قابل نہیں ، صرف طویل مدتی سرمایہ کاروں کے لئے موزوں ہے۔ تیز رفتار SMA کی مدت کو مناسب طریقے سے کم کیا جاسکتا ہے۔
واپسی بڑی ہوسکتی ہے۔ اسٹاپ نقصان کا مقام مقرر کیا جاسکتا ہے ، یا پوزیشن مینجمنٹ کو مناسب طریقے سے ایڈجسٹ کیا جاسکتا ہے۔
اس حکمت عملی کو مندرجہ ذیل پہلوؤں سے بہتر بنایا جاسکتا ہے:
دوسرے اشارے کو فلٹر کریں ، متعدد خرید / فروخت کی شرائط کو جوڑیں ، اور جعلی سگنل کے امکانات کو کم کریں۔
جب قیمت کسی خاص سطح سے نیچے آجائے تو روکنے کا طریقہ کار بڑھانا۔
پوزیشن مینجمنٹ کو بہتر بنائیں۔ مثال کے طور پر رجحان کے ساتھ پوزیشن میں اضافہ ، نقصانات کو روکنا وغیرہ۔ واپسی کو کنٹرول کریں اور زیادہ سے زیادہ منافع حاصل کریں۔
پیرامیٹرز کو بہتر بنائیں۔ منافع کے خطرے کے تناسب پر مختلف پیرامیٹرز کے اثرات کا اندازہ لگائیں۔
یہ حکمت عملی مجموعی طور پر ایک ٹرینڈ ٹریکنگ حکمت عملی ہے۔ یہ ایس ایم اے کے فوائد کا استعمال کرتی ہے ، آسانی سے اور موثر طریقے سے طویل لائن کے رجحانات کو پکڑتی ہے۔ آپ اپنے انداز اور پیرامیٹرز کے مطابق ایڈجسٹ کرنے کی جگہ کو اپنی مرضی کے مطابق بنا سکتے ہیں۔ اس کے ساتھ ہی کچھ موجودہ خامیوں پر بھی توجہ دینے کی ضرورت ہے ، تاکہ مزید اصلاح اور بہتری کی جاسکے۔
/*backtest
start: 2023-12-26 00:00:00
end: 2024-01-02 00:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// @version=4
//
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// www.tradingview.com/u/TradeFab/
// www.tradefab.com
// ___ __ __ __ __ __
// | |__) /\ | \ |__ |__ /\ |__)
// | | \ /~~\ |__/ |__ | /~~\ |__)
//
// DISCLAIMER: Futures, stocks and options trading involves substantial risk of loss
// and is not suitable for every investor. You are responsible for all the risks and
// financial resources you use and for the chosen trading system.
// Past performance is not indicative for future results. In making an investment decision,
// traders must rely on their own examination of the entity making the trading decisions!
//
// TradeFab's Golden Cross Strategy.
// The strategy goes long when the faster SMA 50 (the simple moving average of the last 50 bars) crosses
// above the SMA 200. Orders are closed when the SMA 50 crosses below SMA 200. The strategy does not short.
//
VERSION = "1.2"
// 1.2 FB 2020-02-09 converted to Pine version 4
// 1.1 FB 2017-01-15 added short trading
// 1.0 FB 2017-01-13 basic version using SMAs
//
strategy(
title = "TFs Golden Cross " + VERSION,
shorttitle = "TFs Golden Cross " + VERSION,
overlay = true
)
///////////////////////////////////////////////////////////
// === INPUTS ===
///////////////////////////////////////////////////////////
inFastSmaPeriod = input(title="Fast SMA Period", type=input.integer, defval=50, minval=1)
inSlowSmaPeriod = input(title="Slow SMA Period", type=input.integer, defval=200, minval=1)
// backtest period
testStartYear = input(title="Backtest Start Year", type=input.integer, defval=2019, minval=2000)
testStartMonth = input(title="Backtest Start Month", type=input.integer, defval=1, minval=1, maxval=12)
testStartDay = input(title="Backtest Start Day", type=input.integer, defval=1, minval=1, maxval=31)
testStopYear = input(title="Backtest Stop Year", type=input.integer, defval=2099, minval=2000)
testStopMonth = input(title="Backtest Stop Month", type=input.integer, defval=12, minval=1, maxval=12)
testStopDay = input(title="Backtest Stop Day", type=input.integer, defval=31, minval=1, maxval=31)
///////////////////////////////////////////////////////////
// === LOGIC ===
///////////////////////////////////////////////////////////
smaFast = sma(close, inFastSmaPeriod)
smaSlow = sma(close, inSlowSmaPeriod)
bullishCross = crossover (smaFast, smaSlow)
bearishCross = crossunder(smaFast, smaSlow)
// detect valid backtest period
isTestPeriod() => true
///////////////////////////////////////////////////////////
// === POSITION EXECUTION ===
///////////////////////////////////////////////////////////
strategy.entry("long", strategy.long, when=bullishCross)
strategy.entry("short", strategy.short, when=bearishCross)
///////////////////////////////////////////////////////////
// === PLOTTING ===
///////////////////////////////////////////////////////////
// background color
nopColor = color.new(color.gray, 50)
bgcolor(not isTestPeriod() ? nopColor : na)
bartrendcolor =
close > smaFast and
close > smaSlow and
change(smaSlow) > 0
? color.green
: close < smaFast and
close < smaSlow and
change(smaSlow) < 0
? color.red
: color.blue
barcolor(bartrendcolor)
plot(smaFast, color=change(smaFast) > 0 ? color.green : color.red, linewidth=2)
plot(smaSlow, color=change(smaSlow) > 0 ? color.green : color.red, linewidth=2)
// label
posColor = color.new(color.green, 75)
negColor = color.new(color.red, 75)
dftColor = color.new(color.blue, 75)
posProfit= (strategy.position_size != 0) ? (close * 100 / strategy.position_avg_price - 100) : 0.0
posDir = (strategy.position_size > 0) ? "long" : strategy.position_size < 0 ? "short" : "flat"
posCol = (posProfit > 0) ? posColor : (posProfit < 0) ? negColor : dftColor
var label lb = na
label.delete(lb)
lb := label.new(bar_index, max(high, highest(5)[1]),
color=posCol,
text="Pos: "+ posDir +
"\nPnL: "+tostring(posProfit, "#.##")+"%" +
"\nClose: "+tostring(close, "#.##"))