Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Southbreeze Modified for Amibroker (AFL)

Rating:
3 / 5 (Votes 10)
Tags:
Southbreeze, amibroker, pivots, advanced

This is a modified Southbreeze indicator which includes the following:

1. Candle Pattern Analyser ( appear as commentry )
2. Auto FIBO based on last active wave of the selected period
3. Better Volume
4. Volume Spread Analyser
5. 20EMA Channel as guide for your trading decision
6. 10 indicator auto analyser feedback

Additionally, I have added Beta Trailing Stoploss line ( in GOLD color ).

Happy trading!!

Screenshots

Similar Indicators / Formulas

Boll Fibo Ashi Band
Submitted by Rushabh about 13 years ago
VSM TREND
Submitted by krishna9260 over 10 years ago
VSM TREND NO1 WITH GANNA INDICATOR
Submitted by krishna9260 over 10 years ago
super trend tracker
Submitted by jaipal7786 over 10 years ago
TTS system
Submitted by jaipal7786 about 11 years ago
TTS system V 2
Submitted by jaipal7786 about 11 years ago

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("CandleStick Analysis"); 
/*Body Colors*/
whiteBody=C>=O;
blackBody=O>C;
 
/*Body Size*/
smallBodyMaximum=0.0025;//less than 0.25%
LargeBodyMinimum=0.01;//greater than 1.0%
smallBody=(O>=C*(1-smallBodyMaximum) AND whiteBody)
         OR (C>=O*(1-smallBodyMaximum) AND blackBody);
largeBody=(C>=O*(1+largeBodyMinimum) AND whiteBody)
         OR C<=O*(1-largeBodyMinimum) AND blackBody;
mediumBody=NOT LargeBody AND NOT smallBody;
identicalBodies=abs(abs(Ref(O,-1)-Ref(C,-1))-abs(O-C)) <
          abs(O-C)*smallBodyMaximum;
realBodySize=abs(O-C);
 
 
/*Shadows*/
smallUpperShadow=(whiteBody AND H<=C*(1+smallBodyMaximum))
               OR (blackBody AND H<=O*(1+smallBodyMaximum));
smallLowerShadow=(whiteBody AND L>=O*(1-smallBodyMaximum))
               OR (blackBody AND L>=C*(1-smallBodyMaximum));
largeUpperShadow=(whiteBody AND H>=C*(1+largeBodyMinimum))
               OR (blackBody AND H>=O*(1+largeBodyMinimum));
largeLowerShadow=(whiteBody AND L<=O*(1-largeBodyMinimum))
              OR (blackBody AND L<=C*(1-largeBodyMinimum));
 
/*Gaps*/
upGap=  IIf(Ref(blackBody,-1)AND whiteBody AND O>Ref(O,-1),1,
        IIf(Ref(blackbody,-1) AND blackBody AND C>Ref(O,-1),1,
        IIf(Ref(whiteBody,-1) AND whiteBody AND O>Ref(C,-1),1,
        IIf(Ref(whiteBody,-1) AND blackBody AND C>Ref(C,-1),1,0))));
 
downGap=IIf(Ref(blackBody,-1)AND whiteBody AND C<Ref(C,-1),1,
        IIf(Ref(blackbody,-1) AND blackBody AND O<Ref(C,-1),1,
        IIf(Ref(whiteBody,-1) AND whiteBody AND C<Ref(O,-1),1,
        IIf(Ref(whiteBody,-1) AND blackBody AND O<Ref(O,-1),1,0))));
 
 
/*Candle Definitions*/
spinningTop=mediumBody;
doji=CdDoji(threshold=0.05);/*abs(C-O) <= (C*smallBodyMaximum) OR
(abs(O-C)<=((H-L)*0.1));*/
dojiStar=doji AND (upgap OR downgap)AND Ref(LargeBody,-1);
marabuzu=LargeBody AND smallUpperShadow AND smallLowerShadow;
 
shootingStar=/*(NOT largeBody AND smallLowerShadow AND LargeUpperShadow) OR*/
    smallLowerShadow AND NOT doji AND
   ((blackBody AND abs(O-H)>2*realBodySize) OR
   (whiteBody AND abs(H-C)>2*realBodySize));
 
Hammer=smallUpperShadow AND NOT doji AND
   ((blackBody AND abs(C-L)>2*realBodySize) OR
   (whiteBody AND abs(L-O)>2*realBodySize));
 
tweezerTop=abs(H-Ref(H,-1))<=H*0.0025;
tweezerBottom=abs(L-Ref(L,-1))<=L*0.0025;
engulfing=
   IIf(blackBody AND Ref(blackbody,-1) AND C<Ref(C,-1) AND O>Ref(O,-1),1,
   IIf(blackBody AND Ref(whiteBody,-1) AND O>Ref(C,-1) AND C<Ref(O,-1),1,
   IIf(whitebody AND Ref(whitebody,-1) AND C>Ref(C,-1) AND O<Ref(O,-1),1,
   IIf(whiteBody AND Ref(blackBody,-1) AND C>Ref(O,-1)AND O<Ref(C,-1),1,0))));
Harami=
   IIf(blackbody AND Ref(blackBody,-1) AND O<Ref(O,-1) AND C>Ref(C,-1),1,
   IIf(blackBody AND Ref(whiteBody,-1) AND C>Ref(O,-1) AND O<Ref(C,-1),1,
   IIf(whiteBody AND Ref(whiteBody,-1) AND C<Ref(C,-1) AND O>Ref(O,-1),1,
   IIf(whiteBody AND Ref(blackBody,-1) AND O>Ref(C,-1) AND C<Ref(O,-1),1,0))));
 
 
/*Maximum High Today - (MHT)
Today is the maximum High in the last 5 days*/
MHT=  HHV(H,5)==H;
 
/*Maximum High Yesterday - (MHY)
Yesterday is the maximum High in the last 5 days*/
MHY=   HHV(H,5)==Ref ( H, -1);
 
/*Minimum Low Today - (MLT)
Today is the minimum Low in the last 5 days*/
MLT=   LLV(L,5)==L;
 
/*Minimum Low Yesterday - (MLY)
Yesterday is the minimum Low in the last 5 days*/
MLY=   LLV(L,5)==Ref(L,-1);
 
/*DOJI definitions*/
 
/*Doji Today - (DT)*/
DT = abs(C-O) <= (C*smallBodyMaximum) OR
(abs(O-C)<=((H-L)*0.1));
 
/* Doji Yesterday - (DY)*/
DY = abs(Ref ( C, -1)-Ref(O,-1)) <= Ref ( C, -1) *smallBodyMaximum OR
abs (Ref ( O, -1)-Ref(C,-1)) <= (Ref ( H, -1 ) - Ref ( L, -1 ) )*0.1;
 
/**************************************************
             BULLISH CANDLESTICKS
*************************************************** */
 
/* Abandoned Baby Bullish*/
abandonedBabybullish =Ref(largeBody,-2) AND Ref(blackBody,-2)//Large black candle
             AND Ref(GapDown(),-1) 
             AND whiteBody AND LargeBody AND GapUp();//Large white candle
 
/* Belt Hold*///Bad formula
beltHoldBullish = largeBody AND smallLowerShadow AND whiteBody AND MLT;
 
 
/*BreakAway Bullish*/
breakAwayBullish=Ref(Largebody,-4) AND Ref(blackBody,-4)
              AND Ref(blackBody,-3) AND Ref(O,-3)<Ref(C,-4)
              AND Ref(smallbody,-2) AND Ref(C,-2)<Ref(C,-3)
              AND Ref(C,-1)<Ref(C,-2)
              AND LargeBody AND whiteBody AND C>Ref(O, -3)
              AND C<Ref(C,-4);
 
/*Concealing Baby Swallow only one trade */
ConcealingBabySwallow=Ref(marabuzu,-3) AND Ref(blackbody,-3) AND
                      Ref(MArabuzu,-2) AND Ref(blackBody,-2) AND
                      Ref(blackBody,-1) AND Ref(downGap,-1) AND
                      Ref(H,-1)>Ref(C,-2)AND Ref(blackbody,-1)AND
                      blackBody AND engulfing;
 
/*Doji Star Bullish*/
dojiStarBullish=(dojiStar AND (MLT OR MLY))OR
   (doji AND (C<Ref(C,-1) OR O<Ref(C,-1))AND Ref(blackBody,-1)
    AND Ref(LargeBody,-1));
 
/*Engulfing Bullish*/  
engulfingBullish =
    engulfing AND largeBody AND whiteBody AND
    (Ref(blackbody,-1) OR Ref(Doji,-1)) AND MLT;
 
/*Hammer Bullish*/
hammerBullish=Hammer AND (MLT OR MLY);
 
/*Dragonfly Doji Bullish*/
dragonflyDoji=smallBody AND LargeLowerShadow AND smallUpperShadow AND MLT;
 
/* Harami Bullish*/
haramiBullish = harami AND Ref (LargeBody,-1) AND Ref(blackBody,-1) AND
                NOT LargeBody AND whiteBody;
 
/*Harami Cross*/
HaramiCross=harami AND Ref(LargeBody,-1) AND Ref(blackBody,-1) AND doji;
        
/* Homing Pigeon*/
homingPigeon =  Ref(largeBody,-1) AND Ref(blackBody,-1) AND
                H<= Ref ( O, -1 ) AND L>=Ref( C, -1) AND C<O AND MLY;
 
/*Inverted Hammer*/
invertedHammer=shootingStar AND (MLT OR MLY);
 
/* Meeting LinesBullish*/
meetingLinesbullish= Ref(LargeBody,-1) AND Ref(blackBody,-1) AND
                     LargeBody AND whiteBody AND
                     C>Ref(C,-1)*0.9975 AND C< Ref(C,-1)*1.0025;
 
/*Morning Doji Star*/
morningDojiStar= Ref(LargeBody,-2) AND Ref(blackBody,-2) AND
                 Ref(doji,-1) AND Ref(O,-1)<Ref(C,-2) AND
                 whiteBody AND C>Ref(C,-2) AND MLY;
 
/* Morning Star*/
morningStar =Ref(largeBody,-2) AND Ref(blackBody,-2)//Large black candle
             AND Ref(downGap,-1)//Gap down yesterday
             AND whiteBody AND LargeBody AND C>Ref(C,-2)//Large white candle today
             AND MLY; //Yesterday was the low
 
/* Piercing Line*/
piercingLine= Ref(largeBody,-1) AND Ref(blackBody,-1)AND
               O<Ref(L,-1) AND C>=(Ref(O,-1)+Ref(C,-1))/2 AND C<Ref(O,-1) AND MLT;
 
/* Stick Sandwich*/
stickSandwich=Ref(largeBody,-2) AND Ref(blackbody,-2) AND
              Ref(largeBody,-1) AND Ref(whiteBody,-1) AND
              Ref(O,-1)>=Ref(C,-2) AND O>=Ref(C,-1) AND
              abs(C-Ref(C,-2))<=C*0.0025;
 
/*Three Inside Up harami confirming*/
threeInsideUp =Ref(Haramibullish,-1) AND whiteBody AND
    largeBody AND C>Ref(C,-1);
 
 
/* Three Outside Up Engulfing confirmation*/
threeOutsideUp =Ref(engulfingBullish,-1) AND whiteBody AND C>Ref(C,-1);
 
/* Three Stars in the South*///Rewrite???
threeStarsInTheSouth=
   Ref(LargeBody,-2) AND Ref(blackBody,-2) AND Ref(largelowerShadow,-2)
   AND Ref(blackBody,-1) AND Ref(largeLowerShadow,-1) AND
   Ref(L,-1)>Ref(L,-2) AND blackBody AND smallUpperShadow AND
   smallLowerShadow AND L>Ref(L,-1) AND H<Ref(H,-1);
 
/* Tri-Star Bullish*/
triStarBullish=Ref(doji,-2) AND Ref(doji,-1) AND doji AND MLY AND
   Ref(downgap,-1) AND upGap;
 
/* Three River Bottom Bad formula*/
threeriverBottom=Ref(largeBody,-2) AND Ref(blackBody,-2) AND
                 Ref(blackbody,-1) AND Ref(Largelowershadow,-1) AND
                 Ref(O,-1)<Ref(O,-2) AND Ref(C,-1)>Ref(C,-2) AND
                 whiteBody AND C<Ref(C,-1) AND MLY;  
                   
/* Mat Hold Bullish*/
MAtHoldBullish=Ref(LargeBody,-4) AND Ref(whiteBody,-4)//1st day
   AND Ref(blackBody,-3) AND Ref(upGap,-3) AND NOT Ref(LargeBody,-3)
   AND NOT Ref(LargeBody,-2) AND Ref(C,-2)<Ref(C,-3) AND Ref (O,-2)<Ref(O,-3) AND
   Ref(C,-2)>Ref(O,-4) AND NOT Ref(LargeBody,-1) AND Ref(C,-1)<Ref(C,-2)
   AND LargeBody AND whiteBody AND C>Ref(C,-4);
 
/*RisingThreeMethods*/
risingThreeMethods=Ref(LargeBody,-4) AND Ref(whiteBody,-4) AND NOT
  Ref(LargeBody,-3) AND NOT Ref(LargeBody,-2)AND NOT Ref(LargeBody,-1) AND
  Ref(C,-3)<Ref(C,-4) AND Ref(C,-2)<Ref(C,-3) AND Ref(C,-1)<Ref(C,-2) AND
  LargeBody AND whitebody AND C>Ref(C,-4);
 
/* Seperating Lines Bullish*/
separatingLinesBullish=Ref(blackBody,-1) AND whiteBody AND LargeBody AND
smallLowerShadow AND MHT AND abs(O-Ref(O,-1))<=O*0.0025;
 
/*Side by Side White Lines*/
sideBySideWhiteLines=NOT Ref(smallBody,-2) AND Ref(whiteBody,-2)
   AND Ref(upGap,-1) AND Ref(whitebody,-1)AND whiteBody AND
   identicalBodies AND abs(O-Ref(O,-1))<O*0.0025;
 
 
/*Three White Soldiers*/
threeWhiteSoldiers=NOT Ref(smallbody,-2) AND Ref(whiteBody,-2) AND NOT
   Ref(smallBody,-1) AND Ref(whiteBody,-1) AND NOT
   smallBody AND whiteBody AND C>Ref(C,-1) AND Ref(C,-1)>Ref(C,-2) AND
   Ref(O,-1)>Ref(O,-2) AND Ref(O,-1)<Ref(C,-2) AND O<Ref(C,-1) AND
   O>Ref(O,-1) AND Ref(smallUpperShadow,-2) AND
   Ref(smallUpperShadow,-1) AND smallUppershadow AND LLV(L,12)==Ref(L,-2);
 
/*Upside Gap Three Methods not very good*/
upsideGapThreeMethods=Ref(Largebody,-2) AND Ref(whiteBody,-2) AND
   Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND Ref(upGap,-1) AND
   blackBody AND O>Ref(O,-1) AND C<Ref(C,-2)AND C>Ref(O,-2) AND
  MHY;
 
/*Three Line Strike not good signals*/
threeLineStrike=NOT Ref(smallBody,-3) AND NOT Ref(smallBody,-2) AND
   NOT Ref(smallBody,-1) AND Ref(whiteBody,-3) AND Ref(whiteBody,-2) AND
   Ref(whiteBody,-1) AND Ref(C,-1)>Ref(C,-2) AND Ref(C,-2)>Ref(C,-3) AND
   blackBody AND O>Ref(C,-1) AND C<Ref(O,-3);
 
/*Tweezer Bottom*/
tweezerBottom= (abs(L-Ref(L,-1))/L<0.0025 OR
               abs(L-Ref(L,-2))/L<0.0025)
               AND (MLT OR MLY);
 
/*Upside Tasuki Gap*/
upsideTasukiGap=Ref(largeBody,-2) AND Ref(largeBody,1) AND
   Ref(whiteBody,-2) AND Ref(whiteBody,-1) AND Ref(upGap,-1) AND
   blackBody AND O>Ref(O,-1) AND C<Ref(O,-1) AND C>Ref(C,-2) AND
   identicalBodies AND O<Ref(C,-1);
   //AND HHV(H,5)==Ref(H,-1); Do not use this line
 
 
/*****************************************
            BEARISH CANDLESTICKS
******************************************/
 
/*Abandoned Baby Bearish*/
AbandonedBabyBearish=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
   Ref(smallBody,-1) AND Ref(GapUp(),-1) AND GapDown() AND
   NOT smallBody AND blackBody AND MHY;
 
/*Advance Block Bearish*/
AdvanceBlockBearish=Ref(LargeBody,-2) AND Ref(whiteBody,-2)
    AND Ref(whiteBody,-1) AND
   whiteBody AND Ref(O,-1)>Ref(O,-2) AND Ref(O,-1)<Ref(C,-2) AND
   Ref(C,-1)>Ref(C,-2) AND C>Ref(C,-1) AND
   O<Ref(C,-1) AND O>Ref(O,-1) AND Ref(LargeUpperShadow,-1) AND LargeUpperShadow
   AND C-O<Ref(C,-1)-Ref(O,-1) AND Ref(C,-1)-Ref(O,-1) < Ref(C,-2)-Ref(O,-2);
 
/*Belt Hold Bearish*/
beltHoldBearish=LargeBody AND BlackBody AND smalluppershadow AND MHT;
 
/*Breakaway Bearish*/
breakAwayBearish=Ref(LargeBody,-4) AND Ref(whiteBody,-4) AND
   Ref(GapUp(),-3) AND Ref(whiteBody,-3) AND
   Ref(smallbody,-2) AND Ref(smallBody,-1) AND
   blackBody AND O>Ref(O,-3) AND C<Ref(C,-4);
 
/*Dark Cloud Cover*/
darkCloudCover=Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND
   blackBody AND O>Ref(H,-1) AND C>Ref(O,-1) AND C<(Ref(O,-1)+Ref(C,-1))/2
   AND MHT;
 
/*Deliberation Bearish: needs confirmation*/
deliberationBearish=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
   Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND Ref(C,-1)>Ref(C,-2) AND
   smallbody AND upGap;
 
/*CounterAttackBearish*/
CounterAttackBearish=MHT AND LargeBody AND blackbody AND
   Ref(largeBody,-1) AND Ref(whiteBody,-1) AND
   C<Ref(C,-1)*1.0025 AND C>Ref(C,-1)*0.9975;;
 
/*Doji Star Bearish*/
dojiStarBearish=(dojiStar AND (MHT OR MHY))OR
   (doji AND (C>Ref(C,-1) OR O>Ref(C,-1))AND Ref(whiteBody,-1)
    AND Ref(LargeBody,-1));
 
/*Engulfing Bearish*/
engulfingBearish=engulfing AND largeBody AND blackBody AND
    (Ref(whitebody,-1) OR Ref(Doji,-1))AND (MHT OR MHY);
 
/*Evening Doji Star check formula???*/
eveningDojiStar=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
   Ref(dojiStar,-1) AND Ref(GapUp(),-1) AND (MHY OR MHT);
 
/*Evening Star*/
eveningStar=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
   Ref(upGap,-1) AND NOT Ref(largeBody,-1) AND blackBody AND NOT smallBody AND
   (MHT OR MHY);
 
/*Hammer Bearish*/
HammerBearish=Hammer AND HHV(H,8)==H;
 
/*hangingMan*/
HangingMan=NOT largeBody AND smallUpperShadow AND LargeLowerShadow AND MHT;
 
/*dragonfly Doji Bearish*/
dragonflyDojiBearish=doji AND smallUpperShadow AND LargeLowerShadow AND MHT;
    
/*Harami Bearish-*/
HaramiBearish=harami AND Ref(Largebody,-1) AND Ref(whiteBody,-1)AND blackBody
AND (MHY OR MHT);
 
/*HaramiCross Bearish*/
HaramiCrossBearish=harami AND doji AND Ref(whiteBody,-1) AND Ref(Largebody,-1);
 
/*Identical three black crows*/
idendicalThreeBlackCrows=Ref(blackBody,-2) AND Ref(blackBody,-1) AND blackBody AND
   abs(Ref(C,-2)-Ref(O,-1))<Ref(C,-1)*0.0025 AND abs(Ref(C,-1)-O)<O*0.0025 AND
   HHV(H,20)==Ref(H,-2) AND NOT Ref(doji,-2) AND NOT Ref(doji,-1) AND NOT doji AND
   Ref(smallLowerShadow,-2) AND Ref(smallLowerShadow,-1) AND smallLowerShadow;
 
/*Kicking Bearish No trades*/
kickingBearish=Ref(whiteBody,-1) AND Ref(MArabuzu,-1) AND blackBody AND MArabuzu    AND GapDown();
 
/*Meeting Lines Bearish*/
MeetingLinesBearish=Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND
  HHV(C,8)==Ref(C,-1) AND LargeBody AND blackBody AND
  abs(C-Ref(C,-1))<C*0.0025;
 
/*ShootingStar*/
shootingStarGap=shootingStar AND GapUp() AND MHT;
 
/*Gravestone Doji*/
gravestoneDoji=doji AND largeUpperShadow AND smallLowerShadow AND GapUp()AND MHT;
 
/*Three Inside Down Bearish*/
threeInsideDownBearish=Ref(HaramiBearish,-1) AND blackBody AND C<Ref(C,-1)AND    smallUpperShadow;
 
/*Three Outside Down Bearish*/
threeoutsideDownBearish=Ref(engulfingBearish,-1) AND blackBody AND C<Ref(C,-1)AND
   NOT LargeUpperShadow;
 
/*Tri Star Bearish*/
triStarBearish=Ref(doji,-2) AND Ref(doji,-1) AND doji AND MHY AND Ref(upGap,-1)AND    downGap;
 
/*Two Crows Bearish*/
twoCrows=Ref(whiteBody,-2) AND Ref(LargeBody,-2) //first day
   AND Ref(blackBody,-1) AND Ref(upGap,-1)//Second Day
   AND blackBody AND O<Ref(O,-1) AND O>Ref(C,-1)AND C<Ref(C,-2) AND
   C>Ref(O,-2) AND MHY;//Third day
 
/*Upside Gap Two Crows*/
upsideGapTwoCrows= Ref(whiteBody,-2) AND Ref(LargeBody,-2)// first day
   AND Ref(upGap,-1) AND Ref(blackBody,-1) // 2nd day
   AND blackbody AND O>Ref(O,-1) AND C<Ref(C,-1) AND C>Ref(C,-2);
 
/*Doji Star Bearish needs confirmation
dojiStarBearish=Ref(LargeBody,-1) AND Ref(whiteBody,-1) // first day
   AND doji AND upGap AND MHT;*/
 
/* Downside Gap Three Methods*/
downsideGapThreeMethods=
     Ref(LargeBody,-2) AND Ref(blackBody,-2) AND Ref(downGap,-2) //first day
     AND Ref(LargeBody,-1) AND Ref(blackBody,-1)//2nd day
     AND whitebody AND O<Ref(O,-1) AND C>Ref(C,-2)
     AND LLV(L,8)==Ref(L,-1);
 
/*Downside Tasuki Gap*/
downsideTasukiGap=
   Ref(blackBody,-2)//first day
   AND Ref(blackbody,-1) AND Ref(downgap,-1) //2nd day
   AND whiteBody AND O<Ref(O,-1) AND O>Ref(C,-1) AND C>Ref(O,-1) AND C<Ref(C,-2)
   AND Ref(identicalBodies,-1)                                                                                                                  
   AND LLV(L,15)==Ref(L,-1);
 
 
/*Falling Three Meothods*/
fallingThreeMethods=Ref(LargeBody,-4) AND Ref(blackBody,-4) AND
  /*Ref(doji,-3) AND Ref(doji,-2) AND Ref(doji,-1) AND*/ Ref(C,-1)>Ref(C,-2)
  AND Ref(C,-2)>Ref(C,-3) AND LargeBody AND blackBody AND O>Ref(C,-4) AND
  O<Ref(O,-4) AND C<Ref(O,-4)AND C<Ref(C,-4);
 
/*In Neck Bearish not good*/
inNeckBearish=Ref(LargeBody,-1) AND Ref(blackBody,-1) AND
   whiteBody AND O<Ref(L,-1) AND C<Ref(C,-1)*1.0005 AND C>=Ref(C,-1);
 
/*On Neck Bearish not good*/
OnNeckBearish=Ref(LargeBody,-1) AND Ref(blackBody,-1) AND
   whiteBody AND O<Ref(L,-1) AND C<Ref(L,-1)*1.0025 AND C>=Ref(L,-1)*0.9975;
 
/*separating Lines Bearish*/
separatingLinesBearish=Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND
   blackBody AND O>Ref(O,-1)*0.9975 AND O<=Ref(O,-1)*1.0025;
 
/*Side By Side White Lines Bearish*/
sideBySideWhiteLinesBearish=NOT Ref(smallBody,-2) AND Ref(blackBody,-2) AND 
   Ref(whiteBody,-1) AND whiteBody AND Ref(downGap,-1) AND identicalBodies
  AND abs(C-Ref(C,-1)<C*0.0025);
 
/*Three Black Crows*/
threeBlackCrows=Ref(blackBody,-2) AND Ref(blackBody,-1) AND blackBody  AND Ref(C,-1)<Ref(C,-2) AND C<Ref(C,-1) AND HHV(H,8)==Ref(H,-2) AND NOT Ref(doji,-2) AND NOT Ref(doji,-1) AND NOT doji;;
    
/*Three Line Strike no trades*/
threeLineStrike=threeBlackCrows AND whiteBody AND O<Ref(C,-1) AND C>Ref(O,-3);
 
/*Thrusting Bearish*/
thrustingBearish=Ref(blackBody,-1) AND Ref(LargeBody,-1) AND LargeBody AND
   whitebody AND O<Ref(L,-1) AND C<(Ref(O,-1)+Ref(C,-1))/2 AND C>Ref(C,-1);
 
/*Tweezer Top*/
tweezerTop= (abs(H-Ref(H,-1))/H<0.0025 OR
               abs(H-Ref(H,-2))/H<0.0025)
               AND (MHT OR MHY);
 
 
 
/* ***********************************************
                  Buy Rules
**************************************************/
Buy=
abandonedBabybullish OR
beltHoldBullish OR
breakAwayBullish OR
ConcealingBabySwallow OR
engulfingBullish OR
hammerBullish OR
dragonflyDoji OR
dojiStarBullish OR
haramiBullish OR
HaramiCross OR
homingPigeon OR
invertedHammer OR
meetingLinesbullish OR
morningDojiStar OR
morningStar OR
piercingLine OR
stickSandwich OR
threeInsideUp OR
threeOutsideUp OR
threeStarsInTheSouth OR  
triStarBullish OR
threeriverBottom OR
MAtHoldBullish OR
risingThreeMethods OR
separatingLinesBullish OR
sideBySideWhiteLines OR
threeWhiteSoldiers OR
upsideGapThreeMethods OR
threeLineStrike OR
tweezerBottom OR
upsideTasukiGap;
 
/************************************
                    Sell Rules
*************************************/
Sell=
AbandonedBabyBearish OR
advanceBlockBearish OR
beltHoldBearish OR
breakAwayBearish OR
darkCloudCover OR
deliberationBearish OR
CounterAttackBearish OR
engulfingBearish OR
eveningDojiStar OR
eveningStar OR
HangingMan OR
dragonflyDojiBearish OR
HammerBearish OR
HaramiBearish OR
HaramiCrossBearish OR
idendicalThreeBlackCrows OR
kickingBearish OR
MeetingLinesBearish OR
shootingStarGap OR
gravestoneDoji OR
threeInsideDownBearish OR
threeoutsideDownBearish OR
triStarBearish OR
twoCrows OR
upsideGapTwoCrows OR
dojiStarBearish OR
downsideGapThreeMethods OR
downsideTasukiGap OR
fallingThreeMethods OR
inNeckBearish OR
OnNeckBearish OR
separatingLinesBearish OR
sideBySideWhiteLinesBearish OR
threeBlackCrows OR
threeLineStrike OR
thrustingBearish OR
tweezerTop;
 
 
/***************************************
              Commentary
***************************************
            Bullish Candles
****************************************/
WriteIf(Buy,"Bullish\n=======\n","")+
WriteIf(abandonedBabybullish,"Abandoned Baby Bullish. \nA reversal pattern.\n\\c16LiWick reliability : High.","")+
WriteIf(beltHoldBullish,"Belt Hold Bullish. \nA reversal pattern.\nNison:The larger the candlestick, the more significant it is.\nLitWick Reliability: Low.","")+ 
WriteIf(breakAwayBullish,"Break Away Bullish. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(ConcealingBabySwallow,"Concealing Baby Swallow. \nA reversal pattern.\n LitWick reliability: high.","")+
WriteIf(dojiStarBullish,"Bullish doji Star. A reversal pattern.\nNison: Needs confirmation. Better at calling tops.\nLitWick reliability: moderate.","")+
WriteIf(engulfingBullish,"Bullish Engulfing. \nA reversal pattern.\nNison: Factors increasing the pattern's effectiveness are\n1) The first day has a small real body and the second day has a large real body.\n2) Pattern appears after protracted or very fast move.\n3) Heavy volume on second real body.\n4) The second day engulfs more than one real body.\nLitWick reliability: moderate","")+ 
WriteIf(hammerBullish,"Bullish Hammer. \nA reversal pattern.\nNison: The longer the lower shadow, the smaller the upper shadow, and the smaller the real body, the more significant the pattern.White real body more bullish than black body.\nLitWick reliability: low.","")+
WriteIf(dragonflyDoji,"Dragonfly Doji. \nLitWick reliability: moderate.","")+
WriteIf(haramiBullish, "Harami Bullish. \nA reversal pattern.\nNison: Less significant. Pattern needs confirmation.\nLitWick reliability: low.","")+
WriteIf(HaramiCross,"Harami Cross. \nA reversal pattern.\nNison: Better indicator than Harami. Better at calling tops than bottoms.\nLitWick reliability: low.","")+
WriteIf(homingPigeon,"Homing Pigeon. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(invertedHammer,"Inverted Hammer. \nA reversal pattern.\nNison:Needs bullish verification.\nLitWick reliability: low.","")+
WriteIf(meetingLinesbullish,"Meeting Lines bullish. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(morningDojiStar,"Morning Doji Star. \nA reversal pattern.\nImportant reversal signal.\nLitWick reliability: high.","")+
WriteIf(morningStar,"Morning Star. \nA reversal pattern.\nNison: The stronger the white third body the better.\nLitWick reliability: high.","")+
WriteIf(piercingLine,"Piercing Line. \nA reversal pattern.\nNison: A stron reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(stickSandwich,"Stick Sandwich. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(threeInsideUp,"3 Inside Up. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(threeOutsideUp,"3 Outside Up. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(threeStarsInTheSouth,"3 Stars in the South. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(triStarBullish,"Tri-Star Bullish. \nA reversal pattern.\nNison: Significant reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(threeriverBottom,"3 River Bottom. \nA reversal pattern.\nNison: Selling pressure drying up.\nLit Wick reliability: moderate.","")+
WriteIf(MAtHoldBullish,"Mat Hold Bullish. \nA continuation pattern.\nNison: May have 2-4 black candles.\nLitWick reliability: high. ","")+
WriteIf(risingThreeMethods,"Rising Three Methods. \nA continuation pattern>\nNison: Has more significance if volume of white candle sticks is greater than on black candlesticks.\nLitWick reliability: high.","")+
WriteIf(separatingLinesBullish,"Separating Lines Bullish. \nA continuation pattern.\nNison:    \nLitWick reliability: low.","")+
WriteIf(sideBySideWhiteLines,"Side by Side White Lines. \nA continuation pattern.\nNison: If occurring during a downtrend may only be short covering.\nLitWick reliability: high.","")+
WriteIf(threeWhiteSoldiers,"3 White Soldiers. \nA continuation pattern.\nNison: Positive, but be aware of negative similar stalled pattern and advance block pattern.\nLitWick reliability: high.","")+
WriteIf(upsideGapThreeMethods,"Upside Gap 3 Methods. \nA continuation pattern.\nLitWick reliability: moderate.","")+
WriteIf(threeLineStrike,"3 Line Strike. \nA continuation pattern.\nLitWick reliability: low.","")+
WriteIf(tweezerBottom,"Tweezer Bottom.\nA reversal pattern. With other reversal candles it could indicate a support level.\nNison: Needs confirmation.","")+
WriteIf(upsideTasukiGap,"Upside Tasuki Gap. \nA continuation pattern.\nNison: the real bodies of the two candlesticks in the gap should be about the same size.\nLitWick reliability: moderate.","")+
WriteIf(Buy,"\n-------------------------------------------","");;                                      /***************************************
                 Bearish Candles
********************************************/
WriteIf(Sell,"Bearish\n=======\n","")+
WriteIf(AbandonedBabyBearish,"Abandoned Baby Bearish. \nA reversal pattern.\nNison: Extremely rare.\nLitWick reliability: high.","")+
WriteIf(advanceBlockBearish,"Advancing Block Bearish. \nA reversal pattern.\nNison: Rally is in trouble. Signs of weakening could be progressively smaller white read bodies or relatibvely long upper shadows on the last two white candlesticks.Not necessarily a reversal pattern.\nLitWick Reliability: moderate.","")+
WriteIf(beltHoldBearish,"Belt Hold Bearish. \nA reversal pattern.\nNison: The longer the height of the belt-hold candle the more significant the pattern.\nLitWick reliability: low.","")+
WriteIf(breakAwayBearish,"Break Away Bearish. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(darkCloudCover,"Dark Cloud Cover. \nA reversal pattern.\nNison: Factors indicating the importance of this signal are/n1)The greater the penetration of the first candle by the second.\n2)Both candles are marabozus.\n3)The second body opens above a major resistance level.\n4)High volume on the second day.\nLitWick Reliability: high.","")+
WriteIf(deliberationBearish,"Deliberation Bearish. \nA reversal pattern.\nNison: Not a reversal pattern, but a sign the rally is weakening.\nLitWick reliability: moderate.","")+
WriteIf(CounterAttackBearish,"Counter Attack Bearish.\nNison: A potential stalling of the rally.","")+
WriteIf(engulfingBearish,"Engulfing Bearish. \nA reversal pattern.\nNison: Major reversal signal. Factors increasing patterns importance are\n1) The first day has a very small real body and the second day a very large real body.\n2) The pattern apears after a protracted or very fast move.\n3) Heavy volume on the second day.\n4) The second day engulfs more than one real body.\nLitWick reliability: moderate.","")+
WriteIf(eveningDojiStar,"Evening Doji Star \nA reversal pattern.\nNison: Must be confirmed by long black candle.\nLit Wick reliability: high","")+
WriteIf(eveningStar,"Evening Star. \nA reversal pattern.\nNison: Gap between Second AND third bodies does NOT always occur.\nLitWick reliability: High.","")+
WriteIf(HammerBearish,"Bearish Hammer. \nA reversal pattern.\nNison: More bearish if hammer is black. Needs bearish confirmation. A large gap down on the following day would be a good confirmation.","")+
WriteIf(HangingMan,"Hanging Man. \nA reversal pattern.\nNison: Same as bearish hammer with a large gap down the following day.\nLitWick reliability: low.","")+
WriteIf(dragonflyDojiBearish,"Dragonfly Bearish. \nA reversal pattern.\nNison: Same as Hanging Man.\nLitWick reliability: moderate.","")+
WriteIf(HaramiBearish,"Harami Bearish. \nA reversal pattern.\nNison: Not as significant a reversal pattern as hanging man or engulfing.\nLitWick reliability: low.","")+
WriteIf(HaramiCrossBearish,"Harami Cross Bearish. \nA reversal pattern.\nNison: More significant reversal pattern than Harami. Second day can be white or black.\nLitWick reliability: moderate.","")+
WriteIf(idendicalThreeBlackCrows,"Identical 3 Black Crows. \nA reversal pattern in an uptrend.\nNison:Very bearish.\nLitWick reliability: high. ","")+
WriteIf(kickingBearish,"Kicking Bearish. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(MeetingLinesBearish,"Meeting Lines Bearish. \nA reversal pattern.\nNison:  \nLitWick reliability: moderate, but not as strong as Dark cloud Cover.","")+
WriteIf(shootingStarGap,"Shooting Star. \nA reversal pattern.\nNison:Not major reversal signal as evening star. Ideally real body would gap away from previous body. Needs to appear after an uptrend.\nLitWick reliability: low.","")+
WriteIf(gravestoneDoji,"Gravestone Doji. \nA reversal pattern.\nNison: more significant if it hits new high.\nLitWick reliability: moderate.","")+
WriteIf(threeInsideDownBearish,"3 Inside Down. \nA reversal pattern.\nNison:  \nLitWick reliability: high.","")+
WriteIf(threeoutsideDownBearish,"3 Outside Down. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(triStarBearish,"Tri-Star Bearish. \nA reversal pattern.\nNison: Very significant reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(twoCrows,"2 Crows. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(upsideGapTwoCrows,"Upside Gap 2 Crows. \nA reversal pattern.\nNison:Needs confirmation of a continued reversal on third day.\nLitWick reliability: high.","")+
WriteIf(dojiStarBearish,"Doji Star Bearish. \nA reversal pattern.\nNison: needs confirmation.\nLitWick reliability: moderate.","")+
WriteIf(downsideGapThreeMethods,"Downside Gap 3 Methods. A continuation pattern.\nNison: \nLitWick reliability: moderate.","")+
WriteIf(downsideTasukiGap,"Downside Tasuki Gap. \nA continuation method.\nNison: If last day closes window, continuation pattern is negated.\nLitWick reliability: moderate.","")+
WriteIf(fallingThreeMethods,"Falling 3 Methods. \nA continuation pattern.\nNison:  \nLitWick reliability: high.","")+
WriteIf(inNeckBearish,"In Neck Bearish. A continuatin pattern.\nNison: Similar to piercing pattern but bearish because there is no penetration of second day.\nLitWick reliability: moderate.","")+
WriteIf(OnNeckBearish,"On Neck Bearish. \nA continuation pattern. Similar to piercing pattern but bearish beccause there is no penetration of the second day.\nLitWick reliability: moderate.","")+
WriteIf(separatingLinesBearish,"Separating Lines Bearish","");
WriteIf(sideBySideWhiteLinesBearish,"Side by Side White Lines Bearish. \nA continuation pattern.\nNison: very rare.\nLitWick reliability: moderate.","")+
WriteIf(threeBlackCrows,"3 Black Crows. \nA reversal pattern.\nNison: Need to appear after a mature advance.\nLitWick reliability: high.","")+ 
WriteIf(threeLineStrike,"3 Line Strike. \nA continuation pattern.\nLitWick reliability: low.","")+
WriteIf(thrustingBearish,"Thrusting. \nA continuation pattern.\nNison: Not a reversal day because second day does not pierce midpoint of first day.\nLitWick reliability: low.","")+
WriteIf(tweezerTop,"Tweezer Top. \nA reversal pattern.\nNison: Needs confirmation.","")+
WriteIf(Sell,"\n---------------------------------------------------","");

/***********************************************
               End Commentary
************************************************/
_SECTION_END();


_SECTION_END();

_SECTION_BEGIN("VSA by Mr.Karthik");

DTL=Param("Linear regression period",60,10,100,10);

wbf=Param("WRB factor",1.5,1.3,2.5,.1);

nbf=Param("NRB factor",0.7,0.3,0.9,0.1);

TL=LinRegSlope(MA(C, DTL),2);

 Vlp=Param("Volume lookback period",30,20,300,10);

Vrg=MA(V,Vlp);

St = StDev(Vrg,Vlp);

Vp3 = Vrg + 3*st;

Vp2 = Vrg + 2*st;;

Vp1 = Vrg + 1*st;;

Vn1 = Vrg -1*st;

Vn2 = Vrg -2*st;

rg=(H-L);

arg=Wilders(rg,30);

wrb=rg>(wbf*arg);

nrb=rg<(nbf*arg);

Vl=V<Ref(V,-1) AND V<Ref(V,-2);

upbar=C>Ref(C,-1);

dnbar=C<Ref(C,-1);

Vh=V>Ref(V,-1) AND Ref(V,-1)>Ref(V,-2);

Cloc=C-L;

x=rg/Cloc;

x1=IIf(Cloc==0,arg,x);

Vb=V>Vrg OR V>Ref(V,-1);

ucls=x1<2;

dcls=x1>2;

mcls=x1<2.2 AND x1>1.8 ;

Vlcls=x1>4;

Vhcls=x1<1.35;

j=MA(C,5);

TLL=LinRegSlope(j,40) ;

Tlm=LinRegSlope(j,15) ;

tls=LinRegSlope(j,5);

mp=(H+L)/2;

 

Pp1=Param("NumberOfDays",30,1,200,1);

Pp2=Param("VolOfDays",15,1,200,1);

 

numDays = Pp1;

dwWideSpread = 1.8;

dwNarrowSpread = 0.8;

dwSpreadMiddle = 0.5;

dwHighClose = 0.7;

dwLowClose = 0.3;

 

volNumDays = Pp2;

dwUltraHighVol = 2;

dwVeryHighVol = 1.75; // was 1.8

dwHighVol = 1.75; // was 1.8

dwmoderateVol = 1.10; // was 1.8

dwLowVol = 0.75; // was 0.8

 

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

// Classify each bar...

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

 

upBar = C > Ref(C,-1);

downBar = C < Ref(C,-1);

spread = H-L;

avgRange = Sum(spread, numDays) / numDays;

wideRange = spread >= (dwWideSpread * avgRange);

narrowRange = spread <= (dwNarrowSpread * avgRange);

testHighClose = L + (spread * dwHighClose);

testLowClose = L + (spread * dwLowClose);

testCloseMiddle = L + (spread * dwSpreadMiddle);

 

upClose = C > testHighClose;

downClose = C < testLowClose;

middleClose = C >= testLowClose AND C <= testHighClose;

 

avgVolume = EMA(V, volNumDays);

 

highVolume = V > (avgVolume * dwHighVol);

moderateVol= V > (avgVolume * dwmoderateVol);

veryHighVolume = V > (avgVolume * dwVeryHighVol);

ultraHighVolume = V > (avgVolume * dwUltraHighVol);

LowVolume = V < (avgVolume * dwLowVol);

 

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

// direction and title

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

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

//

// Basic patterns...

//

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

 

upThrustBar = downClose AND H > Ref(H,-1) AND (C == L) AND downClose AND (NOT narrowRange);

noDemandBar = narrowRange AND LowVolume AND upBar AND (NOT upClose);

//noDemandBar = narrowRange AND LowVolume AND upBar AND (V < Ref(V,-1)) AND (V < Ref(V,-2));

noSupplyBar = narrowRange AND LowVolume AND downBar AND (V < Ref(V,-1)) AND (V < Ref(V,-2));

absorption = Ref(downbar, -1) AND Ref(highVolume, -1) AND upBar;

support = Ref(downBar,-1) AND (NOT Ref(downClose,-1)) AND Ref(highVolume,-1) AND upBar;

stoppingVolume = Ref(downBar,-1) AND Ref(highVolume,-1) AND C > testCloseMiddle AND (NOT downBar);

bullishsign=moderateVol+UpThrustBar;//OR moderateVol+upBar;

//rallyEnd = (Ref(highVolume,-1) AND Ref(upBar,-1) AND wideRange AND downBar) OR

// (narrowRange AND highVolume AND H > Ref(HHV(H, 250), -1));

 

 

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

//

// Strength and Weakness

//

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

 

weakness = upThrustBar OR noDemandBar OR (narrowRange AND (H > Ref(H,-1)) AND highVolume) OR (Ref(highVolume,-1) AND Ref(upBar,-1) AND downBar AND (H < Ref(H,-1)));

 

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

 

C1 = Ref(C, -1);

uc = C > C1; dc = C <= C1;

ud = C > O; dd = C <= O;

 

green = 1; blue = 2; yellow = 3; red = 4; white = 5;

VType = IIf(ud, IIf(uc, green, yellow), IIf(dd,IIf(dc, red, blue), white));

 

/* green volume: up-day and up-close*/

gv = IIf(VType == green, V, 0);

/* yellow volume: up-day but down-close */

yv = IIf(VType == yellow, V, 0);

/* red volume: down-day and down-close */

rv = IIf(VType == red, V, 0);

/* blue volume: down-day but up-close */

bv = IIf(VType == blue, V, 0);

 

uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */

dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */

 

/* create moving average period parameters */

VolPer = Param("Adjust Vol. MA per.", 34, 1, 255, 1);

ConvPer = Param("Adjust Conv. MA per.", 9, 1, 255, 1);

 

/* create triple exponential moving avearges of separate up and down volume

moving averages */

MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);

MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);

MAtv = TEMA(V, VolPer );//total volume

 

/* Switch for Horizontal lines indicating current level of positive and

negative volume for ease in comparing to past highs/lows - toggle via

parmameter window */

OscillatorOnly = Param("Show Oscillator Only", 0, 0, 1, 1);

CompareBullVolume = Param("Show Bull Level", 1, 0, 1, 1);

if(CompareBullvolume AND !OscillatorOnly){

//Plot(SelectedValue(MAuv), "", colorGreen, styleLine);

}

 

CompareBearVolume = Param("Show Bear Level", 1, 0, 1, 1);

if(CompareBearVolume AND !OscillatorOnly){

//Plot(SelectedValue(MAdv), "", colorRed, styleLine);

}

 

/* Volume Segment Switches - toggle via parameter window */

bullvolume = Param("Show Bull Volume", 1, 0, 1, 1);

bearvolume = Param("Show Bear Volume", 1, 0, 1, 1);

totalvolume = Param("Show Total Volume", 1, 0, 1, 1);

 

/* plot volume lines and histograms if toggled on: */

bearToFront = Param("Show Bear Vol in Front", 0, 0, 1, 1);

if(bearToFront AND !OscillatorOnly){

//Plot(MAdv, "", colorRed, styleHistogram|styleNoLabel);

}

if(bullvolume AND !OscillatorOnly){

//Plot(MAuv, "Average Bull Volume", colorGreen, styleHistogram|styleNoLabel);

}

if(bearvolume AND !OscillatorOnly){

//Plot(MAdv, "Average Bear Volume", colorRed, styleHistogram|styleNoLabel);

}

if(totalVolume AND !OscillatorOnly){

//Plot(MAtv, "Total Volume", colorWhite, styleHistogram|styleNoLabel);

//Plot(MAtv, "", colorWhite, styleLine);

}

if(bullvolume AND !OscillatorOnly){

//Plot(MAuv, "", colorGreen, styleLine);

}

if(bearvolume AND !OscillatorOnly){

//Plot(MAdv, "", colorRed, styleLine);

}

 

/* better visibility of zero line: */

//Plot(0, "", colorBlue, 1);

 

/* Rise/Fall Convergence variables:  */

Converge = (TEMA(MAuv - MAdv, ConvPer));

Converge1 = Ref(Converge, -1);

ConvergeUp = Converge > Converge1;

ConvergeOver = Converge > 0;

rising = ConvergeUp AND ConvergeOver;

falling = !ConvergeUp AND ConvergeOver;

 

/* Rise/Fall Convergence Oscillator Switch  - toggle via parameter window - (provides a better view of resulting combination of battling bull/bear volume forces) */

convergenceOscillator = Param("Show Oscillator", 0, 0, 1, 1);

if(convergenceOscillator OR OscillatorOnly){

//Plot(Converge, "Bull/Bear Volume Convergence/Divergence", colorViolet,1|styleLeftAxisScale|styleNoLabel|styleThick);

//Plot(0,"", colorYellow, 1|styleLeftAxisScale|styleNoLabel);

}

 

/********************************************************

 Convergence Rise/Fall Shadows:

 

 (provides a more easily visible display of rising and falling  bull/bear

volume convergence) - toggle via parameter window

 

-posiitive Volume exceeding negative Volume: Light shadow

-negative volume exceeding positive volume: dark shadow

-if you use standard gray background - best shadows are:

-my greys: 14 = (216, 216, 216); 15 = (168, 168, 168));

-best substitute? using AB color constants?

-light: colorpalegreen; dark: colorRose;?

-(depends on your color scheme - customize to your tastes)

**********************************************************/

 

/* uncomment if you use my custom color greys: */

riseFallColor = IIf(rising, 14,15); //my custom shadow greys

 

/* comment out if you use my custom color gray shadows: */

/* riseFallColor = IIf(rising, colorPaleGreen,colorRose); */

 

/* Rise/Fall Convergence Plot Switch - toggle via parameter window */

riseFallShadows = Param("Show RiseFallShadows", 0, 0, 1, 1);

if(riseFallShadows){

//Plot(IIf(rising OR falling, 1, 0), "", riseFallColor,styleHistogram|styleArea|styleOwnScale|styleNoLabel);

}

_SECTION_END();

_SECTION_BEGIN("Pivot Finder");
 
/***********************************
 
Code to automatically identify pivots
 
***********************************/
 
// -- what will be our lookback range for the hh and ll?
farback=Param("How Far back to go",100,50,5000,10);
nBars = Param("Number of bars", 12, 5, 40);
 
 
"BIdxJJJ = " + BarIndex() +
 
"\n" + "OGGGGGGGGGGG = " + O + "\n"+"H = "+ H + "\n"+"L = " + L
 
+ "\n"+"C " ;
 
GraphXSpace=7;
 
// -- Create 0-initialized arrays the size of barcount
 
aHPivs = H - H;
 
aLPivs = L - L;
 
// -- More for future use, not necessary for basic plotting
 
aHPivHighs = H - H;
 
aLPivLows = L - L;
 
aHPivIdxs = H - H;
 
aLPivIdxs = L - L;
 
nHPivs = 0;
 
nLPivs = 0;
 
lastHPIdx = 0;
 
lastLPIdx = 0;
 
lastHPH = 0;
 
lastLPL = 0;
 
curPivBarIdx = 0;
 
aHHVBars = HHVBars(H, nBars);
 
aLLVBars = LLVBars(L, nBars);
 
aHHV = HHV(H, nBars);
 
aLLV = LLV(L, nBars);
 
aVisBars = Status("barvisible");
 
nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
 
_TRACE("Last visible bar: " + nLastVisBar);
 
// -- Initialize value of curTrend
 
curBar = (BarCount-1);
 
curTrend = "";
 
if (aLLVBars[curBar] <
 
aHHVBars[curBar]) {
 
curTrend = "D";
 
}
 
else {
 
curTrend = "U";
 
}
 
 
 
 
if (BarCount > farback)
{
for (i=0; i<farback; i++) {
 
curBar = (BarCount - 1) - i;
 
// -- Have we identified a pivot? If trend is down...
 
if (aLLVBars[curBar] < aHHVBars[curBar]) {
 
// ... and had been up, this is a trend change
 
if (curTrend == "U") {
 
curTrend = "D";
 
// -- Capture pivot information
 
curPivBarIdx = curBar - aLLVBars[curBar];
 
aLPivs[curPivBarIdx] = 1;
 
aLPivLows[nLPivs] = L[curPivBarIdx];
 
aLPivIdxs[nLPivs] = curPivBarIdx;
 
nLPivs++;
 
}
 
// -- or current trend is up
 
} else {
 
if (curTrend == "D") {
 
curTrend = "U";
 
curPivBarIdx = curBar - aHHVBars[curBar];
 
aHPivs[curPivBarIdx] = 1;
 
aHPivHighs[nHPivs] = H[curPivBarIdx];
 
aHPivIdxs[nHPivs] = curPivBarIdx;
 
nHPivs++;
 
}
 
// -- If curTrend is up...else...
 
}
 
// -- loop through bars
 
}
}
  
 
curBar = (BarCount-1);
 
candIdx = 0;
 
candPrc = 0;
 
lastLPIdx = aLPivIdxs[0];
 
lastLPL = aLPivLows[0];
 
lastHPIdx = aHPivIdxs[0];
 
lastHPH = aHPivHighs[0];
 
if (lastLPIdx > lastHPIdx) {
 
// -- Bar and price info for candidate pivot
 
candIdx = curBar - aHHVBars[curBar];
 
candPrc = aHHV[curBar];
 
if (
 
lastHPH < candPrc AND
 
candIdx > lastLPIdx AND
 
candIdx < curBar) {
 
 
// -- OK, we'll add this as a pivot...
 
aHPivs[candIdx] = 1;
 
// ...and then rearrange elements in the
 
// pivot information arrays
 
for (j=0; j<nHPivs; j++) {
 
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-
 
(j+1)];
 
aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];
 
}
 
aHPivHighs[0] = candPrc ;
 
aHPivIdxs[0] = candIdx;
 
nHPivs++;
 
}
 
} else {
 
 
// -- Bar and price info for candidate pivot
 
candIdx = curBar - aLLVBars[curBar];
 
candPrc = aLLV[curBar];
 
if (
 
lastLPL > candPrc AND
 
candIdx > lastHPIdx AND
 
candIdx < curBar) {
 
 
// -- OK, we'll add this as a pivot...
 
aLPivs[candIdx] = 1;
 
for (j=0; j<nLPivs; j++) {
 
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
 
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
 
}
 
aLPivLows[0] = candPrc;
 
aLPivIdxs[0] = candIdx;
 
nLPivs++;
 
}
 
}
 
//PlotShapes(IIf(aHPivs==1,shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-15);
//PlotShapes(IIf(aLPivs==1,shapeUpArrow , shapeNone), ColorRGB(168,255,0), 0, Low, Offset=-15);
 
//printf("\n Buuuy pivotss %g", aLPivs);
//printf("\n Seel pivotss %g \n",aHPivs);
 
IIf( (aHPivs==1 AND aLPivs==0),PIVOT_SELL = 5, PIVOT_SELL = 0 );
IIf( aLPivs==1 AND aHPivs==0, PIVOT_BUY = 0, PIVOT_BUY = 5 );
  
PIVOT_BUY  = IIf(aLPivs==1, 5, 0);
PIVOT_SELL = IIf(aHPivs==1, 5, 0);
 
//printf("\n Buy pivots %g", PIVOT_BUY);
//printf("\n Sell pivots %g \n",PIVOT_SELL);
 
PIVOT_status = WriteIf(PIVOT_BUY,"Buy["+PIVOT_BUY+"]",WriteIf(PIVOT_SELL,"Sell["+PIVOT_SELL+"]","NA"));
PIVOT_col = IIf (PIVOT_BUY,colorGreen, IIf (PIVOT_SELL,colorRed,colorLightGrey));
 
_SECTION_END();

/**********************************************************
 /ADX        
***********************************************************/
 
range = Param("Range",14,3,60,1);
 
px = PDI(range);
nx = MDI(range);
ax = ADX(range);
 
Line_Control = 20;
 
up_adx = Ref(ADX(range),-1) < ADX(range);
dw_adx = Ref(ADX(range),-1) > ADX(range);
 
// ADX Trends

Notrend = ADX(range) < 20;
 
ModerateTrend =  ADX(range) >= 20 AND ADX(range) < 40 AND up_adx ;
StrongTrend =  ADX(range) >= 40 AND ADX(range) < 60 AND up_adx ;
VeryStrongTrend =  ADX(range) >= 60 AND ADX(range) < 80 AND up_adx ;
ExtremelyStrongTrend =  ADX(range) >= 80 AND up_adx ;
 
// Buy Conditions
 
bcon1 = Cross(px,ax) AND nx < px AND  ax > Ref(ax,-1);
scon1 = Cross(nx,ax) AND px < nx AND ax > Ref(ax,-1);
 
adbuy = ax < 20 AND ax > Ref(ax,-1) AND ( Cross(px,nx) OR nx < px) ;
adsell = ax < 20 AND ax > Ref(ax,-1) AND ( Cross(nx,px) OR nx > px) ;
 
adbuy1 = Cross(px,ax) AND nx < px AND  ax > Ref(ax,-1) AND px > ax;
adsell1 = Cross(nx,ax) AND nx > px AND  ax > Ref(ax,-1) AND nx > ax;
 
BUY_ADX = bcon1 + adbuy + adbuy1;
SELL_ADX =  scon1 + adsell + adsell1;
 
ADX_status = WriteIf(BUY_ADX,"Buy["+BUY_ADX+"]",WriteIf(SELL_ADX,"Sell["+SELL_ADX+"]","NA"));
ADX_col = IIf (BUY_ADX,colorGreen, IIf (SELL_ADX,colorRed,colorLightGrey));
 
 
/**********************************************************
 /MACD Cross
***********************************************************/
_SECTION_BEGIN("MACD");
MACD_TOGGLE = ParamToggle("Plot MACD","Off|On",0);
 
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
 
m1 = MACD(r1, r2);
s1 = Signal(r1,r2,r3);
difference = m1-s1;
 
 
mycolor=IIf(m1<0 AND m1>s1,51,IIf(m1>0 AND m1>s1,colorBrightGreen,IIf(m1>0 AND m1<s1,colorLightOrange,colorRed)));
 
// **********************
//MACD crossing zero
 
B_MACD_0 =  Cross(MACD(r1, r2),0);
S_MACD_0 =  Cross(0,MACD(r1, r2));
 
// **********************
//Bullish - Bearish MACD crossing signal above zero or below zero plane
 
 
BULL_CROSS_ABOVE_ZERO = Cross (MACD(r1, r2),Signal(r1,r2,r3)) AND MACD(r1, r2) > 0;
BEAR_CROSS_ABOVE_ZERO = Cross (Signal(r1,r2,r3),MACD(r1, r2)) AND MACD(r1, r2) > 0;
 
// **********************
//bELOW ZERO Bullish - Bearish MACD crossing signal above zero or below zero plane
 
BULL_CROSS_BELOW_ZERO  = Cross (MACD(r1, r2),Signal(r1,r2,r3)) AND MACD(r1, r2)<0;
BEAR_CROSS_BELOW_ZERO  = Cross(Signal(r1,r2,r3),MACD(r1, r2)) AND MACD(r1, r2)<0;
 
// **********************
//Zero line reject ZLR
 
BEAR_ZLR = BarsSince(B_MACD_0);
BEAR_ZLR1 = (BEAR_ZLR < 6) AND (S_MACD_0);
 
BULL_ZLR = BarsSince(S_MACD_0);
BULL_ZLR1 = (BULL_ZLR < 6) AND (B_MACD_0);
 
// **********************
//HOOKS
 
BULL_HOOK1 = BarsSince(BEAR_CROSS_ABOVE_ZERO);
BULL_HOOK = (BULL_HOOK1<6) AND BULL_CROSS_ABOVE_ZERO ;

BEAR_HOOK1 = BarsSince(BULL_CROSS_ABOVE_ZERO);
BEAR_HOOK = (BEAR_HOOK1<6) AND BEAR_CROSS_ABOVE_ZERO ;
 
BUY_MACD = B_MACD_0 + BULL_CROSS_ABOVE_ZERO + BULL_CROSS_BELOW_ZERO + BULL_ZLR1 + BULL_HOOK;
SELL_MACD = S_MACD_0 + BEAR_CROSS_ABOVE_ZERO + BEAR_CROSS_BELOW_ZERO + BEAR_ZLR1 + BEAR_HOOK;
 
/*
if(MACD_TOGGLE==1)
{
GraphX = 5;
Plot( m1, StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ),ParamStyle("MACD style") );
Plot( s1 ,"Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlueGrey ), ParamStyle("Signal style") );
  
Color =IIf(difference > 0,colorLime,colorRed);
 
Plot(m1-s1, "MACD Histogram", mycolor, styleHistogram | styleThick | styleNoLabel, styleOwnScale);
 
PlotShapes(IIf(B_MACD_0,shapeDigit1 ,Null),colorYellow,0,Min(0,0),Min(0,0));
PlotShapes(IIf(B_MACD_0,shapeUpArrow,Null),colorGreen,0,Min(0,0),-20);
 
PlotShapes(IIf(S_MACD_0,shapeDigit2 ,Null),colorOrange,0,Min(0,0),0);
PlotShapes(IIf(S_MACD_0,shapeDownArrow,Null),colorRed,0,Min(0,0),-20);
 
PlotShapes(IIf(BULL_CROSS_ABOVE_ZERO,shapeDigit3 ,Null),colorYellow,0,Min(0,0),Min(0,0));
PlotShapes(IIf(BULL_CROSS_ABOVE_ZERO,shapeUpArrow,Null),colorGreen,0,Min(0,0),-20);
 
PlotShapes(IIf(BEAR_CROSS_ABOVE_ZERO ,shapeDigit4 ,Null),colorOrange,0,Min(0,0),Min(0,0));
PlotShapes(IIf(BEAR_CROSS_ABOVE_ZERO ,shapeDownArrow,Null),colorRed,0,Min(0,0),-20);
 
PlotShapes(IIf(BULL_CROSS_BELOW_ZERO,shapeDigit5 ,Null),colorYellow,0,Min(0,0),Min(0,0));
PlotShapes(IIf(BULL_CROSS_BELOW_ZERO,shapeUpArrow,Null),colorGreen,0,Min(0,0),-20);
 
PlotShapes(IIf(BEAR_CROSS_BELOW_ZERO,shapeDigit6 ,Null),colorOrange,0,Min(0,0),Min(0,0));
PlotShapes(IIf(BEAR_CROSS_BELOW_ZERO,shapeDownArrow,Null),colorRed,0,Min(0,0),-20);
 
PlotShapes(IIf(BEAR_ZLR1,shapeStar+shapePositionAbove,shapeNone),colorRed,0,0,-30);
PlotShapes(IIf(BULL_ZLR1,shapeStar+shapePositionAbove,shapeNone),colorGold,0,0,30);
 
PlotShapes(IIf(BULL_HOOK,shapeStar+shapePositionAbove,shapeNone),colorGold,0,0,30);
PlotShapes(IIf(BEAR_HOOK,shapeStar+shapePositionAbove,shapeNone),colorRed,0,0,-30);
}
*/
_SECTION_END();
 
BUY_MACD = B_MACD_0 + BULL_CROSS_ABOVE_ZERO + BULL_CROSS_BELOW_ZERO + BULL_ZLR1 + BULL_HOOK ;
SELL_MACD = S_MACD_0 + BEAR_CROSS_ABOVE_ZERO + BEAR_CROSS_BELOW_ZERO + BEAR_ZLR1 + BEAR_HOOK ;
 
MACD_status = WriteIf(BUY_MACD,"Buy["+BUY_MACD+"]",WriteIf(SELL_MACD,"Sell["+SELL_MACD+"]","NA"));
MACD_col = IIf (BUY_MACD,colorGreen, IIf (SELL_MACD,colorRed,colorLightGrey));
 
/**************************************************
                Stochastics
***************************************************/
_SECTION_BEGIN("STOCHASTICS");
STOC_TOGGLE = ParamToggle("Plot STOCHASTICS","Off|On",0);
 
SP = Param( "Periods", 10, 1, 200, 1 );
Ksmooth = Param( "%K avg", 5, 1, 200, 1 );
Dsmooth = Param( "%D avg", 5, 1, 200, 1 );
StochDval = StochD( SP , Ksmooth, DSmooth );
StochKval = StochK( SP , Ksmooth);
 
Overbought = 80;
Oversold = 20;
 
/*
if(STOC_TOGGLE==1)
{
GraphX = 5;
Plot( StochD( SP , Ksmooth, DSmooth), _DEFAULT_NAME(), ParamColor( "ColorD", colorTurquoise ), ParamStyle("Style") );
Plot( StochK( SP , Ksmooth), _DEFAULT_NAME(), ParamColor( "ColorK", colorPaleGreen ), ParamStyle("Style") );
 
Plot(Overbought,"Overbought Level",colorRed);
Plot(Oversold,"Oversold Level",colorGreen);
}
*/
 
StochBuy = Cross(StochK(SP,Ksmooth), StochD(SP,Ksmooth, DSmooth)) AND
(StochD(SP,Ksmooth, DSmooth) > 20) AND (StochK(SP,Ksmooth) > 20) AND
(StochD(SP,Ksmooth, DSmooth) < 80) AND (StochK(SP,Ksmooth) < 80);
 
StochSell = Cross (StochD(SP,Ksmooth, DSmooth), StochK(SP,Ksmooth)) AND
(StochD(SP,Ksmooth, DSmooth) > 20) AND (StochK(SP,Ksmooth) > 20) AND
(StochD(SP,Ksmooth, DSmooth) < 80) AND (StochK(SP,Ksmooth) < 80);
 
StochStrongBuy = Cross(StochK(SP,Ksmooth),StochD(SP,Ksmooth, DSmooth)) AND
(StochD(SP,Ksmooth, DSmooth) < 20) AND (StochK(SP,Ksmooth) < 20) ;
 
StochStrongSell = Cross (StochD(SP,Ksmooth,DSmooth), StochK(SP , Ksmooth));
(StochD(SP,Ksmooth, DSmooth) > 80) AND (StochK(SP,Ksmooth) > 80);
 
BUY_STOCH = StochBuy + StochStrongBuy;
SELL_STOCH = StochSell + StochStrongSell;
printf("sto %g",BUY_STOCH);
 
_SECTION_END();
 
STOCH_status = WriteIf(BUY_STOCH,"Buy["+BUY_STOCH+"]",WriteIf(SELL_STOCH,"Sell["+SELL_STOCH+"]","NA"));
STOCH_col = IIf (BUY_STOCH,colorGreen, IIf (SELL_STOCH,colorRed,colorLightGrey));
 
/**************************************************
                TREND DETECTOR
***************************************************/
 
_SECTION_BEGIN("Trend Detector");
TREND_TOGGLE = ParamToggle("Plot Trend","Off|On",0);
A = (H+C+L)/3;
B=MA(A,5)-EMA(A,34);
D = EMA(A,34)-MA(A,5);
Bcolor=IIf(B>D,25,39);
Dcolor=IIf(D<B,25,39);
Up = B > D;
down = B < D;
TREND_B = Cross(B,D);
TREND_S = Cross(D,B);
if(TREND_TOGGLE==1)
{
Plot(B,"B ",Bcolor,styleLine|styleThick);
Plot(D,"D ",Dcolor,styleLine|styleThick);
Plot(B,"",Bcolor,styleHistogram|styleThick);
Plot(D,"",Dcolor,styleHistogram|styleThick);
Plot(0,"",colorWhite,styleLine);
PlotShapes(IIf(TREND_S, shapeHollowDownArrow , shapeNone), colorRed,0,0,-8);
PlotShapes(IIf(TREND_B, shapeHollowUpArrow , shapeNone), colorGreen,0,0,-8);
 
}
 
_SECTION_END();

TREND_status = WriteIf(TREND_B,"Buy",WriteIf(TREND_S ,"Sell","NA"));
TREND_col = IIf (TREND_B,colorGreen, IIf (TREND_S ,colorRed,colorLightGrey));
 
/**************************************************
               RSI
***************************************************/
_SECTION_BEGIN("RSI");
 
Rperiods = Param( "Periods", 14, 1, 200, 1 );
OB = Param("OverBrought Line",70,70,100,1);
OS = Param("OverSold Line",30,20,40,1);
CentreRSI = 50;
Overbought = OB;
Oversold = OS;
 
RSI_PERIODS = Prec(RSI( Rperiods),1);
 
 
//******* RSI Cross 30 or 70**//
 
B_RSI = RSI_CROSS_30 = Cross(RSI_PERIODS,OS);
 
S_RSI = RSI_CROSS_70 = Cross(OB,RSI_PERIODS);
 
 
//******* RSI < 30 or > 70**//
 
RSI_BELOW_30 = RSI_PERIODS < OS ;
 
RSI_ABOVE_70 = RSI_PERIODS > OB ;
 
 
//******* RSI > OR < IN LAST 14 DAYS***//
 
RSI_14_GREATEST = RSI_PERIODS>=HHV( RSI_PERIODS, 14);
 
RSI_14_LOWEST = RSI_PERIODS<=LLV( RSI_PERIODS, 14);
 
 
//******* RSI DIVERGENCE***//
 
RSI_BEAR_DIV = Close >= HHV( Close, 14 ) AND RSI_PERIODS < HHV( RSI_PERIODS, 14 );
 
RSI_BULL_DIV = RSI_PERIODS >= HHV( RSI_PERIODS, 14 ) AND Close < HHV( Close, 14 );
 
RSI_BULL_DIV1 = Close <= LLV( Close, 14 ) AND RSI_PERIODS > LLV(RSI_PERIODS, 14 );
 
RSI_BEAR_DIV1 = RSI_PERIODS <= LLV( RSI_PERIODS, 14) AND Close > LLV(Close,14);
/*****/////////
 
RSI_BUY = B_RSI ;
RSI_SELL =S_RSI ;
 
_SECTION_END();

RSI_status = WriteIf(RSI_BUY,"Buy["+RSI_BUY+"]",WriteIf(RSI_SELL,"Sell["+RSI_SELL+"]","NA"));
RSI_col = IIf (RSI_BUY,colorGreen, IIf (RSI_SELL,colorRed,colorLightGrey));
 
/**************************************************
             OBV
***************************************************/
_SECTION_BEGIN("OBV");
 
MA_OBV_Period = Param("OBV_MA Period",10,10,21,1);
 
/***********OBV CROSS MA************/
OBV_BUY = Cross(OBV(),MA(OBV(),MA_OBV_Period));
OBV_SELL = Cross(MA(OBV(),MA_OBV_Period),OBV());
 
_SECTION_END();
 
 
OBV_status = WriteIf(OBV_BUY,"Buy",WriteIf(OBV_SELL,"Sell","NA"));
OBV_col = IIf (OBV_BUY,colorGreen, IIf (OBV_SELL,colorRed,colorLightGrey));
 
/**************************************************
            TSV = SIMILAR TO WORDEN
***************************************************/
_SECTION_BEGIN("TSV");
Period = Param("Period for FVE", 22, 5, 80, 1 );
Coeff = Param("Coeff for Cutoff", 0.1, 0, 2, 0.01 );
 
intra=log(H)-log(L);
Vintra = StDev(intra, period );
inter = log(Avg)-log(Ref(Avg,-1));
Vinter = StDev(inter,period);
Cutoff = Coeff * (Vinter+Vintra)*C;
MF = C- (H+L)/2 + Avg - Ref( Avg, -1 );
VC = IIf( MF > Cutoff, V,
IIf( MF < -Cutoff, -V, 0 ));
FVE = 100 * Sum( VC, Period )/(MA( V, Period ) * Period );
 
// Momemtum Indicator by William Blau
 
TSI = 100 * ( EMA( EMA( C - Ref( C, -1 ) ,25 ) ,13)
/ EMA( EMA( abs( C - Ref( C, -1) ),25 ), 13 ) );
 
 
TSI_BUY = Cross(TSI,EMA(TSI,7));
TSI_SELL = Cross(EMA(TSI,7),TSI);
_SECTION_END();
 
TSI_status = WriteIf(TSI_BUY,"Buy",WriteIf(TSI_SELL,"Sell","NA"));
TSI_col = IIf (TSI_BUY,colorGreen, IIf (TSI_SELL,colorRed,colorLightGrey));
 
/**************************************************
              TRIX
***************************************************/
_SECTION_BEGIN("TRIX");
// TRIX - 15 Periods, 9 Signal Periods
tPeriods = Param("Periods", 15, 2, 100, 1 );
tSig = Param("Signal", 9, 2, 100, 1);
 
Zero = 0;
 
TRIX_VAL = Trix(tPeriods);
SIG_TRIX = EMA(Trix(tPeriods),tSig);
 
/***********TRIX & Signal Line cross ************/
TRIX_SIGNAL_BUY = Cross(TRIX_VAL, SIG_TRIX) AND TRIX_VAL < 0;
TRIX_SIGNAL_SELL = Cross(SIG_TRIX, TRIX_VAL)AND TRIX_VAL > 0;
 
/***********TRIX & Zero Line cross ************/
TRIX_ZERO_BUY = Cross(TRIX_VAL, Zero);
TRIX_ZERO_SELL = Cross(Zero, TRIX_VAL);
 
TRIX_BUY = TRIX_SIGNAL_BUY + TRIX_ZERO_BUY;
TRIX_SELL = TRIX_SIGNAL_SELL + TRIX_ZERO_SELL;

_SECTION_END();
 
TRIX_status = WriteIf(TRIX_BUY,"Buy",WriteIf(TRIX_SELL,"Sell","NA"));
TRIX_col = IIf (TRIX_BUY,colorGreen, IIf (TRIX_SELL,colorRed,colorLightGrey));
 
/************************************************
                 Gap
*************************************************/
 
GAP_UP = GapUp();
GAP_DW = GapDown();
 
GAP_status = WriteIf(GAP_UP,"Buy",WriteIf(GAP_DW ,"Sell","NA"));
GAP_col = IIf (GAP_UP,colorGreen, IIf (GAP_DW ,colorRed,colorLightGrey));
 
/************************************************
            Total of Bullish/Bearish
*************************************************/
 
Total_Buy  = PIVOT_BUY + BUY_ADX + BUY_MACD + BUY_STOCH+ TREND_B + GAP_UP + RSI_BUY + OBV_BUY + TSI_BUY + TRIX_BUY;
Total_Sell = PIVOT_SELL + SELL_ADX + SELL_MACD + SELL_STOCH + TREND_S + GAP_DW + RSI_SELL + OBV_SELL +TSI_SELL+TRIX_SELL;
 
printf("B OIVOTS %g\n",PIVOT_BUY);
printf("SELL PIVOTS %g\n",PIVOT_SELL);
printf("BUY GAP %g\n",TREND_B);
printf("BUY TREND %g\n",GAP_UP);
 
printf("BUY RSI %g\n",B_RSI + RSI_14_GREATEST + RSI_BULL_DIV1 + RSI_BULL_DIV);

_SECTION_BEGIN("Chart Settings");
    SetChartOptions(0,chartShowArrows|chartShowDates);
    SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
    SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkGrey),ParamColor("Lower Chart",colorDarkGrey));
    GraphXSpace=Param("GraphXSpace",10,0,100,1);
    dec = (Param("Decimals",2,0,7,1)/10)+1;
    bi = BarIndex();
    Lbi = LastValue(BarIndex());
    sbi = SelectedValue(bi);
    x1= BarCount-1;
Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(32) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}  " +
    EncodeColor(55)+ "     Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
    EncodeColor(55)+ "     High = "+ EncodeColor(5) + WriteVal(H,dec) +
    EncodeColor(55)+ "      Low = "+ EncodeColor(32)+ WriteVal(L,dec) + 
    EncodeColor(55)+ "    Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
    EncodeColor(55)+ "    Volume = "+ EncodeColor(52)+ WriteVal(V,1) +

"\n"+EncodeColor(colorPink)+"----------------------------------------"

+"\n"+EncodeColor(07)+"Volume: "+WriteIf(V>Vp2,EncodeColor(colorLime)+"Very High",WriteIf(V>Vp1,EncodeColor(colorLime)+" High",WriteIf(V>Vrg,EncodeColor(colorLime)+"Above Average",

WriteIf(V<Vrg AND V>Vn1,EncodeColor(colorRed)+"Less than Average",WriteIf(V<Vn1,EncodeColor(colorRed)+"Low","")))))

 

+"\n"+EncodeColor(colorYellow)+"Spread: "+WriteIf(rg >(arg*2),EncodeColor(colorLime)+" Wide",WriteIf(rg>arg,EncodeColor(colorLime)+" Above Average",EncodeColor(colorRed)+" Narrow"))

 

+"\n"+(EncodeColor(colorYellow)+"Close: ")+WriteIf(Vhcls,EncodeColor(colorLime)+"Very High",WriteIf(ucls,EncodeColor(colorLime)+"High",WriteIf(mcls,EncodeColor(colorYellow)+"Mid",

WriteIf(dcls,EncodeColor(colorRed)+"Down","Very Low"))))

 

+"\n"+EncodeColor(colorYellow) + "Zone : " +WriteIf(rising , EncodeColor(colorBrightGreen) + "Accumulation",WriteIf(falling , EncodeColor(colorCustom12) + "Distirbution",EncodeColor(colorAqua) + "Flat")) + " "

+"\n"+

EncodeColor(colorYellow) + "Status : " +

WriteIf(Weakness , EncodeColor(colorRed) + "Weak",

WriteIf(stoppingVolume , EncodeColor(colorCustom12) + "StoppingVol",

WriteIf(noSupplyBar , EncodeColor(colorLightOrange) + "NoSupply",

WriteIf(support , EncodeColor(colorLightBlue) + "SupportVol",

WriteIf(noDemandBar , EncodeColor(colorPink) + "NoDemand",

WriteIf(absorption, EncodeColor(colorSkyblue) + "Absorption",

WriteIf(upThrustBar, EncodeColor(colorBlue) + "Upthrust",

WriteIf(bullishsign, EncodeColor(colorPaleGreen) + "STRONG",

EncodeColor(colorTan) + "Neutral")))))))) + " "

+"\n"+EncodeColor(colorPink)+"----------------------------------------"

+"\n"+EncodeColor(colorYellow) +"----------------------------------------"
+"\n"+EncodeColor(colorGold)+   "                   Analysis                "
+"\n"+EncodeColor(colorYellow) +"----------------------------------------"
 
 
/**************** PIVOTS***************************/
+ "\n"
+EncodeColor(colorWhite)+"PIVOTS                      = " +
WriteIf (aLPivs,EncodeColor(ColorRGB(168,255,0))+" BUY("+PIVOT_BUY+")",WriteIf (aHPivs,EncodeColor(colorRed)+ " SELL("+PIVOT_SELL+")","Neutral"))
 
/**************** ADX***************************/
+ "\n"
+EncodeColor(colorWhite)+"ADX                            =  " +
WriteIf (BUY_ADX,EncodeColor(ColorRGB(168,255,0))+"BUY("+BUY_ADX+")",WriteIf (SELL_ADX,EncodeColor(colorRed)+ " SELL("+SELL_ADX+")","Neutral"))
 
/**************** MACD ***************************/
 
+ "\n" +
EncodeColor(colorWhite)+"MACD "+"["+r1+"]"+" " +"["+r2+"]"+" " +"["+r3+"]    =  " +
WriteIf (BUY_MACD,EncodeColor(ColorRGB(168,255,0))+"BUY("+BUY_MACD+")",WriteIf (SELL_MACD,EncodeColor(colorRed)+ "SELL("+SELL_MACD+")","Neutral"))
  
/********************STOChASTICS*********************/
 
+"\n"+EncodeColor(colorWhite)+"Stochastics              =  "
+ WriteIf(BUY_STOCH,EncodeColor(ColorRGB(168,255,0))+"BUY ("+BUY_STOCH+")",WriteIf(SELL_STOCH,EncodeColor(colorRed)+"SELL("+SELL_STOCH+")","Neutral"))
 
/********************RSI*********************/
+"\n" + EncodeColor(colorWhite)+"RSI"+"("+Rperiods+")                     =  "
+WriteIf(B_RSI,EncodeColor(ColorRGB(168,255,0))+"BUY("+RSI_BUY+")",WriteIf (S_RSI,EncodeColor(colorRed)+"SELL("+RSI_SELL+")","Neutral"))
 
/********************OBV********************/
+"\n"
+EncodeColor(colorWhite)+"OBV                           =  "+
WriteIf(OBV_BUY,EncodeColor(ColorRGB(168,255,0))+"BUY(1)",WriteIf(OBV_SELL,EncodeColor(colorRed)+"SELL(1)",""))+
WriteIf(NOT OBV_BUY AND NOT OBV_SELL,"No Cross","")
 
/********************TSV********************/
 
+"\n"
+EncodeColor(colorWhite)+"TSV                            =  "  +
WriteIf(TSI_BUY,EncodeColor(ColorRGB(168,255,0))+"BUY(1)",
WriteIf(TSI_SELL,EncodeColor(colorRed)+"SELL(1)",""))+
WriteIf(NOT TSI_BUY AND NOT TSI_SELL,EncodeColor(colorAqua)+"NA","")
 
/********************TRIX*********************/
+"\n"
+EncodeColor(colorWhite)+"TRIX "+ "("+tPeriods+") "+"(" +tSig+ ")            =  "
+EncodeColor(ColorRGB(168,255,0))+
WriteIf (TRIX_BUY, "BUY ("+TRIX_BUY+")","")
+EncodeColor(colorRed)+
WriteIf (TRIX_SELL, "SELL("+TRIX_SELL+")","")
+EncodeColor(colorAqua)+
WriteIf (NOT TRIX_SELL AND NOT TRIX_BUY, "No Cross","")
 
/**************TREND*********************************/
 
+"\n" +EncodeColor(colorWhite)+"Trend                        =  "
+WriteIf(Up AND NOT TREND_B,EncodeColor(ColorRGB(168,255,0))+"Up ",WriteIf(Up AND TREND_B,EncodeColor(colorBrightGreen)+ "BUY(1)",
WriteIf(Down AND NOT TREND_S,EncodeColor(colorRed)+"Down",WriteIf(Down AND TREND_S,EncodeColor(colorRed)+"SELL(1)","."))))
 
/**************GAPS *********************************/

+"\n"+EncodeColor(colorWhite)+"GAP                           =  "
+WriteIf(GAP_UP,EncodeColor(ColorRGB(168,255,0))+"UP (1)",WriteIf(GAP_DW,EncodeColor(colorRed)+"DOWN (1)", EncodeColor(colorAqua)+"Neutral"))
+"\n"+EncodeColor(colorPink) +"======================="
+"\n"+EncodeColor((ColorRGB(242,157,255)))+"BUY    =    "+EncodeColor(colorYellow)+Total_Buy
+"\n"+EncodeColor((ColorRGB(242,157,255)))+"SELL   =    "+EncodeColor(colorYellow)+Total_Sell
+"\n"+EncodeColor(colorPink) +"----------------------------------------";


_SECTION_END();
//========================================================================
 
 
SetChartOptions(2,chartShowArrows|chartShowDates|chartWrapTitle);
SetChartOptions(0,chartShowArrows|chartShowDates);
 
 
//GfxGradientRect( 180, 30, 1759, 735, ColorRGB(40,40,40), ColorRGB(0,0,40) ); 
GfxSetOverlayMode(1); 
//GfxSelectPen( ColorRGB(150,0,0), 1 ); 
GfxSelectSolidBrush( ColorRGB(0,0,40) ); 
//GfxRectangle=( 0,750, 1807, 35 ); 
 
//GfxSelectPen( ColorRGB(150,0,0), 2 ); 
GfxSelectSolidBrush( ColorRGB(65,65,65) ); 
//GfxPolygon(250,200,200,250,250,20,200,50); 
 
//GfxSelectPen( ColorRGB(125,0,0), 1 ); 
//GfxSelectSolidBrush( ColorRGB(0,0,40) ); 
//GfxRectangle( 10,100, 190, 160 ); 
 
//GfxSelectPen=( ColorRGB(0,0,0) ,1 ); 
GfxSelectSolidBrush( ColorRGB(0,0,0) ); 
//GfxSetTextAlign( 250 );// center alignment
 
GfxSetOverlayMode(1); 
//GfxSelectFont=("Times New Roman", 30, 400, True ); 
GfxSetTextColor( ColorRGB( 105, 105, 105 ) );
GfxSetBkMode(0); // transparent
//GfxTextOut=("Pathfinder", 15 , 35 ); 
 
 
_SECTION_BEGIN("Flower");
si=Param("Zoom/In Out",5,-50,100,1);
GraphXSpace=si;  
 
r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );
 
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, ColorRGB(155,155,155),IIf(m1>0 AND m1>s1,ColorRGB(0,125,0),IIf(m1>0 AND m1<s1,ColorRGB(180,30,160),ColorRGB(100,0,0))));
 
Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);
barColor=IIf(Close>Open,ColorRGB(0,245,0),ColorRGB(255,0,0));
 
Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
total = 0;
total = total  + IIf(tskp_colortmplcnd0 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd1 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd2 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd3 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd4 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd5 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd6 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd7 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd8 > 0, 1, -1); 
 
 
for( i = 0; i < BarCount; i++ ) 
{
 
    if( total[i] >= 5 )
        Color[i] = colorLime;
    else if(  total[i] <= -5 )
        Color[i] = colorRed;
    else
        Color[i] = colorWhite;
} 
 
Candle=ParamList("Candle","Modified Candlestick,Modified Heikin Ashi,Normal Candlestick",1);
if(Candle=="Modified Candlestick")
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
Plot (Close,"- Modified Candlestick", Color,ParamStyle( "Style", styleCandle|styleLine | styleThick, maskAll)); 
}
if(Candle=="Modified Heikin Ashi")
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen, flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose, flowerOpen), "Modified Heikin Ashi", Color, styleCandle|styleLine);
}
if(Candle=="Normal Candlestick")
{
//ColorHighliter = myColor;
//SetBarFillColor( ColorHighliter );
PlotOHLC(O,H,L,C,"Normal Candlestick",barcolor,styleCandle|styleLine);
}
 
 
_SECTION_END();
 
_SECTION_BEGIN("TSKPPIVOT");
 
if(Candle=="Modified Heikin Ashi")
{
CHiPr = 0;
CLoPr = 9999999;
blsLong = 0;
PrevCOBar = 0;
NumBars = 0;
PrePP = 0;
PrevLowVal = 9999999;
BuySig = 0;
blsShort = 0;
PrevHiVal = 0;
blsNewCO = 0;
BarDif   = 0;
 
KPA900Val = E_TSKPA900(Close);
KPAutoStopVal = E_TSKPAUTOSTOP(High,Low,Close);
 
// -- Create 0-initialized arrays the size of barcount
aHPivs = flowerHigh - flowerHigh;
aLPivs = flowerLow - flowerLow;
aHiVal = flowerHigh - flowerHigh;
aLoVal = flowerLow - flowerLow;
 
 
Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal = 0;
sctotal = sctotal  + IIf(tskp_colortmplcnd0 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd1 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd2 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd3 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd4 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd5 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd6 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd7 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd8 > 0, 1, -1); 
 
 
for (curBar=0; curBar < BarCount-1; curBar++)
{
 
    if ( curBar == 0 )
    {
        CHiPr = flowerHigh[curBar];
        CHiBar = curBar;
        CLoPr = flowerLow[curBar];
        CLoBar = curBar;
        blsLong = 0;
        blsShort = 0;
        blsNewCO = 0;
        PrePP = 0;
        PrevCOBar = 0;
        PrevHiVal = flowerHigh[curBar];
        PrevLowVal = flowerLow[curBar];
        BuySig = 0;
        SellSig = 0;
        blsLL  = 0;
    }
 
    if (flowerHigh[CurBar] >= CHiPr) {
        CHiPr = flowerHigh[CurBar];
        ChiBar = CurBar;
    }
 
    if (flowerLow[CurBar] <= CLoPr) {
        CLoPr = flowerLow[CurBar];
        CLoBar = CurBar;
    }
 
    if ( (KPA900Val[curBar] >= KPAutoStopVal[curbar]) AND (PrePP != -1) AND (blsLong != 1) ){
        BarDif = CurBar - PrevCOBar;
        if (BarDif >= NumBars) {
            blsLong = 1;
            blsShort = 0;
            blsNewCO = 1;
            PrevCOBar = CurBar;
        }
    }
 
    if ( (KPA900Val[curBar] <= KPAutoStopVal[curbar]) AND (PrePP != 1) AND (blsShort != 1) ){
        BarDif = CurBar - PrevCOBar;
        if (BarDif >= NumBars) {
            blsLong = 0;
            blsShort = 1;
            blsNewCO = 1;
            PrevCOBar = CurBar;
        }
    }
 
    if ( (blsNewCO == 1) AND (sctotal[CurBar] >= 5) AND (blsLong == 1) ) {
        LVal = CurBar - CLoBar;
        for (j= CLoBar-1; j <= CLoBar+1; j++)
        {
            if (j >=0) {
                aLPivs[j] = 1;
                aLoVal[j] = CLoPr;
            }
        }
        PrePP = -1;
        blsNewCO = 0;
        CHiPr = flowerHigh[CurBar];
        CHiBar = CurBar;
        CLoPr = flowerLow[Curbar];
        CLoBar = CurBar;
        } 
        else if ((blsNewCO == 1) AND (sctotal[CurBar] <= -5) AND (blsShort == 1) ) {
        HVal = CurBar - CHiBar;
        for (j= CHiBar-1; j <= CHiBar+1; j++)
        {       
            if (j >=0) {
                aHPivs[j] = 1;
                aHiVal[j] = CHiPr;
            }
        }
        PrePP = 1;
        blsNewCO = 0;
        CHiPr = flowerHigh[CurBar];
        CHiBar = CurBar;
        CLoPr = flowerLow[Curbar];
        CLoBar = CurBar;
        } 
}
 
PlotShapes(IIf(aHPivs == 1, 21,shapeNone), ColorRGB(255,0,145),0,   aHiVal,Offset = 20);
PlotShapes(IIf(aHPivs == 1, 15,shapeNone), ColorRGB(200,50,75),0,   aHiVal,Offset = 20);
PlotShapes(IIf(aLPivs == 1, 21,shapeNone), ColorRGB(0,125,225),0, aLoVal, Offset = -20);
PlotShapes(IIf(aLPivs == 1, 15,shapeNone), ColorRGB(0,125,255),0, aLoVal, Offset = -20);
}
 
 
_SECTION_END();
 
_SECTION_BEGIN("Resistance");
supres=ParamToggle("Sup_Res","No|Yes",1);
if(supres)
{
 
Prd1=Param("Res_Period1",2,0,200,1);
                    
test   = TEMA  ( High , Prd1 ) ;   
 
PK = test > Ref(test,-1) AND Ref(test,1) < High;//Peak
PKV0 = ValueWhen(PK,flowerHigh,0);//PeakValue0
PKV1 = ValueWhen(PK,flowerHigh,1);//PeakValue1
PKV2 = ValueWhen(PK,flowerHigh,2);//PeakValue2
 
MPK = PKV2 < PKV1 AND PKV1 > PKV0 ;//MajorPeak
 
RsColor=ParamColor("ResistColor",ColorRGB(225,0,0));
BrCount=Param("ResistBarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    RsColor[i] = colorBlack;
}
 
 
 
MPKV = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,1); //MajorPeakValue
MPKD = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),1); //MajorPeakDate
SD = IIf(DateNum() < LastValue(MPKD,lastmode = True ), Null, LastValue(MPKV,Lastmode = True));//SelectedDate
Plot(SD, "Resist1",  ColorRGB(200,0,0),ParamStyle("ResStyle1",styleDashed|styleNoTitle,maskAll));
 
RsColor2=ParamColor("Resist2Color",ColorRGB(225,0,0));
BrCount=Param("Resist2BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    RsColor2[i] = colorBlack;
}
 
MPKV2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,2); //MajorPeakValue
MPKD2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),2); //MajorPeakDate
SD2 = IIf(DateNum() < LastValue(MPKD2,lastmode = True ), Null, LastValue(MPKV2,Lastmode = True));//SelectedDate
Plot(SD2, "Resist2", RsColor2,ParamStyle("ResStyle2",styleDashed|styleNoTitle,maskAll));
 
RsColor3=ParamColor("Resist3Color",ColorRGB(225,0,0));
BrCount=Param("Resist3BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    RsColor3[i] = colorBlack;
}
 
 
MPKV3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,3); //MajorPeakValue
MPKD3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),3); //MajorPeakDate
SD3 = IIf(DateNum() < LastValue(MPKD3,lastmode = True ), Null, LastValue(MPKV3,Lastmode = True));//SelectedDate
Plot(SD3, "Resist3", RsColor3,ParamStyle("ResStyle3",styleThick|styleDots|styleNoTitle,maskAll));
 
 
 
_SECTION_END();
 
 
_SECTION_BEGIN("Support");
 
Prd2=Param("Sup_Period1",2,0,200,1);
                    
test2   = TEMA ( Low , Prd2 ) ;   
 
SP = Ref(test2,1) > Low AND test2 < Ref(test2,-1);//Peak
SPV0 = ValueWhen(SP,flowerLow,0);//PeakValue0
SPV1 = ValueWhen(SP,flowerLow,1);//PeakValue1
SPV2 = ValueWhen(SP,flowerLow,2);//PeakValue2
 
MSP = SPV2 > SPV1 AND SPV1 < SPV0 ;//MajorPeak
 
SpColor=ParamColor("SupColor",ColorRGB(0,225,0));
BrCount=Param("SupBarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    SpColor[i] = colorBlack;
}
 
 
MSPV = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,1);
MSPD = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),1);
SD = IIf(DateNum() < LastValue(MSPD,lastmode = True ), Null, LastValue(MSPV,Lastmode = True));
Plot(SD,"Support1",SpColor,ParamStyle("SupportLine1",styleDashed|styleNoTitle,maskAll));
 
SpColor2=ParamColor("SupColor2",ColorRGB(0,200,0));
BrCount=Param("Sup2BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    SpColor2[i] = colorBlack;
}
 
 
MSPV2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,2);
MSPD2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),2);
SD2 = IIf(DateNum() < LastValue(MSPD2,lastmode = True ), Null, LastValue(MSPV2,Lastmode = True));
Plot(SD2,"Support2",Spcolor2,ParamStyle("SupportLine2",styleDashed|styleNoTitle,maskAll));
 
SpColor3=ParamColor("SupColor3",ColorRGB(0,175,0));
BrCount=Param("Sup3BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    SpColor3[i] = colorBlack;
}
 
 
MSPV3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,3);
MSPD3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),3);
SD3 = IIf(DateNum() < LastValue(MSPD3,lastmode = True ), Null, LastValue(MSPV3,Lastmode = True));
Plot(SD3,"Support3",SpColor3,ParamStyle("SupportLine3",styleThick|styleDots|styleNoTitle,maskAll));
}
_SECTION_END();
 
/* 
 
_SECTION_BEGIN("TSKPEBand");

Periods = Param("Standard Error", 20, 3, 200, 1); 
Smooth  = Param("Smooth",12,2,100,1);
 
 
LRCurve = LinearReg( C, periods ); 
MALRCurve  = MA(LRCurve, Smooth);
SEValue = StdErr( C, periods ); 
SErrorAvg =  MA(SEValue, Smooth);
 
LowerBand = MALRCurve - SErrorAvg ;
UpperBand = MALRCurve + SErrorAvg ;
 
Plot( MALRCurve , "MidBand", ParamColor("ColorMB",ColorRGB(0,200,0))  , ParamStyle("StyleMB", style=styleDashed, Mask=maskDefault )); 
Plot( UpperBand , "UpperBand", ParamColor("ColorUp",colorTeal)  , ParamStyle("StyleUp", style=styleDashed, Mask=maskDefault ));
Plot( LowerBand , "LowerBand", ParamColor("ColorLo",colorTeal), ParamStyle("StyleLo", style=styleDashed, Mask=maskDefault ));
_SECTION_END();

_SECTION_BEGIN("Cloud Setting");
//Cloud
ParmCloud = ParamToggle("Cloud", "No|Yes", 1);
 
CloudResColor=ParamColor("CloudResColor",ColorRGB(15,15,15));
CR=Upperband;
CS=Lowerband;
 
if(parmCloud == 1)
{
    PlotOHLC( CS, CS, CR,CR, "Band", CloudResColor, styleCloud | styleNoLabel|styleNoTitle); 
}
 
_SECTION_END();
*/
 
_SECTION_BEGIN("20EMA High");
Ph = ParamField("Price field",1);
Periods1 = Param("Periods", 20, 2, 400, 1 );
bbt=MA( Ph, Periods1 );
//Plot( bbt, "20EMA(H)", ParamColor( "Color", colorAqua ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("20EMA Low");
Pl = ParamField("Price field",2);
Periods2 = Param("Periods", 20, 2, 400, 1 );
bbb=MA( Pl, Periods2 );
//Plot( bbb, "20EMA(L)", ParamColor( "Color", colorAqua ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("EMA Channel");
PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( ParamColor("Color", ColorRGB(15,15,15) ), ColorRGB(15,15,15), 0.9 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();
 
_SECTION_BEGIN("Supertrend");
procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
{
	global buffer_line_down;
	global buffer_line_up;
	buffer_line_down = Null;
	buffer_line_up = Null;
 
	PHASE_NONE = 0;
	PHASE_BUY = 1;
	PHASE_SELL = -1;
 
	phase=PHASE_NONE;
	band_upper = 0;band_lower = 0;
 
	for(i = ATR_Period + 1; i < BarCount; i++)
	{
		band_upper = CalcPrice[i] + ATR_Multiplier * tr[i];
		band_lower = CalcPrice[i] - ATR_Multiplier * tr[i];
 
		if(phase==PHASE_NONE)
		{
			buffer_line_up[i] = CalcPrice[i];
			buffer_line_down[i] = CalcPrice[i];
		}
		if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1]))
		{
			phase = PHASE_BUY;
			buffer_line_up[i] = band_lower;
			buffer_line_up[i-1] = buffer_line_down[i-1];
		}
		if(phase!=PHASE_SELL && Close[i]<buffer_line_up[i-1] && !IsEmpty(buffer_line_up[i-1]))
		{
			phase = PHASE_SELL;
			buffer_line_down[i] = band_upper;
			buffer_line_down[i-1] = buffer_line_up[i-1];
		}
		if(phase==PHASE_BUY && ((TrendMode==0 && !IsEmpty(buffer_line_up[i-2])) || TrendMode==1) )
		{
			if(band_lower>buffer_line_up[i-1])
			{
				buffer_line_up[i] = band_lower;
			}
			else
			{
				buffer_line_up[i] = buffer_line_up[i-1];
			}
		}
		if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
		{
			if(band_upper<buffer_line_down[i-1])
			{
				buffer_line_down[i] = band_upper;
			}
			else
			{
				buffer_line_down[i] = buffer_line_down[i-1];
			}
		}
	}
}
 
TrendMode = ParamToggle("TrendMode","Off|On",1);
ATR_Multiplier = Param("ATR_Multiplier",2,0.1,10,0.1);
ATR_Period = Param( "ATR_Period",5,1,20,1);
tr = ATR(ATR_Period);
 
CalcPrice = (H+L)/2;
calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice);

st = ParamToggle("Supertrend","Show|Hide",0);
if(st==1)  { 
Plot(buffer_line_up,"\ntu",ColorRGB(28,134,238),styleThick);
Plot(buffer_line_down,"\ntd",ColorRGB(205,51,51),styleThick);
 
//Plot( 2,"",IIf(buffer_line_up,colorGreen,colorDarkOliveGreen),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
//Plot( 4,"",IIf(buffer_line_down,colorRed,colorDarkOliveGreen),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
}
_SECTION_END();

_SECTION_BEGIN("Auto Pivot");
Offset = 5; //use two sheets: one with 5 and another with 7, or maybe other offset value
Avgmov = Offset*MA(abs( ROC(C,1)) ,20);
per = LastValue(Avgmov) ;
x=Cum(1);
Range = 0.01;
PS = TroughBars(L, per,1) == 0;
xa = LastValue(ValueWhen (PS,x,1)) ;//x from last trough
Ya = LastValue(ValueWhen (PS,L,1)) ;//y (Low) last trough
PR = PeakBars(H,per, 1) == 0;
xb = LastValue(ValueWhen (PR,x,1)) ;//x from last peak
Yb = LastValue(ValueWhen (PR,H,1)) ;//y (High) last peak
Trough_ReTest = abs((L/ya)-1) <Range;
Peak_ReTest = abs((H/yb)-1) <Range;
Trough_Cross = Cross(ya,C);
Peak_Cross = Cross(C,yb);
//UP = upSwing DN = downSwing
UP = xb>xa;//upSwing
DN = xa>xb;//DownSwing
RT23_6 = IIf(UP,yb-(yb- ya)*0.236, IIf(DN,ya+ (yb-ya)*0.236,-1e10) );
RT38_2 = IIf(UP,yb-(yb- ya)*0.382, IIf(DN,ya+ (yb-ya)*0.382,-1e10) );
RT50_0 = IIf(UP,yb-(yb- ya)*0.500, IIf(DN,ya+ (yb-ya)*0.500,-1e10) );
RT61_8 = IIf(UP,yb-(yb- ya)*0.618, IIf(DN,ya+ (yb-ya)*0.618,-1e10) );
RT78_6 = IIf(UP,yb-(yb- ya)*0.786, IIf(DN,ya+ (yb-ya)*0.786,-1e10) );
 
RT12_7 = IIf(UP,yb-(yb- ya)*1.27, IIf(DN,ya+ (yb-ya)*1.27,-1e10) );
RT16_1 = IIf(UP,yb-(yb- ya)*1.61, IIf(DN,ya+ (yb-ya)*1.61,-1e10) );
 
RT=IIf(UP,-100* (yb-L)/(yb- ya),100*(H-ya)/( yb-ya));//Retracement_ Value
InZone = C<yb & C>ya;//use it for filter to receive only signals that are in in the Retracement zone.
Buy = Trough_ReTest OR peak_Cross;
Sell = Peak_ReTest OR trough_Cross;
Filter = 1;
AddColumn(RT, "RT%");
AddColumn(Trough_ReTest,"TR- Test",1.0) ;
AddColumn(Peak_ReTest,"PK-Test",1.0) ;
AddColumn(Trough_Cross,"TR-Cross",1.0);
AddColumn(Peak_Cross,"PK-Cross",1.0);
//AddColumn(CdDoji( )OR CHammer(),"Candle" ,1.0);
//Plot(C,"C",1, 64);
Plot(IIf(x>xa, ya,-1e10) ,"Bottom" ,colorBrown, 1+8);
Plot(IIf(x>xb, yb,-1e10) ,"Top",colorBrown,1+8);
xab = IIf(xb>xa,xb, xa);
//Retracements
Plot(IIf(x>= xab+1,RT23_6,-1e10), "\n23,6% Retr.",5,1);
Plot(IIf(x>= xab+1,RT38_2,-1e10), "38,2% Retr.",5,1);
Plot(IIf(x>= xab+1,RT50_0,-1e10), "\n50,0% Retr.",colorBlue, 1);
Plot(IIf(x>= xab+1,RT61_8,-1e10), "\n61,8% Retr.",colorBrown, 1);
Plot(IIf(x>= xab+1,RT78_6,-1e10), "78,6% Retr.",colorBrown, 1);
 
Plot(IIf(x>= xab+1,RT12_7,-1e10), "\n127% ext.",colorBrightGreen, styleDots);
Plot(IIf(x>= xab+1,RT16_1,-1e10), "161% ext.",colorBrightGreen, styleDots);

CondA=IIf(x>= xab+1,RT12_7,-1e10);
CondB=IIf(x>= xab+1,RT16_1,-1e10);

PlotOHLC(Condb,Condb,Conda,Conda,"",ColorRGB(30,130,30),styleCloud,styleNoLabel);

GraphXSpace = 0.5;
 
_SECTION_END( );

_SECTION_BEGIN("Better Volume");

Period = Param("Period", 13, 2, 300, 1, 10 );;

LowColor = colorYellow;
ClimaxColor = colorRed;
ChurnColor = colorGreen;
ClimaxChurnColor=colorBlue;
LowChurnColor= colorWhite;

Value1 = V;
Value2 = V*(H-L);
Value3 = V/(H-L);

BarColor = IIf( (Value1 == LLV(Value1,Period)), LowColor, IIf( (Value2 == HHV(Value2,Period)), ClimaxColor, IIf( (Value3 == HHV(Value3,Period)), ChurnColor, IIf( ((Value2 == HHV(Value2,Period) AND (Value3 == HHV(Value3,Period)))), ClimaxChurnColor, IIf( (Value3 == LLV(Value3,Period)), LowChurnColor, colorBlueGrey)))));

Plot( Volume, _DEFAULT_NAME(), BarColor, ParamStyle( "Style", styleHistogram  | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 2 );

_SECTION_END();

_SECTION_BEGIN("Beta Adjusted Trailing Stops by Southwind");
//Concept from Bulkowski’s Stop Placement
 
 
dif=Ref(High,0)-Ref(Low,0);
dif1=Ref(High,-1)-Ref(Low,-1);
dif2=Ref(High,-2)-Ref(Low,-2);
dif3=Ref(High,-3)-Ref(Low,-3);
dif4=Ref(High,-4)-Ref(Low,-4);
dif5=Ref(High,-5)-Ref(Low,-5);
dif6=Ref(High,-6)-Ref(Low,-6);
dif7=Ref(High,-7)-Ref(Low,-7);
dif8=Ref(High,-8)-Ref(Low,-8);
dif9=Ref(High,-9)-Ref(Low,-9);
dif10=Ref(High,-10)-Ref(Low,-10);
dif11=Ref(High,-11)-Ref(Low,-11);
dif12=Ref(High,-12)-Ref(Low,-12);
dif13=Ref(High,-13)-Ref(Low,-13);
dif14=Ref(High,-14)-Ref(Low,-14);
dif15=Ref(High,-15)-Ref(Low,-15);
 
Sumdif=(dif+dif1+dif2+dif3+dif4+dif5+dif6+dif7+dif8+dif9+dif10+dif11+dif12+dif13+dif14+dif15)/16;
 
mp = Param("Multiplier",2,0.25,5,0.25);
Sumdifml=(Sumdif*1);
Sumdifml2=(Sumdif*1.6);
Sumdifml3=(Sumdif*mp);
 
Betastops=HHV(C,20) - Sumdifml;
Betastops2=HHV(C,15) - Sumdifml2;
 
 
//BetastopsO=Ref(L,-1)-sumdifml;
//Plot(betastopsO,"BATS",ParamColor("", colorGreen) ,ParamStyle("",styleLine|styleThick|styleStaircase,maskAll));
//Plot(Betastops, "A", ParamColor( "Color", colorPink ),ParamStyle("Style",styleThick,maskAll));
Plot(Betastops2, "B", ParamColor( "Color2", colorGold ),ParamStyle("Style2",styleThick,maskAll));
 
//Plot(Sumdifml,"DifferenceX",3,styleNoLine |styleNoLabel);
//Plot(sumdif,"AvgDifference",25,styleNoLine |styleNoLabel);
//Plot(dif10,"AvgDifference1",26,styleNoLine |styleNoLabel);
_SECTION_END();

13 comments

1. kv_maligi

Hi Mr.Niladri
Vert Good. Exspecially you have clubbed fibo projections.

Is it possible to add buy/sell signals & exploration ?

what are conditions for buy /sell ? and also is it possible rank the signals strong buy & weak buy like that…

Thanks
Viswanath MK

2. worldastro

error on line no-2017

3. niladri

I have found “Signal Panel” one of my earlier indicator is using FIBO for plotting TGT’s on the same chart, I also noted if we keep " Better Volume" indicator in the same chart window, for some scripts chart looks bad.

So worked out my latest version of this indicator, replaced “Better Volume” indicator with Heiken Ashi Muti-Time-Frame bars ( HAS-MTF like seen in MT4 ) at the bootom of the chart window. Better Volume should be added as a seperate chart in the window & if added with wave trend charts, this now looks like a killer combo.

Wave trend: http://www.wisestocktrader.com/indicators/372-mikes-wave-trend-clone

I will post my new code later today.

4. kv_maligi

Hi Niladri,

wave trend clone is very good.
Awaiting for new code

thanks
viswanath

5. niladri

New version here: http://www.wisestocktrader.com/indicators/3276-southbreeze-modified-v2

With links to all other indicators for the system.

6. kv_maligi

Hi Niladri,

I think, the bars at bottom are indication of Multi Time Frame information. At present they are 3,6 & 12.

what are best values for daily TF ?

Thanks
Viswanath

7. niladri

The multi TF multipliers > TF , TF x 3, TF x 6, TF x 12 ( is meant for 5Min charts )

That way you get idea abt the HA trend on 5M/15M/30M/1H in a single 5M chart itself.

This why it is made part of v2.

8. itzvarma

Dear Friends,
I tried to use this indicator on my Amibroker system,but it is showing an error called “Error 29 variable ‘kpautostopval’ used without having been initialized”
What is the remedy?
Can anyone reply please?

9. Nazrulcpa

PLZ SEND ME THIS AFL FOR AMIBROKER 5.6V . WOULD U PLZ TO DO SOMETHING BETTER FOR DSE/CSE. HERE IS MY EMAIL nazrulcpa@gmail.com

10. spectremind

yes plz send me AFL code for amibroker v5.6 too. it isn’t working for me. thx. fatcatstarvingdog@gmail.com

11. mrdzenli

научись писать формулы

12. pk55

very good nice working

13. tuanhoangplus

It is not run. Would you can fix and send me tuanhoangplus@gmail.com.
Thanks you so much !!!

Leave Comment

Please login here to leave a comment.

Back