Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. study(title='Dudes Margin Call System', shorttitle='DMC', overlay=true)
  2. emaPeriod = input(title="EMA Period (default = 8)", type=integer, defval=8)
  3. mclevellong = input(title="Enter Estimated Margin Call % for Longs",type=float,defval=.042)
  4. mclevelshort = input(title="Enter Estimated Margin Call % for Shorts",type=float,defval=.042)
  5. //EMA Variables
  6. findemahigh(x) =>
  7. ema(high[x],emaPeriod)
  8. findemalow(x) =>
  9. ema(low[x],emaPeriod)
  10. emaHigh = findemahigh(0)
  11. hist1_emaHigh = findemahigh(1)
  12. hist2_emaHigh = findemahigh(2)
  13. hist3_emaHigh = findemahigh(3)
  14. hist4_emaHigh = findemahigh(4)
  15. emaLow = findemalow(0)
  16. hist1_emaLow = findemalow(1)
  17. hist2_emaLow = findemalow(2)
  18. hist3_emaLow = findemalow(3)
  19. hist4_emaLow = findemalow(4)
  20. avgleveluplong=sma(hl2,3)+sma(hl2,3)*mclevellong
  21. avgleveldownlong=sma(hl2,3)-sma(hl2,3)*mclevellong
  22. avglevelupshort=sma(hl2,3)+sma(hl2,3)*mclevelshort
  23. avgleveldownshort=sma(hl2,3)-sma(hl2,3)*mclevelshort
  24.  
  25. //Candle Pivot Functions
  26. //Pivot Up
  27. pivotup0() =>
  28. close[1] < hist1_emaLow and close>open and close >=emaLow ? 1 : 0
  29. pivotup1() =>
  30. close[2] < hist2_emaLow and close[1]>open[1] and close[1] >=hist1_emaLow ? 1 : 0
  31. pivotup2() =>
  32. close[3] < hist3_emaLow and close[2]>open[2] and close[2] >=hist2_emaLow ? 1 : 0
  33. pivotup=pivotup0()
  34.  
  35. //Pivot Up Confirmation
  36. crpivotup0() =>
  37. close > high[1] and pivotup1()==1 ? 1 : 0
  38. crpivotup1() =>
  39. close > high[2] and pivotup2()==1 ? 1 : 0
  40. crup=crpivotup0() or crpivotup1()
  41.  
  42. //Pivot Down
  43. pivotdown0() =>
  44. close[1] > hist1_emaHigh and close<open and close <=emaHigh ? 1 : 0
  45. pivotdown1() =>
  46. close[2] > hist2_emaHigh and close[1]<open[1] and close[1] <=hist1_emaHigh ? 1 : 0
  47. pivotdown2() =>
  48. close[3] > hist3_emaHigh and close[2]<open[2] and close[2] <=hist2_emaHigh ? 1 : 0
  49. pivotdown=pivotdown0()
  50.  
  51. //Confirm Pivot Down
  52. crpivotdown0()=>
  53. close<low[1] and pivotdown1()==1 ? 1 : 0
  54. crpivotdown1()=>
  55. close<low[2] and pivotdown2()==1 ? 1 : 0
  56. crdown=crpivotdown0() or crpivotdown1()
  57.  
  58. //Plots Pivot Up
  59. crmczoneup1=plot(plotmcdots and crup?avgleveluplong:na,title="Pivot Up Long Liquidation Zone", style=circles,color=red,linewidth=2,transp=15)
  60. crmczonedown1=plot(plotmcdots and crup?avgleveldownlong:na,title="Pivot Up Short Liquidation Zone", style=circles,color=lime,linewidth=2,transp=15)
  61. //Plots Pivot Down
  62. crdmczoneup1=plot(plotmcdots and crdown?avglevelupshort:na,title="Pivot Down Long Liquidation Zone", style=circles,color=red,linewidth=2,transp=15)
  63. 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