Advertisement
saisri

main afl(support 3)

Nov 3rd, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. _SECTION_BEGIN("BullBear Volume");
  2.  
  3. C1 = Ref(C, -1);
  4. uc = C > C1; dc = C <= C1;
  5. ud = C > O; dd = C <= O;
  6.  
  7. green = 1; blue = 2; yellow = 3; red = 4; white = 5;
  8. VType = IIf(ud,
  9. IIf(uc, green, yellow),
  10. IIf(dd,
  11. IIf(dc, red, blue), white));
  12.  
  13.  
  14. gv = IIf(VType == green, V, 0);
  15. yv = IIf(VType == yellow, V, 0);
  16. rv = IIf(VType == red, V, 0);
  17. bv = IIf(VType == blue, V, 0);
  18.  
  19. uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
  20. dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */
  21.  
  22. /* create moving average period parameters */
  23. VolPer = Param("Adjust Vol. MA per.", 34, 1, 255, 1);
  24. ConvPer = Param("Adjust Conv. MA per.", 9, 1, 255, 1);
  25.  
  26. /* create triple exponential moving avearges of separate up and down volume moving averages */
  27. MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
  28. MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
  29. MAtv = TEMA(V, VolPer );//total volume
  30.  
  31. /* Switch for Horizontal lines indicating current level of positive and negative volume for ease in comparing to past highs/lows - toggle via parmameter window */
  32. OscillatorOnly = Param("Show Oscillator Only", 0, 0, 1, 1);
  33. CompareBullVolume = Param("Show Bull Level", 1, 0, 1, 1);
  34. if(CompareBullvolume AND !OscillatorOnly){
  35. Plot(SelectedValue(MAuv), "", colorGreen, styleDots);
  36. }
  37.  
  38. CompareBearVolume = Param("Show Bear Level", 1, 0, 1, 1);
  39. if(CompareBearVolume AND !OscillatorOnly){
  40. Plot(SelectedValue(MAdv), "", colorYellow, styleDots);
  41. }
  42.  
  43. /* Volume Segment Switches - toggle via parameter window */
  44. bullvolume = Param("Show Bull Volume", 1, 0, 1, 1);
  45. bearvolume = Param("Show Bear Volume", 1, 0, 1, 1);
  46. totalvolume = Param("Show Total Volume", 1, 0, 1, 1);
  47.  
  48. /* plot volume lines and histograms if toggled on: */
  49. bearToFront = Param("Show Bear Vol in Front", 0, 0, 1, 1);
  50. if(bearToFront AND !OscillatorOnly){
  51. Plot(MAdv, "", colorRed, styleNoLabel);
  52. }
  53. if(bullvolume AND !OscillatorOnly){
  54. Plot(MAuv, "Average Bull Volume", colorBlue, styleThick+styleDots);
  55. }
  56. if(bearvolume AND !OscillatorOnly){
  57. Plot(MAdv, "Average Bear Volume", colorRed, styleThick+styleNoLabel);
  58. }
  59. if(totalVolume AND !OscillatorOnly){
  60. Plot(MAtv, "Total Volume", colorYellow, styleNoLabel);
  61. PlotOHLC(0,MAtv,0,MAtv, "m", colorGrey50, styleCloud+styleNoLabel+styleNoTitle,Null,Null,Null,-4);
  62. }
  63. if(bullvolume AND !OscillatorOnly){
  64. Plot(MAuv, "Total Volume", colorWhite, styleNoLabel);
  65. PlotOHLC(0,MAuv,0,MAuv, "m", colorDarkBlue, styleCloud+styleNoLabel+styleNoTitle,Null,Null,Null,-3);
  66. }
  67. if(bearvolume AND !OscillatorOnly){
  68. Plot(MAdv, "Total Volume", colorWhite, styleNoLabel);
  69. PlotOHLC(0,MAdv,0,MAdv, "m", colorDarkRed, styleCloud+styleNoLabel+styleNoTitle,Null,Null,Null,-2);
  70.  
  71. }
  72.  
  73.  
  74. /* better visibility of zero line: */
  75. Plot(0, "", colorYellow, Null,Null,Null,Null,1);
  76.  
  77. /* Rise/Fall Convergence variables: */
  78. Converge = (TEMA(MAuv - MAdv, ConvPer));
  79. Converge1 = Ref(Converge, -1);
  80. ConvergeUp = Converge > Converge1;
  81. ConvergeOver = Converge > 0;
  82. rising = ConvergeUp AND ConvergeOver;
  83. falling = !ConvergeUp AND ConvergeOver;
  84.  
  85. /* Rise/Fall Convergence Oscillator Switch - toggle via parameter window - (provides a better view of resulting combination of battling bull/bear volume forces) */
  86. convergenceOscillator = Param("Show Oscillator", 0, 0, 1, 1);
  87. if(convergenceOscillator OR OscillatorOnly){
  88. Plot(Converge, "Amimals War", colorViolet, 1|styleLeftAxisScale|styleNoLabel|styleThick);
  89. Plot(0,"", colorYellow, 1|styleLeftAxisScale|styleNoLabel);
  90. }
  91.  
  92. /********************************************************
  93. Convergence Rise/Fall Shadows:
  94.  
  95. (provides a more easily visible display of rising and falling bull/bear volume convergence) - toggle via parameter window
  96.  
  97. -posiitive Volume exceeding negative Volume: Light shadow
  98. -negative volume exceeding positive volume: dark shadow
  99. -if you use standard gray background - best shadows are:
  100. -my greys: 14 = (216, 216, 216); 15 = (168, 168, 168));
  101. -best substitute? using AB color constants?
  102. -light: colorpalegreen; dark: colorRose;?
  103. -(depends on your color scheme - customize to your tastes)
  104. **********************************************************/
  105.  
  106. /* uncomment if you use my custom color greys: */
  107. riseFallColor = IIf(rising, 14,15); //my custom shadow greys
  108.  
  109. /* comment out if you use my custom color gray shadows: */
  110. /* riseFallColor = IIf(rising, colorPaleGreen,colorRose); */
  111.  
  112. /* Rise/Fall Convergence Plot Switch - toggle via parameter window */
  113. riseFallShadows = Param("Show RiseFallShadows", 0, 0, 1, 1);
  114. if(riseFallShadows){
  115. Plot(IIf(rising OR falling, 1, 0), "", riseFallColor, styleArea|styleOwnScale|styleNoLabel);
  116. }
  117. GraphXSpace = 0.5;
  118. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement