NexusFi: Find Your Edge


Home Menu

 





VSA for ThinkorSwim


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one snowcloud with 93 posts (25 thanks)
    2. looks_two StockJock with 91 posts (27 thanks)
    3. looks_3 cbritton with 37 posts (71 thanks)
    4. looks_4 swimtrader with 22 posts (19 thanks)
      Best Posters
    1. looks_one Hornblower with 2.3 thanks per post
    2. looks_two cbritton with 1.9 thanks per post
    3. looks_3 StockJock with 0.3 thanks per post
    4. looks_4 snowcloud with 0.3 thanks per post
    1. trending_up 304,527 views
    2. thumb_up 223 thanks given
    3. group 86 followers
    1. forum 434 posts
    2. attach_file 131 attachments




 
Search this Thread

VSA for ThinkorSwim

  #261 (permalink)
 
marcovth's Avatar
 marcovth 
Canada
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES,6E
Posts: 25 since Jun 2010
Thanks Given: 1
Thanks Received: 30

I don't understand what the advantage would be of a 30 moving average vs the average of ALL the bars, except for days like yesterday and today where the volume is much lower than average.

In statistics, the larger the data set, the more reliably you can fish out extremes.

Using the average of all the bars, indeed, makes the line flat.

I have adapted the VSA code to handle all three volume average options. I will take a little bit of time over the weekend to see whether my two options make sense.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Exit Strategy
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
27 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #262 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154

Good question. What's the advantage? Probably the original programming authors know. However, I just thought it would be good to be consistant with the VPA code, since this discussion is about VSA. You code doesn't display like the TradeGuider's screen shot that you posted. Maybe the advantage is to get it to look more like your TradeGuider screen shot.

Reply With Quote
  #263 (permalink)
 
marcovth's Avatar
 marcovth 
Canada
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES,6E
Posts: 25 since Jun 2010
Thanks Given: 1
Thanks Received: 30


I have implemented the EMA, Day/Night, and Hourly averages in the VSA7 script.

However, I have troubles sharing it. There are too many chars for this forum.
"The text that you have entered is too long (47247 characters). Please shorten it to 30000 characters long."

So, I will have to split it up.

VSA7 UPPER part 1

 
Code
declare upper;
declare real_size;


#######
# Arguments
input AvgVolumeType = {default EMA, Day_Night_Split, Hourly_Avg};
input volumeEMALength = 30;
input narrowSpreadFactor = 0.7;
input wideSpreadFactor = 1.5;
input aboveAvgVolfactor = 1.5;
input ultraHighVolfactor = 2;
input highCloseFactor = 0.70;
input lowCloseFactor = 0.25;
input GdojiFactor = 0.2; # C_RP
input WickFactor = 0.1; # C_RP
input shortTermLength = 5; #C_RP
input midTermLength = 15; #C_RP
input longTermLength = 40; #C_RP
input colorBars = {false, default true}; #C_RP
input trendText = {false, default true};
input volumeDefinitions = { false, default true };
input alerts = { default false, true };


def MarketsHours = if (secondsFromTime(0930) >= 0) and (secondsTillTime(1610) >= 0) then yes else no;

def Hour00 = if (secondsFromTime(0000) >= 0) and (secondsTillTime(0100) > 0) then yes else no;
def Hour01 = if (secondsFromTime(0100) >= 0) and (secondsTillTime(0200) > 0) then yes else no;
def Hour02 = if (secondsFromTime(0200) >= 0) and (secondsTillTime(0300) > 0) then yes else no;
def Hour03 = if (secondsFromTime(0300) >= 0) and (secondsTillTime(0400) > 0) then yes else no;
def Hour04 = if (secondsFromTime(0400) >= 0) and (secondsTillTime(0500) > 0) then yes else no;
def Hour05 = if (secondsFromTime(0500) >= 0) and (secondsTillTime(0600) > 0) then yes else no;
def Hour06 = if (secondsFromTime(0600) >= 0) and (secondsTillTime(0700) > 0) then yes else no;
def Hour07 = if (secondsFromTime(0700) >= 0) and (secondsTillTime(0800) > 0) then yes else no;
def Hour08 = if (secondsFromTime(0800) >= 0) and (secondsTillTime(0900) > 0) then yes else no;
def Hour09 = if (secondsFromTime(0900) >= 0) and (secondsTillTime(0930) > 0) then yes else no;
def Hour930 = if (secondsFromTime(0930) >= 0) and (secondsTillTime(1000) > 0) then yes else no;
def Hour10 = if (secondsFromTime(1000) >= 0) and (secondsTillTime(1100) > 0) then yes else no;
def Hour11 = if (secondsFromTime(1100) >= 0) and (secondsTillTime(1200) > 0) then yes else no;
def Hour12 = if (secondsFromTime(1200) >= 0) and (secondsTillTime(1300) > 0) then yes else no;
def Hour13 = if (secondsFromTime(1300) >= 0) and (secondsTillTime(1400) > 0) then yes else no;
def Hour14 = if (secondsFromTime(1400) >= 0) and (secondsTillTime(1500) > 0) then yes else no;
def Hour15 = if (secondsFromTime(1500) >= 0) and (secondsTillTime(1600) > 0) then yes else no;
def Hour16 = if (secondsFromTime(1600) >= 0) and (secondsTillTime(1630) > 0) then yes else no;
def Hour1630 = if (secondsFromTime(1630) >= 0) and (secondsTillTime(1700) > 0) then yes else no;
def Hour17 = if (secondsFromTime(1700) >= 0) and (secondsTillTime(1800) > 0) then yes else no;
def Hour18 = if (secondsFromTime(1800) >= 0) and (secondsTillTime(1900) > 0) then yes else no;
def Hour19 = if (secondsFromTime(1900) >= 0) and (secondsTillTime(2000) > 0) then yes else no;
def Hour20 = if (secondsFromTime(2000) >= 0) and (secondsTillTime(2100) > 0) then yes else no;
def Hour21 = if (secondsFromTime(2100) >= 0) and (secondsTillTime(2200) > 0) then yes else no;
def Hour22 = if (secondsFromTime(2200) >= 0) and (secondsTillTime(2300) > 0) then yes else no;
def Hour23 = if (secondsFromTime(2300) >= 0) and (secondsTillTime(2359) >= 0) then yes else no;


rec SumVol00 = if Hour00 then SumVol00[1] + volume else SumVol00[1];
rec nBarsHour00 = if Hour00 then nBarsHour00[1] + 1 else nBarsHour00[1];
def AvgVolHour00 = SumVol00 / nBarsHour00;

rec SumVol01 = if Hour01 then SumVol01[1] + volume else SumVol01[1];
rec nBarsHour01 = if Hour01 then nBarsHour01[1] + 1 else nBarsHour01[1];
def AvgVolHour01 = SumVol01 / nBarsHour01;

rec SumVol02 = if Hour02 then SumVol02[1] + volume else SumVol02[1];
rec nBarsHour02 = if Hour02 then nBarsHour02[1] + 1 else nBarsHour02[1];
def AvgVolHour02 = SumVol02 / nBarsHour02;

rec SumVol03 = if Hour03 then SumVol03[1] + volume else SumVol03[1];
rec nBarsHour03 = if Hour03 then nBarsHour03[1] + 1 else nBarsHour03[1];
def AvgVolHour03 = SumVol03 / nBarsHour03;

rec SumVol04 = if Hour04 then SumVol04[1] + volume else SumVol04[1];
rec nBarsHour04 = if Hour04 then nBarsHour04[1] + 1 else nBarsHour04[1];
def AvgVolHour04 = SumVol04 / nBarsHour04;

rec SumVol05 = if Hour05 then SumVol05[1] + volume else SumVol05[1];
rec nBarsHour05 = if Hour05 then nBarsHour05[1] + 1 else nBarsHour05[1];
def AvgVolHour05 = SumVol05 / nBarsHour05;

rec SumVol06 = if Hour06 then SumVol06[1] + volume else SumVol06[1];
rec nBarsHour06 = if Hour06 then nBarsHour06[1] + 1 else nBarsHour06[1];
def AvgVolHour06 = SumVol06 / nBarsHour06;

rec SumVol07 = if Hour07 then SumVol07[1] + volume else SumVol07[1];
rec nBarsHour07 = if Hour07 then nBarsHour07[1] + 1 else nBarsHour07[1];
def AvgVolHour07 = SumVol07 / nBarsHour07;

rec SumVol08 = if Hour08 then SumVol08[1] + volume else SumVol08[1];
rec nBarsHour08 = if Hour08 then nBarsHour08[1] + 1 else nBarsHour08[1];
def AvgVolHour08 = SumVol08 / nBarsHour08;

rec SumVol09 = if Hour09 then SumVol09[1] + volume else SumVol09[1];
rec nBarsHour09 = if Hour09 then nBarsHour09[1] + 1 else nBarsHour09[1];
def AvgVolHour09 = SumVol09 / nBarsHour09;

rec SumVol930 = if Hour930 then SumVol930[1] + volume else SumVol930[1];
rec nBarsHour930 = if Hour930 then nBarsHour930[1] + 1 else nBarsHour930[1];
def AvgVolHour930 = SumVol930 / nBarsHour930;

rec SumVol10 = if Hour10 then SumVol10[1] + volume else SumVol10[1];
rec nBarsHour10 = if Hour10 then nBarsHour10[1] + 1 else nBarsHour10[1];
def AvgVolHour10 = SumVol10 / nBarsHour10;

rec SumVol11 = if Hour11 then SumVol11[1] + volume else SumVol11[1];
rec nBarsHour11 = if Hour11 then nBarsHour11[1] + 1 else nBarsHour11[1];
def AvgVolHour11 = SumVol11 / nBarsHour11;

rec SumVol12 = if Hour12 then SumVol12[1] + volume else SumVol12[1];
rec nBarsHour12 = if Hour12 then nBarsHour12[1] + 1 else nBarsHour12[1];
def AvgVolHour12 = SumVol12 / nBarsHour12;

rec SumVol13 = if Hour13 then SumVol13[1] + volume else SumVol13[1];
rec nBarsHour13 = if Hour13 then nBarsHour13[1] + 1 else nBarsHour13[1];
def AvgVolHour13 = SumVol13 / nBarsHour13;

rec SumVol14 = if Hour14 then SumVol14[1] + volume else SumVol14[1];
rec nBarsHour14 = if Hour14 then nBarsHour14[1] + 1 else nBarsHour14[1];
def AvgVolHour14 = SumVol14 / nBarsHour14;

rec SumVol15 = if Hour15 then SumVol15[1] + volume else SumVol15[1];
rec nBarsHour15 = if Hour15 then nBarsHour15[1] + 1 else nBarsHour15[1];
def AvgVolHour15 = SumVol15 / nBarsHour15;

rec SumVol16 = if Hour16 then SumVol16[1] + volume else SumVol16[1];
rec nBarsHour16 = if Hour16 then nBarsHour16[1] + 1 else nBarsHour16[1];
def AvgVolHour16 = SumVol16 / nBarsHour16;

rec SumVol1630 = if Hour1630 then SumVol1630[1] + volume else SumVol1630[1];
rec nBarsHour1630 = if Hour1630 then nBarsHour1630[1] + 1 else nBarsHour1630[1];
def AvgVolHour1630 = SumVol1630 / nBarsHour1630;

rec SumVol17 = if Hour17 then SumVol17[1] + volume else SumVol17[1];
rec nBarsHour17 = if Hour17 then nBarsHour17[1] + 1 else nBarsHour17[1];
def AvgVolHour17 = SumVol17 / nBarsHour17;

rec SumVol18 = if Hour18 then SumVol18[1] + volume else SumVol18[1];
rec nBarsHour18 = if Hour18 then nBarsHour18[1] + 1 else nBarsHour18[1];
def AvgVolHour18 = SumVol18 / nBarsHour18;

rec SumVol19 = if Hour19 then SumVol19[1] + volume else SumVol19[1];
rec nBarsHour19 = if Hour19 then nBarsHour19[1] + 1 else nBarsHour19[1];
def AvgVolHour19 = SumVol19 / nBarsHour19;

rec SumVol20 = if Hour20 then SumVol20[1] + volume else SumVol20[1];
rec nBarsHour20 = if Hour20 then nBarsHour20[1] + 1 else nBarsHour20[1];
def AvgVolHour20 = SumVol20 / nBarsHour20;

rec SumVol21 = if Hour21 then SumVol21[1] + volume else SumVol21[1];
rec nBarsHour21 = if Hour21 then nBarsHour21[1] + 1 else nBarsHour21[1];
def AvgVolHour21 = SumVol21 / nBarsHour21;

rec SumVol22 = if Hour22 then SumVol22[1] + volume else SumVol22[1];
rec nBarsHour22 = if Hour22 then nBarsHour22[1] + 1 else nBarsHour22[1];
def AvgVolHour22 = SumVol22 / nBarsHour22;

rec SumVol23 = if Hour23 then SumVol23[1] + volume else SumVol23[1];
rec nBarsHour23 = if Hour23 then nBarsHour23[1] + 1 else nBarsHour23[1];
def AvgVolHour23 = SumVol23 / nBarsHour23;

rec SumVolMarketsHours = if MarketsHours then SumVolMarketsHours[1] + volume else SumVolMarketsHours[1];
rec nBarsMarketsHours = if MarketsHours then nBarsMarketsHours[1] + 1 else nBarsMarketsHours[1];
def AvgVolMarketsHours = SumVolMarketsHours / nBarsMarketsHours;

rec SumVolOFFMarketsHours = if !MarketsHours then SumVolOFFMarketsHours[1] + volume else SumVolOFFMarketsHours[1];
rec nBarsOFFMarketsHours = if !MarketsHours then nBarsOFFMarketsHours[1] + 1 else nBarsOFFMarketsHours[1];
def AvgVolOFFMarketsHours = SumVolOFFMarketsHours / nBarsOFFMarketsHours;

def AvgVolHourly=
if Hour00 then AvgVolHour00 else
if Hour01 then AvgVolHour01 else
if Hour02 then AvgVolHour02 else
if Hour03 then AvgVolHour03 else
if Hour04 then AvgVolHour04 else
if Hour05 then AvgVolHour05 else
if Hour06 then AvgVolHour06 else
if Hour07 then AvgVolHour07 else
if Hour08 then AvgVolHour08 else
if Hour09 then AvgVolHour09 else
if Hour930 then AvgVolHour930 else
if Hour10 then AvgVolHour10 else
if Hour11 then AvgVolHour11 else
if Hour12 then AvgVolHour12 else
if Hour13 then AvgVolHour13 else
if Hour14 then AvgVolHour14 else
if Hour15 then AvgVolHour15 else
if Hour16 then AvgVolHour16 else
if Hour1630 then AvgVolHour1630 else
if Hour17 then AvgVolHour17 else
if Hour18 then AvgVolHour18 else
if Hour19 then AvgVolHour19 else
if Hour20 then AvgVolHour20 else
if Hour21 then AvgVolHour21 else
if Hour22 then AvgVolHour22 else
if Hour23 then AvgVolHour23 else
 double.nan;

#plot AvgVolDailyMarketHrs = if MarketsHours then AvgVolMarketsHours else double.nan;
#plot AvgVolNightlyOFFMarketHrs = if !MarketsHours then AvgVolOFFMarketsHours else double.nan;

#plot AvgVolHourlyBars=AvgVolHourly;

# Calculate Volume moving average and it's standard deviation
rec sAvgVolume =  compoundValue(volumeEMALength, Average(volume, volumeEMALength), Double.NaN);
def sAvgVolumeSTD = stdev(sAvgVolume, volumeEMALength);

def AvgVol=
if AvgVolumeType==AvgVolumeType.Hourly_Avg then AvgVolHourly
else if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume
else if MarketsHours then AvgVolMarketsHours else AvgVolOFFMarketsHours
;


def UHline =if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume[0] + 2.0 * sAvgVolumeSTD else AvgVol + (AvgVol * 1);
def VHline =if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume[0] + 1.0 * sAvgVolumeSTD else AvgVol + (AvgVol * 0.65);
def Hline =if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume[0] else AvgVol + (AvgVol * 0.15);
def Lline =if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume[0] - 1.0 * sAvgVolumeSTD else AvgVol - (AvgVol * 0.15);
def VLline =if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume[0] - 2.0 * sAvgVolumeSTD else AvgVol - (AvgVol * 0.65);
def zeroline = 0;


#AddCloud(VHline, UHline, color.pink, color.pink);
#AddCloud(Hline, VHline, color.MAGENTA, color.MAGENTA);
#AddCloud(Lline, Hline, color.BLUE, color.BLUE);
#AddCloud(VLline, Lline, color.MAGENTA, color.MAGENTA);
#AddCloud(zeroline, VLline, color.pink, color.pink);


# This is a conversion of the NinjaTrader VPA indicator.  ToS does not support directional
# triangles and diamonds, so there are some differences.  The triangles are left as is, just
# not pointing a specific direction.  The diamonds have been replaced with circles.

# C_RP Original notes by cbritton are above. Changes made after 20100722 by Richard Paske are marked below by the C_RP comment tag. A few bugs were fixed. More significantly, the color scheme for symbols was changed radically in an attempt to map directional strength to hue based on the ROYGBIV color spectrum. In addition, a symbol's shape and its vertical position above or below a candle now imparts added meaning to it. In general, the strength of a symbol is assigned by its color and shape in that order. In certain circumstances a symbol's vertical offset from its candle's top or bottom strengthens the symbol's meaning. The symbol strength  hierarchy is defined as follows:

# 1. Color: Symbols below candles are assigned strength from weakest to strongest in this order: white (or grey), cyan (blue/green), green. A red symbol under a candle indicates the failure of the symbol attached below the candle immediately preceding it.
# Symbols above candles are assigned strength from weakest to strongest in this order: yellow, orange, red. A green symbol above a candle indicates the failure of a symbol attached above the candle immediately preceding it. A magenta (pinkish purple) square above a candle is a special case indicating Distribution. Another special case for testing purposes as of 20100830 is a white triangle high above a candle indicating a Gravestone Doji.
# Symbols drawn on the middle of a candle are of two types with one variation. A green circle indicates Effort to Move Up on up bars. A magenta (pinkish purple) circle indicates Effort to Move Down on down bars except for red down bars on which magenta displays poorly. In order to be seen easily, yellow circles indicate Effort to Move Down on red down bars.

# 2. Shape: A symbol of a given color is assigned increasing strength according to this hierarchy (from low to high): circle, square, triangle, downward or upward arrow. In certain circumstances two symbols of the same shape and color will be stacked vertically, adding strength through the combined symbols. Occasionally, two different symbols will be stacked vertically because that candle satisfies the criteria for two indications.

# Listed below are the symbols and their meanings. The original symbol chart can be found at the end of this study.

# ___Symbols Below Candles___
# White Square - Test for Supply
# Cyan Circle - No Supply
# Cyan Triangle - Successful Test for Supply
# 2 Cyan Triangles - Successful Test for Supply 2

# Grey Square - Test for Supply in Uptrend

# Green Circle - Stopping Volume

# Cyan Square - Strength in Downtrend
# Green Square - Strength in Downtrend 1
# Green Triangle - Strength in Downtrend 2
# Green UpArrow - Strength Confirmation Bar
# 2 Green UpArrows - Strength Confirmation Bar with High Close
# Red Square - Failed Strength Signal


# ___Symbols in the Middle of Candles___
# Green Circle - Effort to Move Up
# Magenta Circle - Effort to Move Down
# Yellow Circle - Effort to Move Down on Red Down Candles

# ___Symbols Above Candles___
# White Triangle - Gravestone Doji (included as an experiment as of 20100830 to test its usability in the UpThrust category)
# Yellow Triangle - Weakness

# Orange Circle - No Demand
# Orange Square - PseudoUpThrust
# Orange Triangle - PseudoUpThrust Confirmation

# Red Square - UpThrust
# Red Triangle - Confirmed UpThrust Condition 1
# Red DownArrow - Confirmed UpThrust Condition 2 or 3
# Green Square - Failed UpThrust or PseudoUpThrust Confirmation

# Red Circle - Reversal Likely
# Magenta Square - Distribution
# Magenta Triangle - Two or Three Period UpThrust

#######################################################

# C_RP The next two comments are from the original comments by cbritton.
# The NT version used a LinRegSlopeSFX indicator for determining trends. Those have been
# replaced in this ToS version with a call to the built in LinearRegressionSlope indicator.


#######
# Calculations

rec spread = high - low;
def median = (high + low ) / 2;
rec avgVolume = compoundValue(volumeEMALength, ExpAverage(volume, volumeEMALength), Double.NaN);

# Calculate Volume moving average and it's standard deviation
#rec sAvgVolume =  compoundValue(volumeEMALength, Average(volume, volumeEMALength), Double.NaN);
#def sAvgVolumeSTD = stdev(sAvgVolume, volumeEMALength);



# check if the vloume has been decreasing in the past two days.
def isTwoDaysLowVol = (volume < volume[1] && volume[0] < volume[2]);

# Calculate Range information
def avgSpread = WildersAverage(spread, volumeEMALength)[0];
rec isWideSpreadBar = (spread > (wideSpreadFactor * avgSpread));
rec isNarrowSpreadBar = (spread < (narrowSpreadFactor * avgSpread));

# Price information
rec isUpBar = close > close[1];
rec isDownBar = close < close[1];

# Check if the close is in the Highs/Lows/Middle of the bar.
# C_RP 20100809 
# original code - def x1 = if (close == low) then avgSpread else (spread / (close - low));
def x1 = if (high == low) then 2.0 else if (close == low) then 2.65 else (spread / (close - low));
# C_RP try the line below with various divisors totalSum result in a minimum of 2.3 on a spread of 1 pip instead of using a fixed 2.3 as in the line above
# def x1 = if (high==low) then 2.0 else if (close == low) then (spread / 0.43 ) else (spread / (close - low));



def isUpCloseBar = (x1 < 2);
def isDownCloseBar = (x1 > 2);
def isMidCloseBar = (x1 < 2.2 && x1 > 1.8);
def isVeryHighCloseBar = (x1 < 1.35);
# C_RP 20100809 added isVeryLowCloseBar
def isVeryLowCloseBar = (x1 >= 2.65);


# Trend Definitions
rec fiveDaysSma = compoundValue(5, Average(close, 5)[0], Double.NaN);
def LongTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = longTermLength)[0]; # 40
def MiddleTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = midTermLength)[0]; # 15
def ShortTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = shortTermLength)[0]; # 5

######################################################################
#  VSA Definitions
            
# utbar
rec isUpThrustBar = isWideSpreadBar && isDownCloseBar &&  ShortTermTrendSlope > 0 && middleTermTrendSlope > 0; #C_RP added positive middleTermTrendSlope requirement to filter out upThrusts in trends that are only short term. Consider adding longTermTrendSlope requirement as well.
# utcond1
def upThrustConditionOne = (isUpThrustBar[1] && isDownBar);
# utcond2
def upThrustConditionTwo = (isUpThrustBar[1] && isDownBar[0] && volume > volume[1]);
# utcond3
def upThrustConditionThree = (isUpThrustBar[0] && volume > 2 * AvgVol);
# scond1
rec isConfirmedUpThrustBar = (upThrustConditionOne OR upThrustConditionTwo OR upThrustConditionThree);
# scond
rec isNewConfirmedUpThrustBar = (isConfirmedUpThrustBar[0] && !isConfirmedUpThrustBar[1]);

# Two Period UpThrust Bar
rec isTwoPerUpT = isUpBar[1] && isWideSpreadBar[1] &&  isDownBar[0] && isDownCloseBar[0] && !isUpThrustBar[0] && (AbsValue(open[1] - close[0]) < (GdojiFactor * spread[1])) ;

# Three Period UpThrust Bar
rec isThreePerUpT = isUpBar[2] && isWideSpreadBar[2] &&  isDownBar[0] && isDownCloseBar[0] && !isUpThrustBar[0] && (AbsValue(open[2] - close[0]) < (GdojiFactor * spread[2])) ;


#  C_RP 20100816
# rec isGraveDojiBar = (spread > avgSpread) && (open == low) && (close == low); totally strict Gravestone Doji. Revised version below identifies a candle with above average spread, a real body smaller than 20% of the spread, and a lower wick less than 10% of the spread as a Gravestone Doji pictured as a white triangle above the candle.

rec isGraveDojiBar = (spread > avgSpread) && (AbsValue(open - close) < (GdojiFactor * spread)) &&  ((AbsValue(close - low) < (WickFactor * spread)) or (AbsValue(open - low) < (WickFactor * spread))); # less strict Gravestone Doji


#  trbar
def reversalLikelyBar = (volume[1] > AvgVol && isUpBar[1] && isWideSpreadBar[1] && isDownBar[0] && isDownCloseBar && isWideSpreadBar[0] && LongTermTrendSlope > 0 && high == Highest(high, 10)[0]);
            
# hutbar
rec isPseudoUpThrustBar = (isUpBar[1] && (volume[1] > aboveAvgVolfactor * AvgVol) && isDownBar[0] && isDownCloseBar && !isWideSpreadBar[0] && !isUpThrustBar[0]);
# hutcond
def pseudoUpThrustConfirmation = (isPseudoUpThrustBar[1] && isDownBar[0] && isDownCloseBar && !isUpThrustBar[0]);

# C_RP Failed UpThrustConfirmation or pseudoUpThrustConfirmation occurs when the close of bar following such confirmation is not lower than the close of the confirmation bar

rec isFailedUpThrustConfirmation = (isNewConfirmedUpThrustBar[1] or pseudoUpThrustConfirmation[1]) && close[0] >= close[1];

# tcbar
def weaknessBar = (isUpBar[1] && high[0] == Highest(high, 5)[0] && isDownBar[0] && (isDownCloseBar OR isMidCloseBar) && volume[0] > AvgVol && !isWideSpreadBar[0] && !isPseudoUpThrustBar[0]);

# stdn, stdn0, stdn1, stdn2
def strengthInDownTrend =  (volume[0] > volume[1] && isDownBar[1] && isUpBar[0] && (isUpCloseBar OR isMidCloseBar) && ShortTermTrendSlope < 0 && MiddleTermTrendSlope < 0);
def strengthInDownTrend0 = (volume[0] > volume[1] && isDownBar[1] && isUpBar[0] && (isUpCloseBar OR isMidCloseBar) && ShortTermTrendSlope < 0 && MiddleTermTrendSlope < 0 && LongTermTrendSlope < 0);
def strengthInDownTrend1 = (volume[0] > (AvgVol * aboveAvgVolfactor) && isDownBar[1] && isUpBar[0] && (isUpCloseBar OR isMidCloseBar) && ShortTermTrendSlope < 0 && MiddleTermTrendSlope < 0 && LongTermTrendSlope < 0);
def strengthInDownTrend2 = (volume[1] < AvgVol && isUpBar[0] && isVeryHighCloseBar && volume[0] > AvgVol && ShortTermTrendSlope < 0);

Reply With Quote
Thanked by:
  #264 (permalink)
 
marcovth's Avatar
 marcovth 
Canada
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES,6E
Posts: 25 since Jun 2010
Thanks Given: 1
Thanks Received: 30

VSA7 UPPER part 2 (copy+paste this below the code of the first part)

 
Code
rec bycond1 = (strengthInDownTrend OR strengthInDownTrend1);

# bycond
def isStrengthConfirmationBar = (isUpBar[0] && bycond1[1]);

# bycond2 C_RP UpClose on higher volume with all slopes down adds extra strength
def isStrengthConfirmationBar2 = (isUpBar[0] && isUpCloseBar[0] && volume[0] > volume[1] && longtermtrendslope < 0 && bycond1[1]);

# Failed strength in downtrend signal force a follow-up bar that closes below mid-point of confirmaton bar C_RP

def isFailedStrengthSignal = (isStrengthConfirmationBar[1] or isStrengthConfirmationBar2[1] or strengthinDownTrend2[1]) && close[0] <= (close[1] - (spread[1] / 2));

# stvol
def stopVolBar = low[0] == Lowest(low, 5)[0] && (isUpCloseBar OR isMidCloseBar) && volume[0] > aboveAvgVolfactor * AvgVol && LongTermTrendSlope < 0;

# C_RP stvol at highs - the opposite of stvol
def stopVolBarHighs = high[0] == Highest(high, 5)[0] && (isDownCloseBar OR isMidCloseBar) && volume[0] > aboveAvgVolfactor * AvgVol && LongTermTrendSlope > 0;

# ndbar, nsbar
def noDemandBar = (isUpBar[0] && isNarrowSpreadBar[0] && isTwoDaysLowVol && isDownCloseBar);
# C_RP 20100809
# def noSupplyBar = (isDownBar[0] && isNarrowSpreadBar[0] && isTwoDaysLowVol && isDownCloseBar);
def noSupplyBar = (isDownBar[0] && isNarrowSpreadBar[0] && isTwoDaysLowVol && isUpCloseBar);

# lvtbar, lvtbar1, lvtbar2
rec supplyTestBar = (isTwoDaysLowVol && low[0] < low[1] && isUpCloseBar);
def supplyTestInUpTrendBar = (volume[0] < AvgVol && Low[0] < Low[1] && isUpCloseBar && LongTermTrendSlope > 0 && MiddleTermTrendSlope > 0 && isWideSpreadBar[0]);
def successfulSupplyTestBar = (supplyTestBar[1] && isUpBar[0] && isUpCloseBar);

def successfulSupplyTestBar2 = (successfulsupplyTestBar[1] && isUpBar[0] && x1 <= 2 && volume[0] > volume[1]); # C_RP x1 finds Mid and UpCloseBars
            
# dbar
def distributionBar = (volume[0] > ultraHighVolfactor * AvgVol && isDownCloseBar && isUpBar[0] && ShortTermTrendSlope > 0 && MiddleTermTrendSlope > 0 && !isConfirmedUpThrustBar[0] && !isUpThrustBar[0]);

# eftup, eftupfl, eftdn
def effortToMoveUpBar = (high[0] > high[1] && low[0] > low[1] && Close[0] > Close[1] && Close[0] >= ((high[0] - low[0]) * highCloseFactor + low[0]) && spread[0] > avgSpread && volume[0] > volume[1]);
def failedEffortUpMove = (effortToMoveUpBar[1] && (isUpThrustBar[0] OR upThrustConditionOne OR upThrustConditionTwo OR upThrustConditionThree));

def effortToMoveDownBar = ( ((high[0] < high[1]) OR (isWideSpreadBar && volume[0] > 1.5 * AvgVol))  && low[0] < low[1] && close[0] < close[1] && Close[0] <= ((high[0] - low[0]) * lowCloseFactor + low[0]) && spread[0] > avgSpread && volume[0] > volume[1]);


#C_RP old code - def effortToMoveDownBar = (high[0] < high[1] && low[0] < low[1] && close[0] < close[1] && Close[0] <= ((high[0] - low[0]) * lowCloseFactor + low[0]) && spread[0] > avgSpread && volume[0] > volume[1]);

######################################################################
# set the shapes on the graph

# upthurst and NOT confirmed - red square on top
plot upThrustBarPlot = if isUpThrustBar[0] AND !isNewConfirmedUpThrustBar[0] then (high + 2 * tickSize()) else Double.NAN;
upThrustBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES); 
upThrustBarPlot.SetStyle(Curve.POINTS); 
upThrustBarPlot.SetDefaultColor(Color.Red);
upThrustBarPlot.HideBubble();
upThrustBarPlot.HideTitle();

#  C_RP 20100816
# any instance of a Gravestone Doji - white triangle on top
plot GraveDojiBarPlot = if isGraveDojiBar[0] then (high + 4 * tickSize()) else Double.NAN;
GraveDojiBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES); 
GraveDojiBarPlot.SetStyle(Curve.POINTS); 
GraveDojiBarPlot.SetDefaultColor(CreateColor(255, 255, 255));
GraveDojiBarPlot.HideBubble();
GraveDojiBarPlot.HideTitle();

# C_RP
# Two Period UpThrust Plot - magenta triangle high on top
plot TwoPerUpTPlot = if isTwoPerUpT[0]  then (high + 4 * tickSize()) else Double.NAN;
TwoPerUpTPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES); 
TwoPerUpTPlot.SetStyle(Curve.POINTS); 
TwoPerUpTPlot.SetDefaultColor(Color.magenta);
TwoPerUpTPlot.HideBubble();
TwoPerUpTPlot.HideTitle();

# C_RP
# Three Period UpThrust Plot - magenta triangle high on top
plot ThreePerUpTPlot = if isThreePerUpT[0]  then (high + 4 * tickSize()) else Double.NAN;
ThreePerUpTPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES); 
ThreePerUpTPlot.SetStyle(Curve.POINTS); 
ThreePerUpTPlot.SetDefaultColor(Color.magenta);
ThreePerUpTPlot.HideBubble();
ThreePerUpTPlot.HideTitle();

# reversal likely - blue diamond on top C_RP red 6 * ticksize
plot reversalLikelyBarPlot = if reversalLikelyBar then (high + 6 * tickSize()) else Double.NAN;
reversalLikelyBarPlot.SetPaintingStrategy(PaintingStrategy.POINTS);
reversalLikelyBarPlot.SetDefaultColor(Color.Red);
reversalLikelyBarPlot.HideBubble();
reversalLikelyBarPlot.HideTitle();

# new confirmed upthrust bar - red triangle (down) on top C_RP for upThrustConditionOne only
plot isNewConfirmedUpThrustBarPlot = if isNewConfirmedUpThrustBar && upThrustConditionOne then (high + 2 * tickSize()) else Double.NAN;
isNewConfirmedUpThrustBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
isNewConfirmedUpThrustBarPlot.SetDefaultColor(Color.Red);
isNewConfirmedUpThrustBarPlot.HideBubble();
isNewConfirmedUpThrustBarPlot.HideTitle();

# new confirmed upthrust bar - red triangle (down) on top C_RP red arrow down at 4 * tickSize for conditions 2 and 3
plot isNewConfirmedUpThrustBarPlot23 = if isNewConfirmedUpThrustBar && (upThrustConditionTwo or upThrustConditionThree) then (high + 4 * tickSize()) else Double.NAN;
isNewConfirmedUpThrustBarPlot23.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
isNewConfirmedUpThrustBarPlot23.SetDefaultColor(Color.Red);
isNewConfirmedUpThrustBarPlot23.HideBubble();
isNewConfirmedUpThrustBarPlot23.HideTitle();

# strength in down trend - lime square on bottom C_RP cyan for weakest strengthInDownTrend
plot strengthInDownTrendPlot = if strengthInDownTrend then (low - 4 * tickSize()) else Double.NAN;
strengthInDownTrendPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
strengthInDownTrendPlot.SetDefaultColor(Color.cyan);
strengthInDownTrendPlot.HideBubble();
strengthInDownTrendPlot.HideTitle();

# strength in down trend - lime square on bottom C_RP for next-to-weakest strengthInDownTrend
plot strengthInDownTrend1Plot = if strengthInDownTrend1 then (low - 4 * tickSize()) else Double.NAN;
strengthInDownTrend1Plot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
strengthInDownTrend1Plot.SetDefaultColor(Color.green);
strengthInDownTrend1Plot.HideBubble();
strengthInDownTrend1Plot.HideTitle();

# supply test in up trend - lime square on bottom of the bar C_RP grey
plot supplyTestInUpTrendBarPlot = if supplyTestInUpTrendBar then (low - 4 * tickSize()) else Double.NAN;
supplyTestInUpTrendBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
supplyTestInUpTrendBarPlot.SetDefaultColor(CreateColor(153, 153, 153));
supplyTestInUpTrendBarPlot.HideBubble();
supplyTestInUpTrendBarPlot.HideTitle();

# successful test for supply - yellow triangle up on bottom of the bar C_RP cyan
plot successfulSupplyTestBarPlot = if successfulSupplyTestBar or successfulSupplyTestBar2 then (low - 2 * tickSize()) else Double.NAN;
successfulSupplyTestBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
successfulSupplyTestBarPlot.SetDefaultColor(Color.cyan);
successfulSupplyTestBarPlot.HideBubble();
successfulSupplyTestBarPlot.HideTitle();

# successful test for supply - yellow triangle up on bottom of the bar C_RP cyan double triangle for strong follow-up bar
plot successfulSupplyTestBarPlot2 = if successfulSupplyTestBar2 then (low - 4 * tickSize()) else Double.NAN;
successfulSupplyTestBarPlot2.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
successfulSupplyTestBarPlot2.SetDefaultColor(Color.cyan);
successfulSupplyTestBarPlot2.HideBubble();
successfulSupplyTestBarPlot2.HideTitle();

# stopping volume green (diamond) circle at bottom of bar
plot stopVolBarPlot = if stopVolBar then (low - 2 * tickSize()) else Double.NAN;
stopVolBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
stopVolBarPlot.SetDefaultColor(Color.green);
stopVolBarPlot.HideBubble();
stopVolBarPlot.HideTitle();

# stopping volume yellow (diamond) circle at top of bar
plot stopVolBarHighsPlot = if stopVolBarHighs then (high + 7 * tickSize()) else Double.NAN;
stopVolBarHighsPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
stopVolBarHighsPlot.SetDefaultColor(Color.yellow);
stopVolBarHighsPlot.HideBubble();
stopVolBarHighsPlot.HideTitle();

# green triangle up at bottom of the bar C_RP Green arrow up 4 * tickSize for strong strength_In_DownTrend
plot isStrengthConfirmationBarPlot = if isStrengthConfirmationBar then (low - 4 * tickSize()) else Double.NAN;
isStrengthConfirmationBarPlot.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
isStrengthConfirmationBarPlot.SetDefaultColor(Color.green);
isStrengthConfirmationBarPlot.HideBubble();
isStrengthConfirmationBarPlot.HideTitle();

# green triangle up at bottom of the bar C_RP Green arrow up 7 * tickSize for strongest strength_In_DownTrend with isUpCloseBar
plot isStrengthConfirmationBarPlot2 = if isStrengthConfirmationBar2 then (low - 7 * tickSize()) else Double.NAN;
isStrengthConfirmationBarPlot2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
isStrengthConfirmationBarPlot2.SetDefaultColor(Color.green);
isStrengthConfirmationBarPlot2.HideBubble();
isStrengthConfirmationBarPlot2.HideTitle();

# blue square at top of bar  C_RP orange
plot isPseudoUpThrustBarPlot = if isPseudoUpThrustBar then (high + 2 * tickSize()) else Double.NAN;
isPseudoUpThrustBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
isPseudoUpThrustBarPlot.SetDefaultColor(CreateColor(255, 102, 102));
isPseudoUpThrustBarPlot.HideBubble();
isPseudoUpThrustBarPlot.HideTitle();

# blue triangle (down) at top of bar  C_RP orange
plot pseudoUpThrustConfirmationPlot = if pseudoUpThrustConfirmation then (high + 2 * tickSize()) else Double.NAN;
pseudoUpThrustConfirmationPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
pseudoUpThrustConfirmationPlot.SetDefaultColor(CreateColor(255, 102, 102));
pseudoUpThrustConfirmationPlot.HideBubble();
pseudoUpThrustConfirmationPlot.HideTitle();

# Failed UpthrustBarPlot Confirmation plots a green square 2 * tickSize above the failed bar C_RP
plot FailedUpThrustConfirmationPlot = if isFailedUpthrustConfirmation then (high + 2 * tickSize()) else Double.NAN;
FailedUpThrustConfirmationPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
FailedUpThrustConfirmationPlot.SetDefaultColor(Color.green);
FailedUpThrustConfirmationPlot.HideBubble();
FailedUpThrustConfirmationPlot.HideTitle();

# yellow triangle (down) at top of bar
plot weaknessBarPlot = if weaknessBar then (high + 2 * tickSize()) else Double.NAN;
weaknessBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
weaknessBarPlot.SetDefaultColor(Color.yellow);
weaknessBarPlot.HideBubble();
weaknessBarPlot.HideTitle();

# aqua triangle up at bottom of bar C_RP green triangle for next-to-strongest strengthInDownTrend
plot strengthInDownTrend2Plot = if strengthInDownTrend2 then (low - 2 * tickSize()) else Double.NAN;
strengthInDownTrend2Plot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
strengthInDownTrend2Plot.SetDefaultColor(Color.green); # ????
strengthInDownTrend2Plot.HideBubble();
strengthInDownTrend2Plot.HideTitle();

# Failed strength in downtrend signal plots red square at candle's bottom. Under rare conditions a strengthinDownTrend2 green triangle can be overwritten by a successfulsupplyTest cyan triangle below the previous bar. If the bar following the cyan triangle is a FailedStrengthSignal a red square will be plotted on the following bar which is a desirable artifact of this coincidence. C_RP

plot failedstrengthsignalPlot = if isfailedstrengthsignal then (low - 2 * tickSize()) else Double.NAN;
failedstrengthsignalPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
failedstrengthsignalPlot.SetDefaultColor(Color.red); 
failedstrengthsignalPlot.HideBubble();
failedstrengthsignalPlot.HideTitle();

# distribution at end of uptrend - blue square on top C_RP magenta
plot distributionBarPlot = if distributionBar then (high + 2 * tickSize()) else Double.NAN;
distributionBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
distributionBarPlot.SetDefaultColor (Color.magenta);
distributionBarPlot.HideBubble();
distributionBarPlot.HideTitle();

# supply test bar - pink square on bottom C_RP white
plot supplyTestBarPlot = if supplyTestBar then (low - 2 * tickSize()) else Double.NAN;
supplyTestBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
supplyTestBarPlot.SetDefaultColor(Color.white);
supplyTestBarPlot.HideBubble();
supplyTestBarPlot.HideTitle();

# no demand bar - blue squre on top C_RP orange circle
plot noDemandBarPlot = if noDemandBar then (high + 2 * tickSize()) else Double.NAN;
noDemandBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
noDemandBarPlot.SetDefaultColor(CreateColor(255, 102, 102));
noDemandBarPlot.HideBubble();
noDemandBarPlot.HideTitle();

# no supply bar - lime diamond on bottom C_RP turquoise
plot noSupplyBarPlot = if noSupplyBar then (low - 2 * tickSize()) else Double.NAN;
noSupplyBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
noSupplyBarPlot.SetDefaultColor (Color.cyan);
noSupplyBarPlot.HideBubble();
noSupplyBarPlot.HideTitle();

# effort to move up - turquoise diamond in the median of the bar C_RP green
plot effortToMoveUpBarPlot = if effortToMoveUpBar then (median) else Double.NAN;
effortToMoveUpBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
effortToMoveUpBarPlot.SetDefaultColor(CreateColor(0, 255, 0));
effortToMoveUpBarPlot.HideBubble();
effortToMoveUpBarPlot.HideTitle();

# effort to move down - yellow diamond in the median of the bar C_RP for all except red bars the circle's color is magenta
plot effortToMoveDownBarPlot = if effortToMoveDownBar && !(shortTermTrendSlope < 0 && MiddleTermTrendSlope < 0 && longTermTrendSlope < 0) then (median) else Double.NAN;
effortToMoveDownBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
effortToMoveDownBarPlot.SetDefaultColor(Color.magenta);
effortToMoveDownBarPlot.HideBubble();
effortToMoveDownBarPlot.HideTitle();

# effort to move down - yellow diamond in the median of the bar C_RP yellow circle for  Red bars
plot effortToMoveDownBarPlotYel = if effortToMoveDownBar && shortTermTrendSlope < 0 && MiddleTermTrendSlope < 0 && longtermtrendslope < 0 then (median) else Double.NAN;
effortToMoveDownBarPlotYel.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
effortToMoveDownBarPlotYel.SetDefaultColor(Color.yellow);
effortToMoveDownBarPlotYel.HideBubble();
effortToMoveDownBarPlotYel.HideTitle();



######
# Candle definitions

AssignPriceColor( if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope > 0 and longtermtrendslope > 0 then CreateColor(0, 255, 0) # UUU Green
 else if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope > 0 and longtermtrendslope < 0 then CreateColor(153, 255, 102) # UUD Lime Green
else if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope < 0 and longtermtrendslope < 0 then CreateColor(153, 255, 255) # UDD Light Cyan
else if colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope < 0 and longtermtrendslope < 0 then Color.red # DDD Red
else if colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope > 0 and longtermtrendslope > 0 then color.yellow # DUU Yellow
else if colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope < 0 and longtermtrendslope > 0 then color.orange # DDU Orange
else if colorBars then CreateColor(153, 153, 153) else GetColor(7)); # all other combinations are Light Gray


#######
# Trend Text Definitions
# C_RP 20100722 edited by Richard Paske to shorten text
# C_RP some colors changed to match symbols with text backgrounds

#AddChartLabel(trendText, concat("Vol: ", if volume > AvgVol + 2.0 * sAvgVolumeSTD then "VH"
#    else if Volume[0] > (sAvgVolume[0] + 1.0 * sAvgVolumeSTD) then "H"
#    else if (Volume[0] > sAvgVolume[0]) then ">Avg"
#    else if (Volume[0] < sAvgVolume[0] && Volume[0] > (sAvgVolume[0] - 1.0 * sAvgVolumeSTD)) then "<Avg"
#    else if (Volume[0] < (sAvgVolume[0] - 1.0 * sAvgVolumeSTD)) then "L"
#    else ""), Color.white);

AddChartLabel(trendText, concat("Vol: ", 
    if volume > UHline then "UHigh"
    else if Volume > VHline then "VHigh"
    else if Volume > Hline then "High"
    else if Volume > Lline then "Avg"
    else if Volume > VLline then "Low"
    else "VLow"), Color.white);
    
    
    
AddChartLabel(trendText, concat("Spr: ", if (spread > (avgSpread * 2.0)) then "W"
    else if (spread > avgSpread) then ">Avg"
    else "N"), Color.white);

# C_RP 20100809 added isVeryLowCloseBar and changed execution order so that both Verys and Mid execute first
AddChartLabel(trendText, concat("Cls: ", if (isVeryHighCloseBar) then "VH"
    else if (isVeryLowCloseBar) then "VL" 
else if (isMidCloseBar) then "M"
    else if (isUpCloseBar) then "H"
    else if (isDownCloseBar) then "D"
    else "NC"), Color.white);

AddChartLabel(trendText, concat("Trd: ", concat("St-", if (ShortTermTrendSlope > 0) then "U"
    else "D")), Color.white);

AddChartLabel(trendText, concat("Mt-", if (MiddleTermTrendSlope > 0) then "U" else "D"), Color.white);

AddChartLabel(trendText, concat("Lt-", if (LongTermTrendSlope > 0) then "U" else "D"), Color.white);


######
# Volume Bar Definitions

AddChartLabel(volumeDefinitions, if isUpThrustBar[0] then "Weakness on UpThrust" #C_RP Red Square
    else if upThrustConditionOne then "Weakness confirmed on Downbar after UpThrust" #C_RP Red Triangle
    else if upThrustConditionTwo && !upThrustConditionOne then "Weakness confirmed on High-volume Downbar after UpThrust" #C_RP Red DownArrow
    else if upThrustConditionThree then "Weakness confirmed on High-volume UpThrust" #C_RP Red DownArrow
 else if isTwoPerUpT then "Weakness on 2-period UpThrust" #C_RP Magenta Triangle
 else if isThreePerUpT then "Weakness on 3-period UpThrust" #C_RP Magenta Triangle
    else if isGraveDojiBar then "Reversal possible on Gravestone Doji" #C_RP Whute Triangle
  else if strengthInDownTrend then "Strength returning in Downtrend" #C_RP Cyan Square
    else if strengthInDownTrend0  then "Strength returning in long Downtrend" #C_RP Cyan Square
    else if strengthInDownTrend1 then "Strength returning on High Volume in Downtrend" #C_RP Green Square
 else if strengthInDownTrend2  then "Strength on High-volume UpBar closing on High" #C_RP Green Triangle
    else if supplyTestBar[0] then "Test for Supply" #C_RP White Square
    else if successfulSupplyTestBar[0] then "Strength confirmed on UpBar closing Near High after Test" #C_RP Cyan Triangle
    else if isStrengthConfirmationBar then "Strength confirmed on UpBar" #C_RP Green UpArrow
else if isStrengthConfirmationBar2 then "Strength confirmed on UpBar closing Near High" #C_RP Two Green UpArrows
else if isfailedstrengthsignal then "Bearish on Failed Strength Confirmation in downtrend" #C_RP Red Square
    else if distributionBar then "Distribution on High-volume UpBar closing Down in Uptrend" #C_RP Magenta Square
    else if isPseudoUpThrustBar[0] then "Weakness on Pseudo-UpThrust." #C_RP Orange Square
    else if pseudoUpThrustConfirmation then "Weakness confirmed on DownBar closing Down after PseudoUpThrust" #C_RP Orange Triangle
 else if isFailedUpthrustConfirmation then "Less Bearish on Failed UpThrust Confirmation" #C_RP Green Square
    else if supplyTestInUpTrendBar then "Test for Supply in Uptrend" #C_RP Gray Square
    else if weaknessBar then "Weakness on High-volume DownBar after High-volume UpMove" #C_RP Yellow Triangle
    else if noDemandBar then "Weakness on No Demand" #C_RP Orange Circle
    else if noSupplyBar then "Strength on No Supply" #C_RP Cyan Circle
    else if effortToMoveUpBar[0] then "Bullish on Effort-to-Rise" #C_RP Green Circle on middle of Bar
    else if effortToMoveDownBar then "Bearish on Effort-to-Fall" #C_RP Magenta or Yellow Circle on middle of Bar
    else if failedEffortUpMove then "Bearish on Failed Effort-to-Rise" #C_RP no symbol for this indication
    else if stopVolBar then "Stopping Volume at Lows indicates Downtrend end likely" #C_RP Green Circle
    else if stopVolBarHighs then "Stopping Volume at Highs indicates Uptrend end likely" #C_RP Yellow Circle
    else "",
  if isUpThrustBar[0] then Color.Red 
    else if upThrustConditionOne then Color.red
    else if upThrustConditionTwo && !upThrustConditionOne then Color.red
    else if upThrustConditionThree then Color.red
    else if isTwoPerUpT then Color.magenta
    else if isThreePerUpT then Color.magenta
    else if isGraveDojiBar then CreateColor(255, 255, 255)
    else if strengthInDownTrend1 then Color.green
    else if strengthInDownTrend0 && !strengthInDownTrend then Color.cyan
    else if strengthInDownTrend && !strengthInDownTrend1 then Color.cyan
 else if isFailedStrengthSignal then Color.red
    else if supplyTestBar[0] then Color.white
    else if successfulSupplyTestBar[0] then CreateColor(102, 255, 0)
    else if isStrengthConfirmationBar then Color.Green
    else if distributionBar then Color.magenta
    else if isPseudoUpThrustBar[0] then (CreateColor(255, 102, 102))
    else if pseudoUpThrustConfirmation then (CreateColor(255, 102, 102))
else if isFailedUpThrustConfirmation then (Color.green)
    else if supplyTestInUpTrendBar then CreateColor(153, 153, 153)
    else if strengthInDownTrend2 then Color.green
    else if weaknessBar then Color.Yellow
    else if noDemandBar then CreateColor(255, 102, 102)
    else if noSupplyBar then Color.cyan
    else if effortToMoveUpBar[0] then CreateColor(0, 255, 0)
    else if effortToMoveDownBar then Color.magenta
    else if failedEffortUpMove then Color.Blue
    else if stopVolBar then Color.green
    else if stopVolBarHighs then Color.yellow
    else Color.black);

########
# Alerts

alert(if alerts and (isUpThrustBar[0] 
     or upThrustConditionOne 
     or (upThrustConditionTwo && !upThrustConditionOne) 
     or upThrustConditionThree 
     or strengthInDownTrend1 
     or (strengthInDownTrend0 && !strengthInDownTrend)
     or (strengthInDownTrend && !strengthInDownTrend1)
     or supplyTestBar[0] 
     or successfulSupplyTestBar[0] 
     or isStrengthConfirmationBar 
     or distributionBar 
     or isPseudoUpThrustBar[0] 
     or pseudoUpThrustConfirmation 
     or supplyTestInUpTrendBar 
     or strengthInDownTrend2 
     or weaknessBar 
     or noDemandBar 
     or noSupplyBar 
     or effortToMoveUpBar[0] 
     or effortToMoveDownBar 
     or failedEffortUpMove 
     or stopVolBar) then 1 else 0, if isUpThrustBar[0] then "An Upthrust Bar. A sign of weakness."
    else if upThrustConditionOne then "A downbar after an Upthrust. Confirm weakness."
    else if upThrustConditionTwo && !upThrustConditionOne then "A High Volume downbar after an Upthrust. Confirm weakness."
    else if upThrustConditionThree then "This upthrust at very High Volume, Confirms weakness."
    else if strengthInDownTrend1 then "Strength seen returning after a down trend. High volume adds to strength. "
    else if strengthInDownTrend0 && !strengthInDownTrend then "Strength seen returning after a down trend."
    else if strengthInDownTrend && !strengthInDownTrend1 then "Strength seen returning after a long down trend."
    else if supplyTestBar[0] then "Test for supply."
    else if successfulSupplyTestBar[0] then "An Upbar closing near High after a Test confirms strength."
    else if isStrengthConfirmationBar then "An Upbar closing near High. Confirms return of Strength."
    else if distributionBar then "A High Volume Up Bar closing down in a uptrend shows Distribution."
    else if isPseudoUpThrustBar[0] then "Psuedo UpThrust.  A Sign of Weakness."
    else if pseudoUpThrustConfirmation then "A Down Bar closing down after a Pseudo Upthrust confirms weakness."
    else if supplyTestInUpTrendBar then "Test for supply in a uptrend. Sign of Strength."
    else if strengthInDownTrend2 then "High volume upbar closing on the high indicates strength."
    else if weaknessBar then "High volume Downbar after an upmove on high volume indicates weakness."
    else if noDemandBar then "No Demand. A sign of Weakness."
    else if noSupplyBar then "No Supply. A sign of Strength."
    else if effortToMoveUpBar[0] then "Effort to Rise. Bullish sign."
    else if effortToMoveDownBar then "Effort to Fall. Bearish sign."
    else if failedEffortUpMove then "Effort to Move up has failed. Bearish sign."
    else if stopVolBar then "Stopping volume. Normally indicates end of bearishness is nearing."
    else "", Alert.BAR, Sound.Ding);

# Red Square           - UpThrust bar.
# Blue Diamond         - Reversal possible, yesterday was high volume wide spread up bar, but 
#                        today we reached 10 days high with low close wide spread down bar.
# Red Triangle Down    - UpThrust confirmation.
# Lime Square          - Strength bar (either strength is showing in down trend or a supply 
#                        test in up trend).
# Yellow Triangle Up   - An Upbar closing near High after a Test confirms strength.
# Lime Diamond         - Stopping volume. Normally indicates end of bearishness is nearing 
#                        /OR/ No supply.
# Lime Triangle Up     - The previous bar saw strength coming back, This upbar confirms strength.
# Blue Square          - Psuedo UpThrust, A Sign of Weakness /OR/ A High Volume Up Bar closing
#                        down in a uptrend shows Distribution /OR/ No Demand.
# Blue Triangle Down   - A Down Bar closing down after a Pseudo Upthrust confirms weakness.
# Yellow Triangle Down - High volume Downbar after an upmove on high volume indicates weakness.
# Aqua Triangle Up     - High volume upbar closing on the high indicates strength (in short 
#                        term down trend).
# Deep Pink Square     - Test for supply.
# Turquoise Diamond    - Effort to Rise. Bullish sign.
# Yellow Diamond       - Effort to Fall. Bearish sign.

Reply With Quote
Thanked by:
  #265 (permalink)
 
marcovth's Avatar
 marcovth 
Canada
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES,6E
Posts: 25 since Jun 2010
Thanks Given: 1
Thanks Received: 30

VSA7 lower (on_volume) study. This is a separate study from the one above !

If you select a volume average type in the upper study, you should also select the same volume average type in the lower study.

I have tried to make one study out of it, but that didn't work.

I think this script shows that the EMA30 looks a bit odd when you use overnight sessions.
I think the day/night split makes more sense, even though it was not implemented by the TradeGuider people.

The EMA30 and day/night split looks very similar when you only use regular trading hours with e.g. the SPY.



 
Code
declare on_volume;
declare real_size;


#######
# Arguments
input AvgVolumeType = {default EMA, Day_Night_Split, Hourly_Avg};
input volumeEMALength = 30;


def MarketsHours = if (secondsFromTime(0930) >= 0) and (secondsTillTime(1610) >= 0) then yes else no;

def Hour00 = if (secondsFromTime(0000) >= 0) and (secondsTillTime(0100) > 0) then yes else no;
def Hour01 = if (secondsFromTime(0100) >= 0) and (secondsTillTime(0200) > 0) then yes else no;
def Hour02 = if (secondsFromTime(0200) >= 0) and (secondsTillTime(0300) > 0) then yes else no;
def Hour03 = if (secondsFromTime(0300) >= 0) and (secondsTillTime(0400) > 0) then yes else no;
def Hour04 = if (secondsFromTime(0400) >= 0) and (secondsTillTime(0500) > 0) then yes else no;
def Hour05 = if (secondsFromTime(0500) >= 0) and (secondsTillTime(0600) > 0) then yes else no;
def Hour06 = if (secondsFromTime(0600) >= 0) and (secondsTillTime(0700) > 0) then yes else no;
def Hour07 = if (secondsFromTime(0700) >= 0) and (secondsTillTime(0800) > 0) then yes else no;
def Hour08 = if (secondsFromTime(0800) >= 0) and (secondsTillTime(0900) > 0) then yes else no;
def Hour09 = if (secondsFromTime(0900) >= 0) and (secondsTillTime(0930) > 0) then yes else no;
def Hour930 = if (secondsFromTime(0930) >= 0) and (secondsTillTime(1000) > 0) then yes else no;
def Hour10 = if (secondsFromTime(1000) >= 0) and (secondsTillTime(1100) > 0) then yes else no;
def Hour11 = if (secondsFromTime(1100) >= 0) and (secondsTillTime(1200) > 0) then yes else no;
def Hour12 = if (secondsFromTime(1200) >= 0) and (secondsTillTime(1300) > 0) then yes else no;
def Hour13 = if (secondsFromTime(1300) >= 0) and (secondsTillTime(1400) > 0) then yes else no;
def Hour14 = if (secondsFromTime(1400) >= 0) and (secondsTillTime(1500) > 0) then yes else no;
def Hour15 = if (secondsFromTime(1500) >= 0) and (secondsTillTime(1600) > 0) then yes else no;
def Hour16 = if (secondsFromTime(1600) >= 0) and (secondsTillTime(1630) > 0) then yes else no;
def Hour1630 = if (secondsFromTime(1630) >= 0) and (secondsTillTime(1700) > 0) then yes else no;
def Hour17 = if (secondsFromTime(1700) >= 0) and (secondsTillTime(1800) > 0) then yes else no;
def Hour18 = if (secondsFromTime(1800) >= 0) and (secondsTillTime(1900) > 0) then yes else no;
def Hour19 = if (secondsFromTime(1900) >= 0) and (secondsTillTime(2000) > 0) then yes else no;
def Hour20 = if (secondsFromTime(2000) >= 0) and (secondsTillTime(2100) > 0) then yes else no;
def Hour21 = if (secondsFromTime(2100) >= 0) and (secondsTillTime(2200) > 0) then yes else no;
def Hour22 = if (secondsFromTime(2200) >= 0) and (secondsTillTime(2300) > 0) then yes else no;
def Hour23 = if (secondsFromTime(2300) >= 0) and (secondsTillTime(2359) >= 0) then yes else no;


rec SumVol00 = if Hour00 then SumVol00[1] + volume else SumVol00[1];
rec nBarsHour00 = if Hour00 then nBarsHour00[1] + 1 else nBarsHour00[1];
def AvgVolHour00 = SumVol00 / nBarsHour00;

rec SumVol01 = if Hour01 then SumVol01[1] + volume else SumVol01[1];
rec nBarsHour01 = if Hour01 then nBarsHour01[1] + 1 else nBarsHour01[1];
def AvgVolHour01 = SumVol01 / nBarsHour01;

rec SumVol02 = if Hour02 then SumVol02[1] + volume else SumVol02[1];
rec nBarsHour02 = if Hour02 then nBarsHour02[1] + 1 else nBarsHour02[1];
def AvgVolHour02 = SumVol02 / nBarsHour02;

rec SumVol03 = if Hour03 then SumVol03[1] + volume else SumVol03[1];
rec nBarsHour03 = if Hour03 then nBarsHour03[1] + 1 else nBarsHour03[1];
def AvgVolHour03 = SumVol03 / nBarsHour03;

rec SumVol04 = if Hour04 then SumVol04[1] + volume else SumVol04[1];
rec nBarsHour04 = if Hour04 then nBarsHour04[1] + 1 else nBarsHour04[1];
def AvgVolHour04 = SumVol04 / nBarsHour04;

rec SumVol05 = if Hour05 then SumVol05[1] + volume else SumVol05[1];
rec nBarsHour05 = if Hour05 then nBarsHour05[1] + 1 else nBarsHour05[1];
def AvgVolHour05 = SumVol05 / nBarsHour05;

rec SumVol06 = if Hour06 then SumVol06[1] + volume else SumVol06[1];
rec nBarsHour06 = if Hour06 then nBarsHour06[1] + 1 else nBarsHour06[1];
def AvgVolHour06 = SumVol06 / nBarsHour06;

rec SumVol07 = if Hour07 then SumVol07[1] + volume else SumVol07[1];
rec nBarsHour07 = if Hour07 then nBarsHour07[1] + 1 else nBarsHour07[1];
def AvgVolHour07 = SumVol07 / nBarsHour07;

rec SumVol08 = if Hour08 then SumVol08[1] + volume else SumVol08[1];
rec nBarsHour08 = if Hour08 then nBarsHour08[1] + 1 else nBarsHour08[1];
def AvgVolHour08 = SumVol08 / nBarsHour08;

rec SumVol09 = if Hour09 then SumVol09[1] + volume else SumVol09[1];
rec nBarsHour09 = if Hour09 then nBarsHour09[1] + 1 else nBarsHour09[1];
def AvgVolHour09 = SumVol09 / nBarsHour09;

rec SumVol930 = if Hour930 then SumVol930[1] + volume else SumVol930[1];
rec nBarsHour930 = if Hour930 then nBarsHour930[1] + 1 else nBarsHour930[1];
def AvgVolHour930 = SumVol930 / nBarsHour930;

rec SumVol10 = if Hour10 then SumVol10[1] + volume else SumVol10[1];
rec nBarsHour10 = if Hour10 then nBarsHour10[1] + 1 else nBarsHour10[1];
def AvgVolHour10 = SumVol10 / nBarsHour10;

rec SumVol11 = if Hour11 then SumVol11[1] + volume else SumVol11[1];
rec nBarsHour11 = if Hour11 then nBarsHour11[1] + 1 else nBarsHour11[1];
def AvgVolHour11 = SumVol11 / nBarsHour11;

rec SumVol12 = if Hour12 then SumVol12[1] + volume else SumVol12[1];
rec nBarsHour12 = if Hour12 then nBarsHour12[1] + 1 else nBarsHour12[1];
def AvgVolHour12 = SumVol12 / nBarsHour12;

rec SumVol13 = if Hour13 then SumVol13[1] + volume else SumVol13[1];
rec nBarsHour13 = if Hour13 then nBarsHour13[1] + 1 else nBarsHour13[1];
def AvgVolHour13 = SumVol13 / nBarsHour13;

rec SumVol14 = if Hour14 then SumVol14[1] + volume else SumVol14[1];
rec nBarsHour14 = if Hour14 then nBarsHour14[1] + 1 else nBarsHour14[1];
def AvgVolHour14 = SumVol14 / nBarsHour14;

rec SumVol15 = if Hour15 then SumVol15[1] + volume else SumVol15[1];
rec nBarsHour15 = if Hour15 then nBarsHour15[1] + 1 else nBarsHour15[1];
def AvgVolHour15 = SumVol15 / nBarsHour15;

rec SumVol16 = if Hour16 then SumVol16[1] + volume else SumVol16[1];
rec nBarsHour16 = if Hour16 then nBarsHour16[1] + 1 else nBarsHour16[1];
def AvgVolHour16 = SumVol16 / nBarsHour16;

rec SumVol1630 = if Hour1630 then SumVol1630[1] + volume else SumVol1630[1];
rec nBarsHour1630 = if Hour1630 then nBarsHour1630[1] + 1 else nBarsHour1630[1];
def AvgVolHour1630 = SumVol1630 / nBarsHour1630;

rec SumVol17 = if Hour17 then SumVol17[1] + volume else SumVol17[1];
rec nBarsHour17 = if Hour17 then nBarsHour17[1] + 1 else nBarsHour17[1];
def AvgVolHour17 = SumVol17 / nBarsHour17;

rec SumVol18 = if Hour18 then SumVol18[1] + volume else SumVol18[1];
rec nBarsHour18 = if Hour18 then nBarsHour18[1] + 1 else nBarsHour18[1];
def AvgVolHour18 = SumVol18 / nBarsHour18;

rec SumVol19 = if Hour19 then SumVol19[1] + volume else SumVol19[1];
rec nBarsHour19 = if Hour19 then nBarsHour19[1] + 1 else nBarsHour19[1];
def AvgVolHour19 = SumVol19 / nBarsHour19;

rec SumVol20 = if Hour20 then SumVol20[1] + volume else SumVol20[1];
rec nBarsHour20 = if Hour20 then nBarsHour20[1] + 1 else nBarsHour20[1];
def AvgVolHour20 = SumVol20 / nBarsHour20;

rec SumVol21 = if Hour21 then SumVol21[1] + volume else SumVol21[1];
rec nBarsHour21 = if Hour21 then nBarsHour21[1] + 1 else nBarsHour21[1];
def AvgVolHour21 = SumVol21 / nBarsHour21;

rec SumVol22 = if Hour22 then SumVol22[1] + volume else SumVol22[1];
rec nBarsHour22 = if Hour22 then nBarsHour22[1] + 1 else nBarsHour22[1];
def AvgVolHour22 = SumVol22 / nBarsHour22;

rec SumVol23 = if Hour23 then SumVol23[1] + volume else SumVol23[1];
rec nBarsHour23 = if Hour23 then nBarsHour23[1] + 1 else nBarsHour23[1];
def AvgVolHour23 = SumVol23 / nBarsHour23;

rec SumVolMarketsHours = if MarketsHours then SumVolMarketsHours[1] + volume else SumVolMarketsHours[1];
rec nBarsMarketsHours = if MarketsHours then nBarsMarketsHours[1] + 1 else nBarsMarketsHours[1];
def AvgVolMarketsHours = SumVolMarketsHours / nBarsMarketsHours;

rec SumVolOFFMarketsHours = if !MarketsHours then SumVolOFFMarketsHours[1] + volume else SumVolOFFMarketsHours[1];
rec nBarsOFFMarketsHours = if !MarketsHours then nBarsOFFMarketsHours[1] + 1 else nBarsOFFMarketsHours[1];
def AvgVolOFFMarketsHours = SumVolOFFMarketsHours / nBarsOFFMarketsHours;

def AvgVolHourly=
if Hour00 then AvgVolHour00 else
if Hour01 then AvgVolHour01 else
if Hour02 then AvgVolHour02 else
if Hour03 then AvgVolHour03 else
if Hour04 then AvgVolHour04 else
if Hour05 then AvgVolHour05 else
if Hour06 then AvgVolHour06 else
if Hour07 then AvgVolHour07 else
if Hour08 then AvgVolHour08 else
if Hour09 then AvgVolHour09 else
if Hour930 then AvgVolHour930 else
if Hour10 then AvgVolHour10 else
if Hour11 then AvgVolHour11 else
if Hour12 then AvgVolHour12 else
if Hour13 then AvgVolHour13 else
if Hour14 then AvgVolHour14 else
if Hour15 then AvgVolHour15 else
if Hour16 then AvgVolHour16 else
if Hour1630 then AvgVolHour1630 else
if Hour17 then AvgVolHour17 else
if Hour18 then AvgVolHour18 else
if Hour19 then AvgVolHour19 else
if Hour20 then AvgVolHour20 else
if Hour21 then AvgVolHour21 else
if Hour22 then AvgVolHour22 else
if Hour23 then AvgVolHour23 else
 double.nan;

plot AvgVolDailyMarketHrs = if MarketsHours then AvgVolMarketsHours else double.nan;
plot AvgVolNightlyOFFMarketHrs = if !MarketsHours then AvgVolOFFMarketsHours else double.nan;

plot AvgVolHourlyBars=AvgVolHourly;

# Calculate Volume moving average and it's standard deviation
rec sAvgVolume =  compoundValue(volumeEMALength, Average(volume, volumeEMALength), Double.NaN);
def sAvgVolumeSTD = stdev(sAvgVolume, volumeEMALength);

def AvgVol=
if AvgVolumeType==AvgVolumeType.Hourly_Avg then AvgVolHourly
else if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume
else if MarketsHours then AvgVolMarketsHours else AvgVolOFFMarketsHours
;


def UHline =if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume[0] + 2.0 * sAvgVolumeSTD else AvgVol + (AvgVol * 1);
def VHline =if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume[0] + 1.0 * sAvgVolumeSTD else AvgVol + (AvgVol * 0.65);
def Hline =if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume[0] else AvgVol + (AvgVol * 0.15);
def Lline =if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume[0] - 1.0 * sAvgVolumeSTD else AvgVol - (AvgVol * 0.15);
def VLline =if AvgVolumeType==AvgVolumeType.EMA then sAvgVolume[0] - 2.0 * sAvgVolumeSTD else AvgVol - (AvgVol * 0.65);
def zeroline = 0;


AddCloud(VHline, UHline, color.pink, color.pink);
AddCloud(Hline, VHline, color.MAGENTA, color.MAGENTA);
AddCloud(Lline, Hline, color.BLUE, color.BLUE);
AddCloud(VLline, Lline, color.MAGENTA, color.MAGENTA);
AddCloud(zeroline, VLline, color.pink, color.pink);

Reply With Quote
Thanked by:
  #266 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154

marcovth,

Nice work. One possibility for your code is to place it into a text file and upload it as an attachment. Actually, it's best that you make them attachments. I get a lot of errors when cutting and pasting. Some of the errors are from repeditive definitions of the same variable. There's a lot of code for various hours of the day. How does that help with a trading decision?

Reply With Quote
  #267 (permalink)
 
marcovth's Avatar
 marcovth 
Canada
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES,6E
Posts: 25 since Jun 2010
Thanks Given: 1
Thanks Received: 30

The number of NYSE stocks that have risen in price compared to their close on the previous trading day are called "Advancing Issues". The number of NYSE stocks that have fallen in price compared to their close on the previous trading day are called "Declining Issues".

Of course, the stocks (issues) are being traded in volume, "Advancing Volume" and "Declining Volume".

I think we can use that volume to approximate the buying/selling pressure when trading e.g. the ES and SPY.

This could give a new level of understanding to VSA.

I made the following code.
- In green, you see the number of Advancing Volume vs yesterdays close.
- In red, you see the number of Declining Volume vs yesterdays close.
- A bar greater than 0, shows that the resp. volume has increased vs yesterday.
- A bar less than 0, shows that the resp. volume has decreased vs yesterday.

It seems the numbers for overnight trading get's accumulated and is shown in the 9:30 bar, therefore I skip that bar to avoid a giant spike.

Take a look at it for yourself, and see if it makes any sense when explaining VSA signals.
I only played with it for the day, so I don't have trading rules yet.

 
Code
declare lower;

def MarketsHours = if (secondsFromTime(0931) >= 0) and (secondsTillTime(1600) >= 0) then yes else no;

rec UVOL = close("$UVOL");
rec DVOL = close("$DVOL");
def TVol = close("$TVOL");


rec SumVolMarketsHours = if MarketsHours then SumVolMarketsHours[1] + volume else SumVolMarketsHours[1];
rec nBarsMarketsHours = if MarketsHours then nBarsMarketsHours[1] + 1 else nBarsMarketsHours[1];
def AvgVolMarketsHours = SumVolMarketsHours / nBarsMarketsHours;

rec SumTVol = if MarketsHours then SumTVol[1] + (TVol - TVOL[1]) else SumTVol[1];
rec nBarsTVOL = if MarketsHours then nBarsTVOL[1] + 1 else nBarsTVOL[1];
def AvgTVol = SumTVol / nBarsTVOL;

rec UVOLspike = ((UVOL - UVOL[1]) / AvgTVol);
rec DVOLspike = ((DVOL - DVOL[1]) / AvgTVol);

plot dffUVOL = if MarketsHours then UVOLspike else double.nan;
dffUVOL.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
dffUVOL.DefineColor("Highest", Color.GREEN);
dffUVOL.DefineColor("Lowest", Color.DARK_GREEN);
dffUVOL.AssignNormGradientColor(5, dffUVOL.color("Lowest"), dffUVOL.color("Highest"));
dffUVOL.SetLineWeight(1);


plot dffDVOL = if MarketsHours then DVOLspike else double.nan;
dffDVOL.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
dffDVOL.DefineColor("Highest", Color.DARK_RED);
dffDVOL.DefineColor("Lowest", Color.RED);
dffDVOL.AssignNormGradientColor(5, dffDVOL.color("Highest"), dffDVOL.color("Lowest"));
dffDVOL.SetLineWeight(3);



plot ZeroLine = 0;
ZeroLine.SetDefaultColor(color.GRAY);

def UpVol = ((UVol / TVol) - 0.5) * 2;
def DnVol = ((DVol / TVol) - 0.5) * 2;
plot UV = UpVol;
UV.SetDefaultColor(color.GREEN);
plot DV = DnVol;
DV.SetDefaultColor(color.RED);

Reply With Quote
Thanked by:
  #268 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154

You're very creative in your approach to VSA. You must have studied it thoroughly with years of experience using it.

Reply With Quote
  #269 (permalink)
 tst1 
Magadan Russia
 
Posts: 79 since Nov 2010


StockJock View Post
Attached is a test code for reversals; however, I don't think it turned out very well. Also, I'm using my own bar colors.

Hi SJ! What is the meaning of the colours?
tnx

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



tst1 View Post
Hi SJ! What is the meaning of the colours?
tnx

I think a better question would be "How do the colors help in trading?" No one seems to know how they help; whether they're my colors or some one else's.

Reply With Quote




Last Updated on May 21, 2023


© 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