Friday, September 16, 2011

TOS Code for 9 Ema Break

Since lot of you have been asking about my cloud bands. I thought of posting this code on the blog itself.
The Bands I have are called Vidya Bands. These bands were invented by Prof. Tushar Chande  You can find him on SFO magazine or University of Pittsburgh's site. He has lot of indicator RAVI, ARUN etc.

I came across his article on how to find early the stocks that break out and that lead me to this quest. He had described using 1% above and 1% below his Chande momentum oscillator. His oscillator is very complex using sigmas and deviations etc. So I decided to make it little simple and I use his 99% and 101% on 9 Ema with the new clouds on TOS platform.

Here is the code for you folks to use.


#########################################################
## BigbullandBigBear LLC
## Date: 1st Sept 2010
#########################################################

input price       = close;
input ColoredCloud = yes;
input ColoredFill = yes;
input BreakArrows = yes;
input displace    =  0;
input length      = 9;

def lastBar = if (IsNaN(close), 1, 0);

def EMA = expAverage(close, 9);

def EmaStatus =
  if close >EMA then 2    
  else
    if close < EMA then -2  
    else 0    ;                          

rec BreakStatus = compoundValue(1,
  if BreakStatus[1] == emaStatus or emaStatus == 0 then BreakStatus[1]
  else
    if Emastatus == 2 then 2
    else -2, 0);

plot UpperBand = EMA*1.01;
UpperBand.AssignValueColor (
    if !Coloredcloud then Color.White
    else
      if BreakStatus[0] == 2 then Color.Green
      else Color.Red);
UpperBand.SetLineWeight(1);

plot LowerBand = EMA*.99;
LowerBand.AssignValueColor (
    if !Coloredcloud then Color.White
    else
      if BreakStatus[0] == 2 then Color.Green
      else Color.Red);
LowerBand.SetLineWeight(1);

# Breakout/down arrows.
plot BreakOutArrow =
  if BreakArrows then
    if BreakStatus[0] == BreakStatus[1] then double.NAN
    else if BreakStatus[0] == 2 then
      close else double.NAN
  else double.NAN;
BreakOutArrow.SetPaintingStrategy(PaintingStrategy.Arrow_Up);
BreakOutArrow.SetDefaultColor(Color.Green);
BreakOutArrow.SetLineWeight(3);

plot BreakDownArrow =
  if BreakArrows then
    if BreakStatus[0] == BreakStatus[1] then double.NAN
    else if BreakStatus[0] == -2 then
      close else double.NAN
else double.NAN;
BreakDownArrow.SetPaintingStrategy(PaintingStrategy.Arrow_Down);
BreakDownArrow.SetDefaultColor(Color.Red);
BreakDownArrow.SetLineWeight(3);

# colored clouds
plot GreenUpper = if ColoredFill and BreakSTatus[0] == 2 then
  UpperBand else double.NAN;
GreenUpper.SetDefaultColor(CreateColor(0,100,0));
plot GreenLower = if ColoredFill and BreakStatus[0] == 2 then
  LowerBand else double.NAN;
GreenLower.SetDefaultColor(CreateColor(0,100,0));
AddCloud (GreenUpper, GreenLower,CreateColor(0,100,0), color.red);

plot RedUpper = if ColoredFill and BreakSTatus[0] == -2 then
  UpperBand else double.NAN;
RedUpper.SetDefaultColor(CreateColor(200,0,0));
plot RedLower = if ColoredFill and BreakStatus[0] == -2 then
  LowerBand else double.NAN;
RedLower.SetDefaultColor(CreateColor(200,0,0));
AddCloud (RedUpper, RedLower, CreateColor(200,0,0), color.green);


############ END##############################################


The picture matches up very nicely with even Hekin Ashi style of charts..
Also it matched perfectly with my picture perfect setup couple days ago on SPY....that I posted here on the blog.

Any questions, please e-mail me at marketing1977@gmail.com

3 comments:

Anonymous said...

Nice Job

Jele said...

Great indicator. Thanks

david said...

I don't appreciate you posting my copyrighted code.
Please email david@pc3i.net to purchase permission for posting.
thanks
David

Post a Comment