Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- study(title='Dudes Margin Call System', shorttitle='DMC', overlay=true)
- emaPeriod = input(title="EMA Period (default = 8)", type=integer, defval=8)
- mclevellong = input(title="Enter Estimated Margin Call % for Longs",type=float,defval=.042)
- mclevelshort = input(title="Enter Estimated Margin Call % for Shorts",type=float,defval=.042)
- //EMA Variables
- findemahigh(x) =>
- ema(high[x],emaPeriod)
- findemalow(x) =>
- ema(low[x],emaPeriod)
- emaHigh = findemahigh(0)
- hist1_emaHigh = findemahigh(1)
- hist2_emaHigh = findemahigh(2)
- hist3_emaHigh = findemahigh(3)
- hist4_emaHigh = findemahigh(4)
- emaLow = findemalow(0)
- hist1_emaLow = findemalow(1)
- hist2_emaLow = findemalow(2)
- hist3_emaLow = findemalow(3)
- hist4_emaLow = findemalow(4)
- avgleveluplong=sma(hl2,3)+sma(hl2,3)*mclevellong
- avgleveldownlong=sma(hl2,3)-sma(hl2,3)*mclevellong
- avglevelupshort=sma(hl2,3)+sma(hl2,3)*mclevelshort
- avgleveldownshort=sma(hl2,3)-sma(hl2,3)*mclevelshort
- //Candle Pivot Functions
- //Pivot Up
- pivotup0() =>
- close[1] < hist1_emaLow and close>open and close >=emaLow ? 1 : 0
- pivotup1() =>
- close[2] < hist2_emaLow and close[1]>open[1] and close[1] >=hist1_emaLow ? 1 : 0
- pivotup2() =>
- close[3] < hist3_emaLow and close[2]>open[2] and close[2] >=hist2_emaLow ? 1 : 0
- pivotup=pivotup0()
- //Pivot Up Confirmation
- crpivotup0() =>
- close > high[1] and pivotup1()==1 ? 1 : 0
- crpivotup1() =>
- close > high[2] and pivotup2()==1 ? 1 : 0
- crup=crpivotup0() or crpivotup1()
- //Pivot Down
- pivotdown0() =>
- close[1] > hist1_emaHigh and close<open and close <=emaHigh ? 1 : 0
- pivotdown1() =>
- close[2] > hist2_emaHigh and close[1]<open[1] and close[1] <=hist1_emaHigh ? 1 : 0
- pivotdown2() =>
- close[3] > hist3_emaHigh and close[2]<open[2] and close[2] <=hist2_emaHigh ? 1 : 0
- pivotdown=pivotdown0()
- //Confirm Pivot Down
- crpivotdown0()=>
- close<low[1] and pivotdown1()==1 ? 1 : 0
- crpivotdown1()=>
- close<low[2] and pivotdown2()==1 ? 1 : 0
- crdown=crpivotdown0() or crpivotdown1()
- //Plots Pivot Up
- crmczoneup1=plot(plotmcdots and crup?avgleveluplong:na,title="Pivot Up Long Liquidation Zone", style=circles,color=red,linewidth=2,transp=15)
- crmczonedown1=plot(plotmcdots and crup?avgleveldownlong:na,title="Pivot Up Short Liquidation Zone", style=circles,color=lime,linewidth=2,transp=15)
- //Plots Pivot Down
- crdmczoneup1=plot(plotmcdots and crdown?avglevelupshort:na,title="Pivot Down Long Liquidation Zone", style=circles,color=red,linewidth=2,transp=15)
- crdmczonedown1=plot(plotmcdots and crdown?avgleveldownshort:na,title="Pivot Down Short Liquidation Zone", style=circles,color=lime,linewidth=2,transp=15)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement