یہ ایک قیمت پر مبنی ٹریڈنگ حکمت عملی ہے جس میں رجحانات کی نشاندہی کرنے کے لئے مساوی اشارے کے ساتھ مل کر قیمت کی شکل کا استعمال کرتے ہوئے داخل ہوتا ہے.
اس حکمت عملی کی بنیاد مندرجہ ذیل پہلوؤں پر ہے:
ای ایم اے اوسط لائن کا استعمال کرتے ہوئے رجحان کا تعین کریں۔ 89 سائیکل ای ایم اے اور ہل ایم اے دونوں سرخ ہونے پر ، اس کا فیصلہ بیئر رجحان کے طور پر کیا جاتا ہے ، اور صرف خالی ہوجاتا ہے۔ جب دونوں اوسط لائنیں سبز ہوں تو ، اس کا فیصلہ بیل رجحان کے طور پر کیا جاتا ہے ، اور صرف زیادہ ہوتا ہے۔ جب ایک سبز اور ایک سرخ ہو تو ، اس کا فیصلہ ہلچل کے طور پر کیا جاتا ہے ، اور زیادہ سے زیادہ خالی ہوجاتا ہے۔
قیمت کی شکل کو پہچاننے والے سگنل کا استعمال کریں۔ ممکنہ داخلے کے اوقات کی شناخت کے لئے حکمت عملیوں کو متعدد یارن اور نائن کے امتزاج کی شناخت کریں ، جیسے واحد ہستی لائن ، جعلی توڑنے والی شکلیں ، ماں لائن وغیرہ۔
کلیدی معاونت اور مزاحمت کی سطح پر داخلے کے ساتھ۔ اس حکمت عملی کو اہم معاونت اور مزاحمت کی سطح کے ساتھ مل کر ، قیمت کی شکل کے اشارے کو مزید تصدیق کرنے اور جھوٹے ٹوٹنے سے بچنے کے لئے۔
MACD معاون فیصلے. MACD اشارے کے ستون لائن رنگ کے ساتھ مل کر ، قیمت کی شکل کے اشارے کی توثیق کریں ، کامیابی کی شرح میں اضافہ کریں۔
ٹرینڈ ٹریکنگ میکانزم کو اپنانا۔ حکمت عملی میں ٹرینڈ ٹریکنگ ماڈیول شامل کیا گیا ہے ، جس سے رجحان کی تبدیلی کا زیادہ درست اندازہ لگایا جاسکتا ہے ، اور ٹاپ اور نیچے سے بچنا ہے۔
اسٹاپ نقصان کی روک تھام کا تعین کریں۔ حکمت عملی میں اے ٹی آر کی قیمت پر مبنی اسٹاپ نقصان اور اسٹاپ ماڈیول شامل کیا گیا ہے ، جس سے منافع کی شرح کو سمجھنے میں مدد ملتی ہے۔
یہ حکمت عملی مندرجہ ذیل فوائد رکھتی ہے:
قیمتوں کے رجحان پر مبنی ، اشارے سے متاثر نہیں ہے۔ خالص طور پر قیمت کے فیصلے پر مبنی ، پیچیدہ اشارے سے گمراہ نہیں ، مارکیٹ کے اصل ماخذ سے زیادہ قریب۔
رجحان کے تصور کے ساتھ مل کر ، اوپر سے نیچے کی پیروی سے گریز کریں۔ ای ایم اے اور ہل ایم اے میں رجحان کی سمت کی شناخت میں شامل ہوں ، صرف رجحان کی سمت میں ہی کام کریں ، مخالف سمت میں داخل ہونے سے بچیں۔
فارمیٹ کے ساتھ مل کر ، کامیابی کی شرح میں اضافہ کریں۔ قیمت کی شکل اور MACD اشارے ایک دوسرے کی توثیق کرتے ہیں ، جعلی سگنل کو فلٹر کرتے ہیں ، منافع کمانے کے امکانات میں اضافہ کرتے ہیں۔
ٹریکنگ میکانزم بڑے رجحانات کو پکڑ سکتا ہے۔ رجحان ٹریکنگ ماڈیول بڑے ٹائم پیریڈ کے رجحانات کو پکڑ سکتا ہے ، جس سے زیادہ منافع ہوتا ہے۔
نقصان کی روک تھام کا طریقہ کار ، کنٹرول کرنے کے لئے خطرہ۔ مقررہ نقصان کی روک تھام کا تناسب مقرر کیا گیا ہے ، جو منافع اور نقصان کے تناسب کو سمجھنے اور خطرے کو کنٹرول کرنے میں مدد کرتا ہے۔
اس حکمت عملی میں مندرجہ ذیل خطرات بھی ہیں:
بڑے دورانیہ کے رجحان کے الٹ جانے کا خطرہ۔ حکمت عملی صرف اس رجحان کے اندر کام کرنے کے لئے موزوں ہے جس میں وسط کی مختصر لائن زیادہ واضح ہے۔ اگر بڑے دورانیہ کے رجحان کا الٹ ہوتا ہے تو ، اس کو روک دیا جائے گا۔ بڑے رجحان کا تجزیہ بڑھا کر دورانیہ سے بچایا جاسکتا ہے۔
قیمت کی شکل میں ناکامی کا خطرہ۔ مختلف مارکیٹ کے ماحول میں قیمت کی شکل کا اثر بہت مختلف ہوتا ہے ، اور کچھ مارکیٹ کی شکلیں توقع کے مطابق اثر انداز نہیں ہوسکتی ہیں ، جس کی وجہ سے نظام میں رکاوٹ پیدا ہوتی ہے۔ مختلف مارکیٹ کی شکلوں کی تاثیر کے ردعمل کے ذریعہ مناسب شکل کا انتخاب کیا جاسکتا ہے۔
پیرامیٹرز کو بہتر بنانے میں دشواری۔ حکمت عملی میں متعدد پیرامیٹرز شامل ہیں ، مختلف پیرامیٹرز کا مجموعہ نتائج پر بہت زیادہ اثر ڈالتا ہے ، بہترین پیرامیٹرز تلاش کرنے کے لئے بہت زیادہ ریٹرننگ کی ضرورت ہوتی ہے ، اور پیرامیٹرز کی جامد ترتیب مارکیٹ میں تبدیلی کے خطرے کا سامنا کرتی ہے۔ متحرک پیرامیٹرز کی اصلاح کا طریقہ کار اس کے لئے تشکیل دیا جاسکتا ہے۔
انفرادی خطرے کو مؤثر طریقے سے کنٹرول کرنے میں ناکامی۔ فکسڈ اسٹاپ نقصان کی حد کی ترتیب ہر تجارت کی اتار چڑھاؤ کو سمجھنے میں مشکل ہے ، انفرادی منافع اور نقصان کی شرح کو ہدف کے مطابق کنٹرول کرنے میں ناکامی ہے۔ متحرک اسٹاپ نقصان کے الگورتھم یا وینڈر کنٹرول ماڈیول کو متعارف کرایا جاسکتا ہے۔
اس حکمت عملی کو مندرجہ ذیل پہلوؤں سے بہتر بنایا جاسکتا ہے:
مشین لرننگ متعارف کروائیں تاکہ زیادہ پیچیدہ قیمتوں کی شناخت کی جاسکے۔ گہری سیکھنے جیسی ٹیکنالوجیز کا استعمال کریں تاکہ زیادہ موثر شکلوں کی خودکار شناخت کی جاسکے۔
خود کو اپنانے میں اضافہ کریں۔ متحرک پیرامیٹرز کو بہتر بنانے کا طریقہ کار قائم کریں تاکہ حکمت عملی کے پیرامیٹرز کو جامد ترتیبات کی بجائے حقیقی وقت کی مارکیٹ میں ایڈجسٹ کیا جاسکے۔
مزید عوامل کی توثیق کے اشارے کے ساتھ۔ قیمتوں کے رجحانات کے مزید عوامل شامل کریں ، جیسے تجارت کی مقدار ، اوور نائٹ گیپس وغیرہ کی توثیق کریں ، اور بیعانہ کا خطرہ کم کریں۔
ونڈ کنٹرول اور پوزیشن مینجمنٹ ماڈیول متعارف کرایا گیا ہے۔ پوزیشن کا سائز خود بخود کم قیمت کے مطابق ایڈجسٹ کریں ، ایک ہی اسٹاپ نقصان کو مؤثر طریقے سے کنٹرول کریں ، اور منافع اور نقصان کی شرح کو بہتر بنائیں۔
داخلہ کے طریقہ کار کو بہتر بنائیں۔ رجحانات کے فیصلے کے ماڈیول کو بہتر بنائیں ، رجحانات کی ہلچل کی تیز رفتار کی شناخت کریں ، تاکہ داخلے کی کامیابی کی شرح میں اضافہ ہو۔
مجموعی طور پر ، اس حکمت عملی کا بنیادی فائدہ یہ ہے کہ یہ قیمتوں کے رجحانات پر مبنی فیصلے پر مبنی ہے ، اشارے پر انحصار کرنے سے گریز کرتا ہے ، اور زیادہ سے زیادہ مارکیٹ کی نوعیت کی عکاسی کرتا ہے۔ رجحانات اور اشارے کے ساتھ مل کر منافع کے امکانات کو بہتر بنایا جاسکتا ہے ، اسٹاپ نقصان کو کنٹرول کرنے کا خطرہ شامل کیا جاسکتا ہے۔ تاہم ، بڑے دورانیہ کے رجحانات کی تبدیلی ، قیمت کی شکل کی ناکامی اور دیگر خطرات سے بچنے کی ضرورت ہے۔ مستقبل میں مشین لرننگ ، متحرک پیرامیٹرز کی اصلاح ، وائر کنٹرول ماڈیول وغیرہ کے ذریعہ اس حکمت عملی کو زیادہ مستحکم اور قابل اعتماد بنایا جاسکتا ہے۔
/*backtest
start: 2023-08-19 00:00:00
end: 2023-09-18 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
args: [["v_input_1",true]]
*/
//@version=2
// strategy(title="Price Action", shorttitle="Price Action", overlay=true,default_qty_value=2000,initial_capital=1000,currency=currency.USD, pyramiding=1,calc_on_every_tick=true)
// EMA //
HiLoLen = 34
pacL = ema(low,HiLoLen)
pacC = ema(close,HiLoLen)
pacH = ema(high,HiLoLen)
signalMA = ema(close,89)
col1=pacC>signalMA?lime:pacC<signalMA?red:yellow
plot(signalMA, color=col1, title="SignalMA")
// Plot the Price Action Channel (PAC) base on EMA high,low and close//
//L=plot(pacL, color=yellow, linewidth=1, title="High PAC EMA",transp=0)
//C=plot(pacC, color=yellow, style = line, linewidth=1, title="Close PAC EMA",transp=0)
//H=plot(pacH, color=yellow, linewidth=1, title="Low PAC EMA",transp=0)
// HullMA //
n=89
//
n2ma=2*wma(close,round(n/2))
nma=wma(close,n)
diff=n2ma-nma
sqn=round(sqrt(n))
//
n2ma1=2*wma(close[1],round(n/2))
nma1=wma(close[1],n)
diff1=n2ma1-nma1
sqn1=round(sqrt(n))
//
n1=wma(diff,sqn)
n2=wma(diff1,sqn)
condDown = n2 >= n1
condUp = condDown != true
col =condUp ? lime : condDown ? red : yellow
plot(n1,title="Hull MA", color=col,linewidth=1)
// Macd Barcolor
fastlength = 12
slowlength = 26
MACDLength = 9
MACD = ema(close, fastlength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD
hisup= iff(delta>delta[1] and delta>0, 1,iff(delta<delta[1], -1, nz(hisup[1], 0)))
hisdown = iff(delta<delta[1] and delta<0, 1,iff(delta>delta[1], -1, nz(hisdown[1], 0)))
//Swing high low//
ktswinghigh=(high<=high[2] and high[1]<=high[2] and high[3]<=high[2] and high[4]<=high[2])// and high<high[1] and high[4]<high[3]) or (high<high[1] and high[1]<high[2] and high[4]<high[2] and high[5]<high[2] and high[3]<high[2])
ktswinghigh3=(high<high[1] and high[1]<high[3] and high[5]<high[3] and high[6]<high[5]and high[2]<high[3] and high[4]<high[3]) or(high<high[3] and high[2]<high[3] and high[1]<high[3] and high[4]<high[3] and high[5]<high[4])
sh=ktswinghigh?high[2]:na
swinghigh = fixnan(sh)
colorsh=swinghigh==swinghigh[1]?white:na
plot(swinghigh,color=colorsh,title="Swing High",style=line,offset=-2)
ktswinglow=(low>=low[2] and low[1]>=low[2] and low[3]>=low[2] and low[4]>=low[2])// and low>low[1] and low[4]>low[3]) or (low>low[1] and low[1]>low[2] and low[4]>low[2] and low[5]>low[2] and low[3]>low[2])
ktswinglow3=low>low[1] and low[1]>low[3] and low[5]>low[3] and low[6]>low[5] and low[2]>low[3] and low[4]>low[3] or (low>low[3] and low[1]>low[3] and low[2]>low[3] and low[4]>low[3] and low[5]>low[4])
sl=ktswinglow?low[2]:na
swinglow = fixnan(sl)
colorsl=swinglow==swinglow[1]?white:na
plot(swinglow,title="Swing Low",color=colorsl,style=line,offset=-2)
// Pinbar FailBreak
ema21=ema(close,13)
beariskpinbar= (close-open<(high-low)/3 and open-close<(high-low)/3) and ((high>swinghigh and high>high[1] and high>high[2] and high>high[3] and close<swinghigh))// or ((open[2]<ema21[2] or close[2]<ema21[2]) and high>ema21 and low[2]<low[1] and low[3]<low[2] and high>high[1] and high>high[2] and high>high[3]))
bullishpibar=(close-open<(high-low)/3 and open-close<(high-low)/3) and ((low<swinglow and low<low[1] and low<low[2] and low<low[3] and close>swinglow))// or ((open[2]>ema21[2] or close[2]>ema21[2]) and low<ema21 and high[2]>high[1] and high[3]>high[2] and low<low[1] and low<low[2] and low<low[3]))
//
Inside(position) => high <= high[position] and low >= low[position]
outsidebar = (high >= high[1] and low <= low[1])
barcolor((high <= high[1] and low >= low[1]) ? white : na)
barcolor(hisup==1 and MACD>0 ? lime: hisdown==1 and MACD<0 ? red : hisup==-1 and MACD>0 ? green: orange )
barcolor(bullishpibar or beariskpinbar ?white:na)
secLast = 1
fakey = (high[1] <= high[2] and low[1] >= low[2] and high > high[2] and close >= low[2] and close < high[2]) or (high[2]<=high[3] and low[2]>=low[3] and high[1]>high[2] and close<high[2] and close>low[3] and high-close>0.75*(high-low))// ? red : na
fakey1 = (high[1] <= high[2] and low[1] >= low[2] and low < low[2] and close > low[2] and close <= high[1]) or (high[2]<=high[3] and low[2]>=low[3] and low[1]<low[2] and close>low[2] and close<high[3] and close-low>0.75*(high-low)) //? lime : na
barcolor(fakey or fakey1?white:na)
//plotshape(beariskpinbar and (not fakey or (fakey and outsidebar)) , title= "Pinbar Bearisk", location=location.abovebar, color=white, style=shape.arrowdown, text="Pinbar",size=size.tiny)
//plotshape(bullishpibar and (not fakey1 or (fakey1 and outsidebar)), title= "Pinbar Bullish", location=location.belowbar, color=white, style=shape.arrowup, text="Pinbar",size=size.tiny)
//insidebar= Inside(secLast)? #FF9800: na
onewhitesoliderbear= close<open and high[1]-close>0.5*(high[1]-low[1]) and (open-close)>2/3*(high-low) and (high[1]>ema21[1] or high>ema21) and open[1]<ema21[1] and close-low<(high-close)*0.3 and (open[2]<ema21[2] or close[2]<ema21[2]) and close<ema21 and low[2]<low[1] and low[3]<low[2]
onewwhitesoliderbull= close>open and close-low[1]>0.5*(high[1]-low[1]) and (close-open)>2/3*(high-low) and (low[1]<ema21[1] or low<ema21) and open[1]>ema21[1] and high-close<(close-low)*0.3 and (open[2]>ema21[2] or close[2]>ema21[2]) and close>ema21 and high[2]>high[1] and high[3]>high[2]
onewhitesoliderbear1= close<open and high[1]-close>0.5*(high[1]-low[1]) and (open-close)>2/3*(high-low) and (high[1]>pacC[1] or high>pacC) and open[1]<pacC[1] and close-low<(high-close)*0.3 and (open[2]<pacC[2] or close[2]<pacC[2]) and close<pacC and low[2]<low[1] and low[3]<low[2]
onewwhitesoliderbull1= close>open and close-low[1]>0.5*(high[1]-low[1]) and (close-open)>2/3*(high-low) and (low[1]<pacC[1] or low<pacC) and open[1]>pacC[1] and high-close<(close-low)*0.3 and (open[2]>pacC[2] or close[2]>pacC[2]) and close>pacC and high[2]>high[1] and high[3]>high[2]
onewhitesoliderbear2= close<open and high[1]-close>0.5*(high[1]-low[1]) and (open-close)>2/3*(high-low) and (high[1]>signalMA[1] or high>signalMA) and open[1]<signalMA[1] and close-low<(high-close)*0.3 and (open[2]<signalMA[2] or close[2]<signalMA[2]) and close<signalMA and low[2]<low[1] and low[3]<low[2]
onewwhitesoliderbull2= close>open and close-low[1]>0.5*(high[1]-low[1]) and (close-open)>2/3*(high-low) and (low[1]<signalMA[1] or low<signalMA) and open[1]>signalMA[1] and high-close<(close-low)*0.3 and (open[2]>signalMA[2] or close[2]>signalMA[2]) and close>signalMA and high[2]>high[1] and high[3]>high[2]
//plotshape(beariskpinbar and (not fakey or (fakey and outsidebar)) and not onewhitesoliderbear and not onewwhitesoliderbull, title= "Pinbar Bearisk", location=location.abovebar, color=white, style=shape.arrowdown, text="Pinbar",size=size.tiny)
//plotshape(bullishpibar and (not fakey1 or (fakey1 and outsidebar)) and not onewwhitesoliderbull and not onewhitesoliderbear, title= "Pinbar Bullish", location=location.belowbar, color=white, style=shape.arrowup, text="Pinbar",size=size.tiny)
//
//pinbar=(open>ema21 and low<ema21 and close-low>2*(high-close)) or (open[1]>ema21[1] and low[1]<ema21[1] and (close-low[1]>2*(high[1]-close) or close-low>2*(high[1]-close)))? green:na
//pinbar2=(open<ema21 and high>ema21 and high-close>2*(close-low)) or (open[1]<ema21[1] and high[1]>ema21[1] and (high[1]-close>2*(close-low[1]) or high-close>2*(close-low[1])))?orange:na
//plot(ema21)
//bgcolor(insidebar, transp=70)
//bgcolor(fakey, transp=80)
//bgcolor(fakey1, transp=80)
//bgcolor(pinbar, transp=70)
//bgcolor(pinbar2, transp=70)
insidebar = ((high[1] <= high[2] and low[1] >= low[2]) and not(outsidebar))
barcolor(outsidebar and high[1]<=high[2] and low[1]>=low[2]?white:na)
bearishibbf=( insidebar and (high > high[1] and close < high[1]))
//barcolor( bearishibbf ? white : na, 0, true, "Bearish Inside Bar Breakout Failure")
//plotshape(bearishibbf and not fakey, title= "Bearish Inside Bar Breakout Failure", location=location.abovebar, color=white, style=shape.arrowdown, text="InsideBar\nFailBreak",size=size.tiny)
bullishibbf=(insidebar and (low < low[1] and close > low[1]))
//barcolor( bullishibbf ? white : na, 0, true, "Bullish Inside Bar Breakout Failure")
//plotshape(bullishibbf and not fakey1, title= "Bullish Inside Bar Breakout Failure", location=location.belowbar, color=white, style=shape.arrowup, text="InsideBar\nFailBreak",size=size.tiny)
//
barcolor((onewwhitesoliderbull or onewhitesoliderbear) and not insidebar?white:na)
//
// Outsidebar follow Insidebar
///plotshape(outsidebar and ((high[1]<=high[2] and low[1]>=low[2] ) ) and close<ema21 and not beariskpinbar and not bullishpibar, title= "OutsideBar Break InsideBar", location=location.abovebar, color=white, style=shape.arrowdown, text="Outside\nBar",size=size.tiny)
//plotshape(outsidebar and ((high[1]<=high[2] and low[1]>=low[2]) ) and close>ema21 and not beariskpinbar and not bullishpibar, title= "OutsideBar Break InsideBar", location=location.belowbar, color=white, style=shape.arrowup, text="Outside\nBar",size=size.tiny)
//
whitesoldierreversal= ((low[1]<low[2] and low[2]<low[3]) or (high[1]<high[2] and high[2]<high[3])) and low[3]<low[8] and low[8]<ema21[8] and high[2]<ema21[2] and high[1]<ema21[1] and high[3]<ema21[3] and close-low[1]>(high[1]-close) and (open<close[1] or open<open[1]) and close-open>0.3*(high-low) and high-close<0.5*(close-open)
blackcrowreversal= ((high[1]>high[2] and high[2]>high[3]) or (low[1]>low[2] and low[2]>low[3])) and high[3]>high[8] and high[8]>ema21[8] and low[2]>ema21[2] and low[1]>ema21[1] and low[3]>ema21[3] and close-low[1]<(high[1]-close) and (open>close[1] or open>open[1]) and open-close>0.3*(high-low) and close-low<0.5*(open-close)
// Black Crow and White Soldier Reversal
//plotshape(whitesoldierreversal, title= "Piercing Pattern", location=location.belowbar, color=white, style=shape.arrowup, text="Piercing",size=size.tiny)
//plotshape(blackcrowreversal, title= "Dark Cloud Cover", location=location.abovebar, color=white, style=shape.arrowdown, text="Dark\nCloud",size=size.tiny)
barcolor(blackcrowreversal or whitesoldierreversal?white:na)
//
pinbarreversalbull= ((low[1]<low[2] and low[2]<low[3]) or (high[1]<high[2] and high[2]<high[3])) and low[3]<low[8] and low[8]<ema21[8] and high[2]<ema21[2] and high[1]<ema21[1] and high[3]<ema21[3] and close-open<(high-low)/3 and open-close<(high-low)/3 and high-close<close-low and low<low[1]
pinbarreversalbear= ((high[1]>high[2] and high[2]>high[3])or (low[1]>low[2] and low[2]>low[3])) and high[3]>high[8] and high[8]>ema21[8] and low[2]>ema21[2] and low[1]>ema21[1] and low[3]>ema21[3] and close-open<(high-low)/3 and open-close<(high-low)/3 and high-close>close-low and high>high[1]
// Pinbar Reversal
//plotshape(pinbarreversalbull and not whitesoldierreversal and not fakey1 and not blackcrowreversal and not whitesoldierreversal and not bullishpibar, title= "Bullish Pinbar Reversal", location=location.belowbar, color=white, style=shape.arrowup, text="Pinbar",size=size.tiny)
//plotshape(pinbarreversalbear and not blackcrowreversal and not fakey and not whitesoldierreversal and not blackcrowreversal and not beariskpinbar, title= "Bearisk Pinbar Reversal", location=location.abovebar, color=white, style=shape.arrowdown, text="Pinbar",size=size.tiny)
barcolor(pinbarreversalbear or pinbarreversalbull?white:na)
// Fakey
plotshape(fakey and (not outsidebar or not (high[1]<=high[2] and low[1]>=low[2]) ) and not blackcrowreversal , title= "Fakey Bearisk", location=location.abovebar, color=white, style=shape.arrowdown, text="Fakey",size=size.tiny)
plotshape(fakey1 and (not outsidebar or not (high[1]<=high[2] and low[1]>=low[2]) ) and not whitesoldierreversal , title= "Fakey Bullish", location=location.belowbar, color=white, style=shape.arrowup, text="Fakey",size=size.tiny)
// Pinbar Fake Breakout
//plotshape(beariskpinbar and (not fakey or (fakey and outsidebar)) and not onewhitesoliderbear and not onewwhitesoliderbull and not blackcrowreversal and not whitesoldierreversal and not fakey, title= "Pinbar Bearisk", location=location.abovebar, color=white, style=shape.arrowdown, text="FalseBreak\nPinbar",size=size.tiny)
//plotshape(bullishpibar and (not fakey1 or (fakey1 and outsidebar)) and not onewwhitesoliderbull and not onewhitesoliderbear and not whitesoldierreversal and not blackcrowreversal and not fakey1, title= "Pinbar Bullish", location=location.belowbar, color=white, style=shape.arrowup, text="FalseBreak\nPinbar",size=size.tiny)
// Black Crow and White Soldier Continuation
//plotshape((onewhitesoliderbear or onewhitesoliderbear1 or onewhitesoliderbear2) and not insidebar and not fakey and not fakey1 and not outsidebar, title= "One solider Bearisk", location=location.abovebar, color=white, style=shape.arrowdown, text="Black\nCrow",size=size.tiny)
//plotshape((onewwhitesoliderbull or onewwhitesoliderbull1 or onewwhitesoliderbull2)and not insidebar and not fakey and not fakey1 and not outsidebar, title= "One solider Bullish", location=location.belowbar, color=white, style=shape.arrowup, text="White\nSoldier",size=size.tiny)
// Pinbar Continuation
pinbarresistance= (close-open<(high-low)/3 and open-close<(high-low)/3) and high-close>(close-low) and high-open>(open-low) and ((open[2]<ema21[2] or close[2]<ema21[2]) and high>ema21 and low[2]<low[1] and low[3]<low[2] and high>high[1] and high>high[2] and high>high[3])
pinbarsupport=(close-open<(high-low)/3 and open-close<(high-low)/3) and close-low>(high-close) and open-low>(high-open) and ((open[2]>ema21[2] or close[2]>ema21[2]) and low<ema21 and high[2]>high[1] and high[3]>high[2] and low<low[1] and low<low[2] and low<low[3])
//plotshape(pinbarresistance and (not fakey or (fakey and outsidebar)) and not onewhitesoliderbear and not onewwhitesoliderbull and not blackcrowreversal and not whitesoldierreversal and not fakey and not beariskpinbar, title= "Pinbar Bearisk", location=location.abovebar, color=white, style=shape.arrowdown, text="Pinbar",size=size.tiny)
//plotshape(pinbarsupport and (not fakey1 or (fakey1 and outsidebar)) and not onewwhitesoliderbull and not onewhitesoliderbear and not whitesoldierreversal and not blackcrowreversal and not fakey1 and not bullishpibar, title= "Pinbar Bullish", location=location.belowbar, color=white, style=shape.arrowup, text="Pinbar",size=size.tiny)
// barcolor
onlybuy=input(false)
onlysell=input(false)//
conmua= hisup==1 and MACD>0?1: (hisdown[1]==1 and MACD[1]<0 and pacC[1]>signalMA[1]) or (n1[2]<n1[3] and pacC[1]>signalMA[1])?-1:nz(conmua[1],1)
conmua1= conmua==1 and (hisdown==1 and MACD<0 and pacC>signalMA) or (n1[1]<n1[2] and pacC>signalMA)?1:(close[1]>n1[1] and pacC[1]>signalMA[1] and open[1]<n1[1] and close[1]>pacC[1]) or crossunder(pacC,signalMA) ?-1:nz(conmua1[1],1)
conmua2=conmua1==1 and hisup==1 and MACD>0 and close>n1?1: high[1]<high[3] and high[2]<high[3]?-1:nz(conmua2[1],1)
conmua3=conmua2==1 and high<high[2] and high[1]<high[2]?1: (close[1]>swinghigh[1] and hisup[1]==1 and MACD[1]>0) or ( MACD<0)?-1:nz(conmua3[1],1)
mua=conmua3==1 and hisup==1 and MACD>0 and conmua2==-1 and conmua1==-1
mua2= conmua1==1 and ( close>n1 and pacC>signalMA and open<n1 and close>pacC) and conmua[1]==-1
//if(mua2 and onlysell==false)
// strategy.entry("Buy",strategy.long)
conban=hisdown==1 and MACD<0?1:(hisup[1]==1 and MACD[1]>0 and pacC[1]<signalMA[1]) or (n1[2]>n1[3] and pacC[1]<signalMA[1])?-1:nz(conban[1],1)
conban1= conban==1 and (hisup==1 and MACD>0 and pacC<signalMA) or (n1[1]>n1[2] and pacC<signalMA)?1:( close[1]<n1[1] and pacC[1]<signalMA[1] and open[1]>n1[1] and close[1]<pacC[1]) or crossover(pacC,signalMA)?-1:nz(conban1[1],1)
conban2=conban1==1 and hisdown==1 and MACD<0 and close<n1?1: low[1]>low[3] and low[2]>low[3]?-1:nz(conban2[1],1)
conban3=conban2==1 and low[1]>low[2] and low>low[2]?1: (close[1]<swinglow[1] and hisdown[1]==1 and MACD[1]<0) or ( MACD>0)?-1:nz(conban3[1],1)
ban=conban3==1 and hisdown==1 and MACD<0 and conban2==-1
ban2=conban1==1 and ( close<n1 and pacC<signalMA and open>n1 and close<pacC) and conban[1]==-1
//if(ban2 and onlybuy==false)
// strategy.entry("Sell",strategy.short)
plotshape(conmua1==1 and conmua[1]==-1, style= shape.triangleup, color = lime, location = location.bottom,size=size.tiny)
plotshape(conban1==1 and conban[1]==-1, style= shape.triangledown, color = red, location = location.bottom,size=size.tiny)
plotshape(mua2, style= shape.labelup, color = lime, location = location.bottom,size=size.tiny)
plotshape(ban2, style= shape.labeldown, color = red, location = location.bottom,size=size.tiny)
// TP and SL/
SL = input(defval=50.00, title="Chốt lời (Pip)", type=float, step=1)
rr= input(defval=20.00,title="Cắt lỗ (Pip)",type=float, step=1)
useTPandSL = input(defval = true, title = "Sử dụng chốt lời và cắt lỗ?")
Stop = rr*10
Take=SL*10
Q = 100
if(useTPandSL)
strategy.exit("ExitBuy", "Buy", qty_percent=Q, profit= Take, loss=Stop)
strategy.exit("ExitSell", "Sell", qty_percent=Q, profit= Take, loss=Stop)