NexusFi: Find Your Edge


Home Menu

 





ThinkScript: Three Line Break


Discussion in ThinkOrSwim

Updated
    1. trending_up 8,876 views
    2. thumb_up 1 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

ThinkScript: Three Line Break

  #1 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154

I need help with the cloud function. This three line break indicator displays an upper and lower line that I would like to fill to make it look more like a regular three line break chart. The problem is filling the gap between the upper and lower lines. Using just the cloud function doesn't work properly; so there could be a way to use the cloud function together with the rec or the fold commands. Can anyone help me with this?

 
Code
 
#  SJ_ThreeLineBreak
#  Original Code by Richard Houser
declare upper;
# Clear Chart
# Turn off volume on upper chart: Style > Settings > Equities > Show Volume (empty checkbox)
AssignPriceColor(CreateColor(10, 0, 78));
AssignBackgroundColor(CreateColor(10, 0, 78));
 
rec state = {default barOne, barTwo, barThree};
rec xHigh;
rec xLow;
rec xWhite;
switch ( state[1] ) {
  case barOne:
    state    = state.barTwo;
    xHigh    = high;
    xLow     = low;
    xWhite   = if close > open then yes else no;
  case barTwo:
    state = state.barThree;
    if high > xHigh[1] then {
      xHigh  = high;
      xLow   = xHigh[1];
      xWhite = yes;
    } else if low < xLow[1] then {
      xHigh  = xLow[1];
      xLow   = low;
      xWhite = no;
    } else {
      xHigh  = xHigh[1];
      xLow   = xLow[1];
      xWhite = xWhite[1];
    }
  case barThree:
    state = state.barThree;
    if high > Max(xHigh[1],xHigh[2]) then {
      xHigh  = high;
      xLow   = xHigh[1];
      xWhite = yes;
    } else if low < Min(xLow[1],xLow[2]) then {
      xHigh  = xLow[1];
      xLow   = low;
      xWhite = no;
    } else {
      xHigh  = xHigh[1];
      xLow   = xLow[1];
      xWhite = xWhite[1];
    }
}
DefineGlobalColor( "3LBH", Color.YELLOW );
DefineGlobalColor( "3LBL", Color.CYAN );
plot TLB_High  = if IsNaN(close) then Double.NaN else if xWhite then xHigh else xLow;
TLB_High.SetPaintingStrategy( PaintingStrategy.DASHES );
TLB_High.AssignValueColor( if xWhite then globalColor("3LBH") else globalColor("3LBL"));
plot TLB_Low = if IsNaN(close) then Double.NaN else if xWhite then xLow else xHigh;
TLB_Low.SetPaintingStrategy( PaintingStrategy.DASHES );
TLB_Low.AssignValueColor( if xWhite then globalColor("3LBH") else globalColor("3LBL"));
# AddCloud( TLB_High, TLB_Low, globalColor("3LBH"), globalColor("3LBL") );
plot P = close;
P.SetPaintingStrategy( PaintingStrategy.POINTS );
P.Hide();

Reply With Quote
Thanked by:




Last Updated on December 16, 2010


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts