
यह रणनीति सरल चलती औसत और कुछ गणितीय गणनाओं का उपयोग करके खरीद/बिक्री बिंदुओं को निर्धारित करती है। हम 100 दिन के SMA को एक बेंचमार्क के रूप में उपयोग करते हैं। यदि समापन मूल्य उस रेखा से नीचे है, तो हम उस स्थिति को खोलने के लिए चुनते हैं जो उस रेखा से नीचे है, और यह मूल्य (<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
इस रणनीति में तीन SMA लाइनों का उपयोग किया जाता हैः फास्ट लाइन (डिफ़ॉल्ट 14 दिन), स्लो लाइन (डिफ़ॉल्ट 100 दिन) और रेफरेंस लाइन (डिफ़ॉल्ट 30 दिन) ।
जब समापन मूल्य संदर्भ रेखा से नीचे होता है और धीमी रेखा के सापेक्ष कम विचलन विन्यास की तुलना में अधिक होता है, और तेज रेखा ऊपर जाती है और धीमी रेखा नीचे जाती है, तो मल्टीहेड में प्रवेश करती है। जब इन शर्तों को पूरा किया जाता है, तो तेज और धीमी रेखाओं के पार होने की संभावना होती है, इसलिए एक अच्छा प्रवेश बिंदु होता है।
जब समापन मूल्य संदर्भ रेखा से अधिक है, और धीमी रेखा के सापेक्ष उच्च विचलन विन्यास के उच्च विचलन से अधिक है, और समापन मूल्य लगातार 3 K लाइनों पर बढ़ गया है, लाभप्रदता प्राप्त की गई है, और तेज रेखा धीमी रेखा से अधिक है, तो एक और स्थिति को बंद करें। यदि कीमतें जारी रहती हैं, तो स्टॉप लॉस को ट्रैक करना शुरू कर दिया जाएगा।
प्रत्येक ट्रेड पर पोजीशन एक निश्चित अनुपात के आधार पर प्रवेश करती है, इस तरह से स्थिति को नियंत्रित करती है।
अनुकूलन के लिए उपाय:
एसएमए अस्थिरता विचलन ट्रेडिंग रणनीति विभिन्न एसएमए औसत के संदर्भ में विचलन सेट करके, सबसे अच्छा प्रवेश समय खोजने के लिए। साथ ही, बाहर निकलने के तंत्र ने लाभ को लॉक करने के लिए स्टॉपलॉस को ट्रैक करने के लिए सेट किया है। यह रणनीति सरल है और इसे लागू करना आसान है। एसएमए पैरामीटर, विचलन सेटिंग और स्टॉपलॉस समता को अनुकूलित करके बेहतर प्रभाव प्राप्त किया जा सकता है। यह रणनीति मध्यम और लंबी अवधि के लिए उपयुक्त है।
/*backtest
start: 2022-12-12 00:00:00
end: 2023-12-18 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// @version=4
// Author: Sonny Parlin (highschool dropout)
strategy(shorttitle="SMA+Strategy", title="SMA Offset Strategy",
overlay=true, currency=currency.USD,
initial_capital=10000)
// Inputs and variables
ss = input(14, minval=10, maxval=50, title="SMA Fast (days)")
ff = input(100, minval=55, maxval=200, title="SMA Slow (days)")
ref = input(30, minval=20, maxval=50, title="SMA Reference (days)")
lowOffset = input(0.001, "Low Offset (%)", minval=0, step=0.001)
highOffset = input(0.0164, "High Offset (%)", minval=0, step=0.0001)
orderStake = input(0.96, "Order Stake (%)", minval=0, step=0.01)
// SMA
smaFast = sma(close, ss)
smaSlow = sma(close, ff)
smaRef = sma(close, ref)
distanceLow = (close - smaSlow) / close
distanceHigh = (close - smaSlow) / close
// Set up SMA plot but don't show by default
plot(smaFast, "smaFast", color=#00ff00, display = 0)
plot(smaSlow, "smaSlow", color=#ff0000, display = 0)
plot(smaRef, "smaRef", color=#ffffff, display = 0)
// The buy stratey:
// guard that the low is under our sma low reference line by our lowOffset %,
// default is 0.001. (low < smaRef) and (distanceLow > lowOffset)
// SMA fast is on the rise and SMA slow is falling and they are very likely
// to cross. (rising(smaFast,1)) and (falling(smaSlow, 1))
enterLong = (low < smaRef) and (distanceLow > lowOffset) and (rising(smaFast,1)) and (falling(smaSlow, 1))
// The sell Strategy:
// Guard that close is higher than our sma high reference line by our
// highOffset %, default is 0.0164. (close > smaRef) and (distanceHigh > highOffset)
// Guard that close has risen by 3 candles in a row (rising(close,3))
// Guard that we currently have profit (strategy.openprofit > 0)
// Guard that SMA fast is higher than smaSlow (smaFast > smaSlow)
// If it keeps going up past our close position the trailing stoploss will kick in!
enterShort = (close > smaRef) and (distanceHigh > highOffset) and (rising(close,3)) and (strategy.openprofit > 0) and (smaFast > smaSlow)
// Order size is based on total equity
// Example 1:
// startingEquity = 2000
// close = 47434.93
// orderStake = 0.45
// (2,000 × orderStake) / close = orderSize = 0.0189733599 = approx $900
// Example 2:
// startingEquity = 2000
// close = 1.272
// orderStake = 0.45
// (startingEquity × orderStake) / close = orderSize = 707.5471698113 = approx $900
orderSize = (strategy.equity * orderStake) / close
// Trailing Stoploss
// I'm using 1.35 as my default value, play with this for different results.
longTrailPerc = input(title="Trailing Stoploss (%)",
type=input.float, minval=0.0, step=0.1, defval=1.35) * 0.01
longStopPrice = 0.0
longStopPrice := if (strategy.position_size > 0)
stopValue = close * (1 - longTrailPerc)
max(stopValue, longStopPrice[1])
else
0
if (enterLong)
strategy.entry("Open Long Position", strategy.long, orderSize, when=strategy.position_size <= 0)
if (enterShort)
strategy.exit(id="Close Long Position", stop=longStopPrice)
//plot(strategy.equity)