 # Upper Gaussian Mean crossovers with lower macd/gacd

#### J007RMC

##### Well-known member
2019 Donor
• markos

#### J007RMC

##### Well-known member
2019 Donor
Last edited:
• #### J007RMC

##### Well-known member
2019 Donor
The first of the lower two indicators above is a gaussian mean cross with arrows and so I paired it with the WT_LB Short Name TV and I'm getting good signals both short and long where I take confirmation if present from the WT_LB Short Name TV.. today I ran a 1min and a 512t I like what I'm seeing with the indicator minus the labels.

Code:
``````  # GaussianMeanCrossWithProfitability_JQ

declare lower;
#plot Data = close;
input GaussianLength = 5;
input GaussianLengthLong = 20;
input betaDev = 7.0; #hint betaDev: adjust this value till the label indicates a minimum of 68.2% of closes

# Trying to achieve Normal Distribution
# Mobius
# V01.09.2015
def c;
def w;
def beta;
def alpha;
def G;
plot GaussianMean;
GaussianMean.SetDefaultColor(Color.WHITE);
GaussianMean.SetLineWeight(2);
c = close;
w = (2 * Double.Pi / GaussianLength);
beta = (1 - Cos(w)) / (Power(1.414, 2.0 / betaDev) - 1 );
alpha = (-beta + Sqrt(beta * beta + 2 * beta));
G = Power(alpha, 4) * c +
4 * (1 – alpha) * G – 6 * Power( 1 - alpha, 2 ) * G +
4 * Power( 1 - alpha, 3 ) * G - Power( 1 - alpha, 4 ) * G;
GaussianMean = G;

#*******************************************************************************;
# Trying to achieve Normal Distribution
# Mobius
# V01.09.2015
def c2;
def w2;
def beta2;
def alpha2;
def G2;
plot GaussianMeanLong;
GaussianMeanLong.SetDefaultColor(Color.YELLOW);
GaussianMeanLong.SetLineWeight(2);
c2 = close;
w2 = (2 * Double.Pi / GaussianLengthLong);
beta2 = (1 - Cos(w2)) / (Power(1.414, 2.0 / betaDev) - 1 );
alpha2 = (-beta2 + Sqrt(beta2 * beta2 + 2 * beta2));
G2 = Power(alpha2, 4) * c2 +
4 * (1 – alpha2) * G2 – 6 * Power( 1 - alpha2, 2 ) * G2 +
4 * Power( 1 - alpha2, 3 ) * G2 - Power( 1 - alpha2, 4 ) * G2;
GaussianMeanLong = G2;
## End Gaussian Codes
#    ---------------------------------------------------
## Begin Plots
plot BullishCross = GaussianMean crosses above GaussianMeanLong;
BullishCross.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BullishCross.SetDefaultColor(Color.UPTICK);
plot BearishCross = GaussianMean crosses below GaussianMeanLong;
BearishCross.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BearishCross.SetDefaultColor(Color.DOWNTICK);

# Total Cross Count in Bubbles
# TsL for fredw
# Nube 9.24.18
# universals
def bn = BarNumber();
#def c = close;
def na = Double.NaN;
# variables
def upCross = GaussianMean crosses above GaussianMeanLong;
def upCrossCt = CompoundValue(1,
if upCross
then upCrossCt + 1
else upCrossCt, 0);
def currentUpCrossCount = HighestAll(if !IsNaN(c) && IsNaN(c[-1])
then upCrossCt else na);
def upCrossBar = if upCross
then bn else upCrossBar;
# plots
# alternative version for those who prefer to also use GetValue()
#def currentBar = HighestAll(if !IsNaN(c) && IsNaN(c[-1])
# then bn else na);
#def getUpCount = GetValue(upCrossCt, bn - currentBar);

## ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
## ProfitLossSnippet_v04_JQ
## Profit Loss Code Snippet
## This snippet should be appendable to most studies will little effort
## Signal COde portion should be adjusted to capture buy/sell open/close signals
## v04    Splitting into Long only and short only sections
## V03 - 10.20.2018 - JQ - Correct calculation of Profit Loss yet again
## V02.1 - 071715 - Dilbert - Correct calculation of profitLoss again
## V02 - 071515 - Dilbert - Correct calculation of profitLoss
## Profit/Loss label and bubbles, added by linus (2014-07-31)
## Note: Insert at the bottom of Mobius' RSI in Laguerre Time V02.07.2014 study.

## Signal Code
## Signal Code needs to be adjusted to the script to which this snippet is appended
# End Profit/Loss Code``````

Last edited:
• Gildes

##### Member
Can we improve the result if we long with an additional condition (when price is above VWAP) and short (when price is below VWAP)

#### J007RMC

##### Well-known member
2019 Donor
I do think this has potential Ive been trading the indicator. I can envision a vwap crossover with alerts. And somehow normalizing the study with an added WT_LB Short Name TV. Along with this I am also using the

# Leavitt, Jay A., PhD . “Beyond The Hull With Leavitt Projections,” Technical Analysis of StockS & commoditieS, Volume 35: February.
script LeavittProjection indicator.

Code:
``````input y = close;
input n = 20;
rec x = x + 1;
def a = (n * sum(x * y, n) - sum(x, n) * sum(y, n) ) / ( n *sum(Sqr(x), n) - Sqr(sum(x, n)));
def b = (sum(Sqr(x), n) * sum(y, n) - sum(x, n) * sum(x *y, n) ) / ( n * sum(Sqr(x), n) - Sqr(sum(x, n)));
plot LeavittProjection= a*x+ b;
}
script LeavittConvolution
{ input price = close;
input n = 20;
def intLength = Floor(Sqrt(n));
plot LeavittConvolution = LeavittProjection (LeavittProjection (price, n), intLength);
}
def price = Close;
input length = 9;
def intLength = Floor(Sqrt(length));
plot LeavittConvolution = LeavittProjection (LeavittProjection (price, length), intLength);
LeavittConvolution.AssignValueColor(if LeavittConvolution > LeavittConvolution  then Color.GREEN else Color.RED);``````

Last edited:

#### J007RMC

##### Well-known member
2019 Donor
The LeavittProjection moving avg and Im sure we have something like this here just cannot find it
but the hull not sure about the difference between the two averages.

#### HighBredCloud

##### Well-known member
VIP
@J007RMC That Gap % label...did you get that from a code found here? And does this tell you how much the gap filled on a gap down or how much it gapped up and fell?

#### J007RMC

##### Well-known member
2019 Donor
The indicator shows percent filled and Im pretty dure I found the label here.
Code:
``````# TS_GapFill
# [email protected]
# Last Update 28 Jan 2010
# Last Update 16 Jan 2019 by Jerry Investor
input marketOpenTime = 0930;
input marketCloseTime = 1615;
def yesterdaysClose = close(period = "DAY" );
def secondsFromOpen =  SecondsFromTime(marketOpenTime);
def secondsTillClose = SecondsTillTime(marketCloseTime);
def marketOpen = if secondsFromOpen >= 0 and secondsTillClose >= 0 then 1 else 0;
rec regularHoursOpen = if (secondsFromOpen >= 0 and secondsFromOpen < 0) or
(GetDay() != GetDay()) then open else regularHoursOpen;
def newDay = if GetDay() != GetDay() then 1 else 0;
rec regHoursHigh = if newDay then high else if marketOpen then
if high > regHoursHigh then high else regHoursHigh else high;
rec regHoursLow = if newDay then low else if marketOpen then
if low < regHoursLow then low else regHoursLow else low;
def yc = if marketOpen then yesterdaysClose else Double.NaN;
def o = if marketOpen then regularHoursOpen else Double.NaN;
def hg = o + (yc - o) / 2;
def gapUp = if yc < o then 1 else 0;
def gapDown = if yc > o then 1 else 0;
def gapRemaining = if gapUp then
Max(regHoursLow - yc, 0) else
if gapDown then Max(yc - regHoursHigh, 0) else 0;
def percentRemaining = 100 * gapRemaining / AbsValue(yc - o);
def gapFilled = if percentRemaining == 0 then 1 else 0;
def halfGapFilled = if percentRemaining <= 50 then 1 else 0;
plot gH = if (gapUp and !gapFilled and marketOpen and !newDay[-1])
then regHoursLow else if (gapDown and !gapFilled and marketOpen and !newDay[-1])
then yc else Double.NaN;
plot gL = if (gapUp and !gapFilled and marketOpen and !newDay[-1])
then yc else if (gapDown and !gapFilled and marketOpen and !newDay[-1])
then regHoursHigh else Double.NaN;
plot hGF = if !gapFilled and !halfGapFilled and marketOpen and !newDay[-1]
then hg else Double.NaN;
gH.SetPaintingStrategy(PaintingStrategy.DASHES);
gH.AssignValueColor(if gapDown then Color.DARK_RED else Color.DARK_GREEN);
gL.SetPaintingStrategy(PaintingStrategy.DASHES);
gL.AssignValueColor(if gapDown then Color.DARK_RED else Color.DARK_GREEN);
hGF.SetStyle(Curve.LONG_DASH);
hGF.SetDefaultColor(Color.DARK_GRAY);
gH.HideBubble();
gL.HideBubble();
hGF.HideBubble();