ایم ایل انتباہات کا نمونہ

مصنف:چاؤ ژانگ، تاریخ: 2022-05-17 10:48:20
ٹیگز:ای ایم اےاے ٹی آرایس ایم اے

میں نے یہ اشارے / مطالعہ اسکرپٹ پیدا کیا کیونکہ میں اس مسئلے میں چلا گیا کہ ایک ہی الرٹ کئی بار فائر کرے گا۔ مثال کے طور پر یہ ایک طویل سگنل کو متحرک کرے گا جب پہلے ہی طویل عرصے میں ہو۔ مجھے لگتا ہے کہ ایک بہت ہی بنیادی حکمت عملی کے ساتھ کوئی مسئلہ نہیں ہوگا لیکن ایک بڑی اسکرپٹ اور بہت سے متغیرات کے ساتھ ، ایسا لگتا ہے کہ پیچیدگیاں پیدا ہوتی ہیں۔

یہ ٹریڈنگ لائن آسکیلیٹر کے ذریعہ حل کیا جاتا ہے اور جب ہی یہ ایک نئی اور سابقہ سے مختلف پوزیشن میں سوئچ کرتا ہے تو ، یہ ایک الرٹ کو متحرک کرے گا۔

اگر آپ لانگ میں ہیں اور یہ ایک بار پھر لانگ کا اشارہ کرتا ہے تو ، پھر اس کو الرٹ کی ترتیبات میں Continuation Long کے طور پر دیکھا جاتا ہے۔ آپ اپنی موجودہ پوزیشن (اختیاری) میں شامل کرنے کے لئے اس شرط کا استعمال کرسکتے ہیں۔ تسلسل کے اشارے روشن سبز / سرخ نقطوں کے طور پر دکھائے جاتے ہیں۔

آپ دیکھیں گے کہ Trade Shorts اور Trade Exits سگنلز کو غیر چیک کرنے کا آپشن موجود ہے۔ فرض کریں کہ آپ شارٹ اور ایگزٹ کی تجارت نہ کرنے کا انتخاب کرتے ہیں، پھر آپ کا لانگ صرف ایک بار ہی ایگزٹ کرے گا جب شارٹ سگنل کا پتہ چل جائے گا۔ یہ بیک ٹیسٹنگ کے مقاصد کے لئے مفید ثابت ہوسکتا ہے.

یہ فوری مثال اسکرپٹ EMA 10، EMA 200، emaPlus1Atr اور emaMinus1Atr استعمال کرتا ہے.

آپ کے اسکرپٹ میں استعمال کرنے کے لئے، آپ کو باکس میں اپنے BUY / SELL / EXIT سگنل کو تبدیل کرنے اور شامل کرنے کی ضرورت ہوگی جہاں یہ کہتا ہے:

//// اپنی خرید/فروخت/خرید کے سگنل یہاں درج کریں: ////

//////////////////////////////////////////////////

امید ہے کہ کسی کو یہ مفید ملے گا، یا صرف آپ کی اپنی تجارتی حکمت عملی اور اسکرپٹ کے لئے ایک اضافی بصری تصدیق کے طور پر.

بیک ٹسٹنگ

img


/*backtest
start: 2022-04-16 00:00:00
end: 2022-05-15 23:59:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zombie76

//@version=5
indicator("ML Alerts Template [indicator]", shorttitle = "ML Alerts Template [indicator]", overlay=false)






/////////////////////////////////////////////////////////////////////////
tradeshorts = input(title='- *Trade Shorts* - ', defval=true)
tradeexitsignals = input(title='- *Trade Exits* -', defval=true)
/////////////////////////////////////////////////////////////////////////

src = (close)
source = (close)

///////////////////// EMA's ////////////////////////
p10=input(title="EMA 1",defval=10)
p200=input(title="EMA 2",defval=200)

ema10=ta.ema(close,p10)
ema200=ta.ema(close,p200)
////////////////////////////////////////////////////






//************* ATR ***************//
lengthatr = input(12, title="ATR Length") 

atr = ta.rma(ta.tr(true), lengthatr)
ema = ta.ema(close, lengthatr)

emaPlus1Atr = ema + atr
emaMinus1Atr = ema - atr

//************ END ATR ***********//






////////////////////////////// HIST ///////////////////////////////////

fastLengthHist = input(title='Hist Fast Length',defval=12)
slowLengthHist=input(title='Hist Slow Length',defval=26)
signalLength=input(title='Hist Signal Length',defval=9)

fastMA = ta.ema(source, fastLengthHist)
slowMA = ta.ema(source, slowLengthHist)

macd = fastMA - slowMA
signal = ta.sma(macd, signalLength)
hist = macd - signal

///////////////////////////////////////////////////////////////////












//////////////////////////////////////////////////
//// INPUT YOUR  BUY/SELL/EXIT  SIGNALS HERE: ////
//////////////////////////////////////////////////

tradeups = ema10 > ema10[1] and low > emaMinus1Atr and hist > hist[1] // LONG
tradeexits = tradeexitsignals and (ema10 < ema10[1]) and not tradeups // Exit Long
tradedowns = ((ema10 < ema10[1] and hist < hist[1]) or (high > emaPlus1Atr and close < emaPlus1Atr and close < open and hist < hist[1])) and not tradeups // SHORT
exitshort = low < emaMinus1Atr and close > open and ema10 > ema10[1] and hist > hist[1] // Exit Short

//////////////////////////////////////////////////
//////////////////////////////////////////////////

















///////////////////////////////// Buy Sell Line ///////////////////////////////////////////
////////////////////////// DO NOT EDIT ANYTHING BELOW /////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////

// Filters out signals if opposite signal is also on:
heikDownColor() => tradedowns
heikUpColor() => tradeups
heikExitColor() => tradeexitsignals and tradeexits

previnashort = 0
previnalong = 0
previnaexit = 0

// Heiki Down Filter //    
//short//
inashort_filt = heikDownColor() and tradeshorts and not heikUpColor()
previnashort := inashort_filt ? 1 : heikUpColor() ? -1 : previnashort[1]
inashort2 = previnashort[1] == 1

// Heiki Up Filter //
//long// 
inalong_filt = heikUpColor() and not (heikDownColor() or tradeexits)
previnalong := inalong_filt ? 1 : heikDownColor() ? -1 : previnalong[1]
inalong2 = previnalong[1] == 1

// Heiki Exit Filter //
//exit//
inaexit_filt = heikExitColor() and not heikDownColor() and not (heikUpColor() or tradeups)
previnaexit := inaexit_filt ? 1 : heikDownColor() or heikUpColor() ? -1 : previnaexit[1]
inaexit2 = previnaexit[1] == 1

// Heiki Exit Filter 2 //
//exit short//
previnasexits = 0
inasexits_filt = exitshort and (inashort2 or tradedowns) and not tradeups //and not tradedowns[1]
previnasexits := inasexits_filt ? 1 : heikDownColor() or heikUpColor() ? -1 : previnasexits[1]
inasexit2 = previnasexits[1] == 1 //and not exitshort[1]

/////////////////////////////////////////////////////// 

 
heikDownColor_filt = (heikDownColor() and not heikUpColor()) or (heikDownColor() and not heikExitColor())
heikUpColor_filt = tradeups or ((heikUpColor() or inalong2) and not (tradeexits or tradedowns or (inaexit2 and not tradeups)))
heikExitColor_filt = heikExitColor() and not (heikDownColor_filt or tradeups)
heikNeuColor_filt = (heikUpColor() or heikDownColor() or tradeups)

prev5 = 0
prev5 := (heikUpColor_filt and (not (tradedowns or tradeexits))) or tradeups ? 1000 : (tradeshorts and tradedowns) or not (inashort2 and (exitshort or inasexit2)) and (tradeshorts and (inashort2 or heikDownColor_filt)) ? -1000 : not (tradeups or heikUpColor_filt) and (((not tradeshorts and (heikExitColor_filt)) or (inashort2 and exitshort) or (tradeshorts and tradeexits and heikUpColor_filt and not (heikDownColor_filt)) or (tradeshorts and tradeexits and not heikDownColor_filt and not heikUpColor_filt))) ? 0 : prev5[0]

plot(prev5, color=color.new(color.aqua, 10), style=plot.style_stepline, title='Trade Line')

shortdata2 = prev5[0] == -1000 and (heikDownColor_filt or inashort2) //and heikNeuColor_filt
longdata2 = prev5[0] == 1000 and (heikUpColor_filt or not (heikExitColor_filt or heikDownColor_filt))
exitdata2 = prev5[0] == 0 and not (heikNeuColor_filt or heikDownColor_filt)
////////////////////// END Buy Sell Line ///////////////////////////////////





/////////////////////////////////// Plot Dots //////////////////////////////
plotshape(longdata2 and not tradeexits, style=shape.diamond, location=location.bottom, color=color.new(color.lime, 50)) //LONG
plotshape(shortdata2 and tradeshorts, style=shape.diamond, location=location.bottom, color=color.new(color.red, 50)) // SHORT
plotshape(exitdata2 and not (tradeups or heikUpColor_filt), style=shape.diamond, location=location.bottom, color=color.new(color.purple, 50)) // EXIT

plotshape(tradeups and not tradeups[1], style=shape.diamond, location=location.bottom, color=color.new(color.lime, 0)) //LONG
plotshape(tradedowns and tradeshorts and not tradedowns[1], style=shape.diamond, location=location.bottom, color=color.new(color.red, 0)) // SHORT
plotshape(prev5[0] == 0 and (prev5[1] > 0 or prev5[1] < 0) and not (tradeups or heikUpColor_filt), style=shape.diamond, location=location.bottom, color=color.new(color.white, 70))
////////////////////////////////////////////////////////////////////////////

/////////////////////////////////

GoLong = prev5[0] > 0 and prev5[1] < 900
GoShort = prev5[0] < 0 and prev5[1] > -900
GoExit = prev5[0] == 0 and (prev5[1] > 0 or prev5[1] < 0)

///////////// Alerts ////////////////

alertcondition(condition=GoLong,
     title="1_Warp LONG",
     message="LONG *")
     
     
alertcondition(condition=GoShort and tradeshorts,
     title="2_Warp SHORT",
     message="SHORT *")

   
alertcondition(condition=GoExit,
     title="3_EXIT Warp",
     message="EXIT *")   




////// Alerts Add to Position ////// 
alertcondition(condition=tradeups and not exitdata2[1] and not tradeups[1],
     title="4_Warp Add to LONG",
     message="LONG *increase")
     
     
alertcondition(condition=tradedowns and tradeshorts and not exitdata2[1] and not tradedowns[1],
     title="5_Warp Add to SHORT",
     message="SHORT *increase")
     
//////////////// END ALL /////////////////////








if GoLong
    strategy.entry("Enter Long", strategy.long)
else if GoShort
    strategy.entry("Enter Short", strategy.short)

متعلقہ

مزید