Need Help with Laguerre moving averge

J007RMC

J007RMC

Well-known member
2019 Donor
VIP
I'm wanting to have a Laguerre moving average x2. Meaning two Laguerre moving averages so I can change the base color and length independently for each. My ideal is to set one at 10 and the other at 30. For instance change to blue base in red the other change to green base into red and back.
 
J007RMC

J007RMC

Well-known member
2019 Donor
VIP
Well I do have question too say Im watching my watchlist and Im seeing both bull and bear counting bars, for instance bull count 3 bear count 5 different stocks? I dont understand the theory behind the counts? Thanks

Code:
# HA Watchlist
# Paris
# 2.9.2019

# Paris: Vide Mobius comments that Mary's HA defs were wrong,
# changed the definitions for HAhigh, HAlow, and HAclose.
# Also added extra logic that resets counts for state transitions

def HAopen;
def HAhigh;
def HAlow;
def HAclose;
HAopen = CompoundValue(1, HAopen[1] + HAclose[1], open[1] + close[1])/2;
HAhigh = Max(high, Max(HAclose, HAopen));
HAlow = Min(low, Min(HAclose, HAopen));
haclose = OHLC4;
def noWickBullish = haClose > haOpen and haOpen == haLow;
def nowickBearish = haClose < haOpen and haOpen == haHigh;

def bullStateCounter;
def bearStateCounter;
if noWickBullish
    {
     bullStateCounter = bullStateCounter[1] + 1;
     bearStateCounter = 0;
    }
else if nowickBearish
    {
     bullStateCounter = 0;
     bearStateCounter = bearStateCounter[1] + 1;
    }
else
    {
     bullStateCounter = bullStateCounter[1];
     bearStateCounter = bearStateCounter[1];
    }
addLabel(1, if bullStateCounter then "Buy Signal = " + bullStateCounter else “Sell Signal = " + bearStateCounter,
            if bullStateCounter then color.green else color.red);

# Added logic that resets counts for state transitions

def BullCount = if bullStateCounter and bearStateCounter[1]
                then 1
                else if bullStateCounter >= 1
                     then BullCount[1] + 1
                else BullCount[1];
def BearCount = if bearStateCounter and bullStateCounter[1]
                then 1
                else if bearStateCounter >= 1
                     then BearCount[1] + 1
                else BearCount[1];
AddLabel(bullStateCounter, "Bull Count = " + BullCount, color.cyan);
AddLabel(bearStateCounter, "Bear Count = " + BearCount, color.pink);

AssignPriceColor(if HAclose > HAopen then color.green else color.red);
# End Code
 
Last edited:

Similar threads

Top