abestinkin8
New member
Hello again --
I'm trying to take 2 studies and make them into 2 separate watchlist columns. One is Moxie Slippage, and the other is BonBon's Heikn_Ashi. This is developed from this thread: https://usethinkscript.com/threads/moxie-indicator-trend-trader-pro-strategies-combined.6187/. (on page 6 he posts the script for the upper section, which is what I am modifying.
Rather than having long arrows or short arrows, I'd like the watchlist column to light up Dark Green/Dark Red whenever the arrows would appear on the chart. Then they would be Gray for everything else.
Right now, it lights up green whenever the long arrows show up. This is good and the ideal function of what I want it to do. However, I would like the boxes to be gray the rest of the time (unless the short arrow/dark red box would show up). It just displays NaN everywhere. I know which part of the script needs to be modified (anywhere it is double.nan) I'm just not sure how to tighten this up a bit.
Here is my code so far:
input lookback = 5; # past N minutes
def currentAggPeriod = GetAggregationPeriod();
def higherAggPeriod =
if currentAggPeriod <= AggregationPeriod.TWO_MIN then AggregationPeriod.FIVE_MIN
else if currentAggPeriod <= AggregationPeriod.THREE_MIN then AggregationPeriod.TEN_MIN
else if currentAggPeriod <= AggregationPeriod.FIVE_MIN then AggregationPeriod.FIFTEEN_MIN
else if currentAggPeriod <= AggregationPeriod.TEN_MIN then AggregationPeriod.THIRTY_MIN
else if currentAggPeriod <= AggregationPeriod.FIFTEEN_MIN then AggregationPeriod.HOUR
else if currentAggPeriod <= AggregationPeriod.THIRTY_MIN then AggregationPeriod.TWO_HOURS
else if currentAggPeriod <= AggregationPeriod.TWO_HOURS then AggregationPeriod.DAY
else if currentAggPeriod <= AggregationPeriod.FOUR_HOURS then AggregationPeriod.TWO_DAYS
else if currentAggPeriod <= AggregationPeriod.DAY then AggregationPeriod.WEEK
else if currentAggPeriod <= AggregationPeriod.WEEK then AggregationPeriod.MONTH
else AggregationPeriod.QUARTER
;
script MoxieFunc {
input price = close;
def vc1 = ExpAverage(price, 12) - ExpAverage(price , 26);
def va1 = ExpAverage(vc1, 9);
plot data = (vc1 - va1) * 3;
}
def price =
if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN then high(period = higherAggPeriod)
else close(period = higherAggPeriod)
;
def Moxie = MoxieFunc(price);
def longTrigger = if Moxie > 0 and Moxie[1] <= 0 then Moxie else Double.NaN;
def longArrowPosition =
# first arrow
if Moxie == longTrigger and Moxie != Moxie[1] then low
# consecutive arrows at same position
else if Moxie == longTrigger and Moxie == Moxie[1] then longArrowPosition[1]
else Double.NaN;
plot shortTrigger = if Moxie < 0 and Moxie[1] >= 0 then Moxie else Double.NaN;
def shortArrowPosition =
# first arrow
if Moxie == shortTrigger and Moxie != Moxie[1] then high
# consecutive arrows at same position
else if Moxie == shortTrigger and Moxie == Moxie[1] then shortArrowPosition[1]
else Double.NaN;
AssignBackgroundColor(if longtrigger then color.darK_GREEN
else if shorttrigger then color.dark_RED
else color.gray);
AssignPriceColor(if longtrigger then color.darK_GREEN
else if shorttrigger then color.darK_RED
else color.gray);
EDIT: One other thing I'd like to do is have it sort only whether it is dark green or dark red, rather than by the Moxie number. That way when a buy arrow shows up it would automatically move to the top of the watchlist.
I'm trying to take 2 studies and make them into 2 separate watchlist columns. One is Moxie Slippage, and the other is BonBon's Heikn_Ashi. This is developed from this thread: https://usethinkscript.com/threads/moxie-indicator-trend-trader-pro-strategies-combined.6187/. (on page 6 he posts the script for the upper section, which is what I am modifying.
Rather than having long arrows or short arrows, I'd like the watchlist column to light up Dark Green/Dark Red whenever the arrows would appear on the chart. Then they would be Gray for everything else.
Right now, it lights up green whenever the long arrows show up. This is good and the ideal function of what I want it to do. However, I would like the boxes to be gray the rest of the time (unless the short arrow/dark red box would show up). It just displays NaN everywhere. I know which part of the script needs to be modified (anywhere it is double.nan) I'm just not sure how to tighten this up a bit.
Here is my code so far:
input lookback = 5; # past N minutes
def currentAggPeriod = GetAggregationPeriod();
def higherAggPeriod =
if currentAggPeriod <= AggregationPeriod.TWO_MIN then AggregationPeriod.FIVE_MIN
else if currentAggPeriod <= AggregationPeriod.THREE_MIN then AggregationPeriod.TEN_MIN
else if currentAggPeriod <= AggregationPeriod.FIVE_MIN then AggregationPeriod.FIFTEEN_MIN
else if currentAggPeriod <= AggregationPeriod.TEN_MIN then AggregationPeriod.THIRTY_MIN
else if currentAggPeriod <= AggregationPeriod.FIFTEEN_MIN then AggregationPeriod.HOUR
else if currentAggPeriod <= AggregationPeriod.THIRTY_MIN then AggregationPeriod.TWO_HOURS
else if currentAggPeriod <= AggregationPeriod.TWO_HOURS then AggregationPeriod.DAY
else if currentAggPeriod <= AggregationPeriod.FOUR_HOURS then AggregationPeriod.TWO_DAYS
else if currentAggPeriod <= AggregationPeriod.DAY then AggregationPeriod.WEEK
else if currentAggPeriod <= AggregationPeriod.WEEK then AggregationPeriod.MONTH
else AggregationPeriod.QUARTER
;
script MoxieFunc {
input price = close;
def vc1 = ExpAverage(price, 12) - ExpAverage(price , 26);
def va1 = ExpAverage(vc1, 9);
plot data = (vc1 - va1) * 3;
}
def price =
if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN then high(period = higherAggPeriod)
else close(period = higherAggPeriod)
;
def Moxie = MoxieFunc(price);
def longTrigger = if Moxie > 0 and Moxie[1] <= 0 then Moxie else Double.NaN;
def longArrowPosition =
# first arrow
if Moxie == longTrigger and Moxie != Moxie[1] then low
# consecutive arrows at same position
else if Moxie == longTrigger and Moxie == Moxie[1] then longArrowPosition[1]
else Double.NaN;
plot shortTrigger = if Moxie < 0 and Moxie[1] >= 0 then Moxie else Double.NaN;
def shortArrowPosition =
# first arrow
if Moxie == shortTrigger and Moxie != Moxie[1] then high
# consecutive arrows at same position
else if Moxie == shortTrigger and Moxie == Moxie[1] then shortArrowPosition[1]
else Double.NaN;
AssignBackgroundColor(if longtrigger then color.darK_GREEN
else if shorttrigger then color.dark_RED
else color.gray);
AssignPriceColor(if longtrigger then color.darK_GREEN
else if shorttrigger then color.darK_RED
else color.gray);
EDIT: One other thing I'd like to do is have it sort only whether it is dark green or dark red, rather than by the Moxie number. That way when a buy arrow shows up it would automatically move to the top of the watchlist.