Chart Bubble Exception

a1cturner

Well-known member
I need help!

I have created this study which I believe is a 90+% winner but I am trying to clean it up. I need to code an exception for the chart bubbles.

I have created both a study and a strategy and the STUDY seems to work out a little better because I can buy a put for example when the STRATEGY would just have me sell the previously purchased call and then wait for the next opportunity. I have tried using buy_auto vs buy_to_open but I'm still way more confident in the study vs the strategy.

This is the problem. I will get a "buy call" trigger and then maybe 20 minutes later I will get another "buy call" trigger and possibly even another after that before I get my sell trigger. Usually, but not always if I am holding a call and i get a sell trigger, I will also get a "buy put" trigger on the same candle. I am totally okay with that because if I wasn't in a trade and wanted to enter there I would want that trigger. What I don't want is the multiple "buy call" or "buy put" triggers before the sell trigger. I don't want them because it would cause the trade to be entered too late (another downfall of the STRATEGY using buy_to_open or sell_to_open).

What I want is a buy trigger followed by a sell trigger followed by a buy trigger followed by a sell trigger OR a buy trigger followed by a sell trigger/buy trigger (on the same candle) followed by a sell trigger etc.

To explain it a different way this is what the chart shows below: CALL/SELL.........CALL........CALLX..........CALLX.......SELL/PUT..........SELL........CALLX.......SELL/PUT.........CALLX/PUT.........SELL/PUT........PUT........SELL

vs. what I want:

CALL/SELL................................................................SELL/PUT..........SELL........CALLX.......SELL/PUT.........CALLX/PUT.........SELL/PUT......................SELL

To make things even more difficult I don't want a "back to back" CALL and CALL or CALL and CALLX or SELL and SELL or SELL and SELLX

The CALLX and SELLX just mean that VIX is trending against your move. (down for call or up for put)

My current code is:

AddChartBubble(BuyCall and !BuyCall[10] and (CompareEMA1 > CompareEMA2), low, "Call", color.green, no);
AddChartBubble(BuyPut and !BuyPut[10] and (CompareEMA1 < CompareEMA2), high, "Put", color.green, yes);
AddChartBubble(BuyCall and !BuyCall[10] and (CompareEMA1 < CompareEMA2), low, "CallX", color.orange, no);
AddChartBubble(BuyPut and !BuyPut[10] and (CompareEMA1 > CompareEMA2), high, "PutX", color.orange, yes);

AddChartBubble(SellPut and !SellPut[10], low, "Sell", color.red, no);
AddChartBubble(SellCall and !SellCall[10], high, "Sell", color.red, yes);

I did get rid of a lot of extra chart bubbles by adding in !BuyCall[10] and !BuyPut[10] but it's still not clean enough for me. (I had to use 10 because i am using this on a 1 minute time frame with a few 10 minute studies so it is really only 1 bar)

Is there any code to say AddChartBubble(BuyCall "IF THE PREVIOUS BUBBLE IS NOT CALL OR CALLX" and (CompareEMA1 > CompareEMA2), low, "Call", color.green, no);

Even if I defined CALL, CALLX, PUT, and PUTX as so.... def CALLX=(BuyCall and !BuyCall[10] and (CompareEMA1 > CompareEMA2); and replaced that in the AddChartBubble script, I don't know if that would help.

I hope I explained that well enough and didn't make it more confusing.

Here is the chart:

FvaA81X.png


And the links to the Study and Strategy

Study: http://tos.mx/zJ7PGw3

#JT MOMO INDICATOR

#USED TO IDENTIFY REVERSALS IN DAILY TRENDS FOR SCALPS OR DAY TRADES ONLY.
#USE ON 1 MINUTE CHART ONLY BUT IN CONJUNCTION WITH 10 MINUTE CHART.
#I USE 5/12 AND 34/50 EMA CLOUDS ON MY 10 MINUTE CHART ALONG WITH A FASTER MACD (10, 22, 8) AND RSI.

#ONCE THE INDICATOR IS TRIGGERED WITH CALL OR PUT I WILL SUBMIT A 50ish DELTA CALL OR PUT WITH A MARKET ORDER

#ENSURE THAT THERE HAS NOT BEEN ANOTHER CALL OR PUT TRIGGER SINCE THE REVERSAL (USUALLY WITHIN THE PAST 20-30 MINUTES). IF THERE IS, THAN YOU ARE LATE AND SHOULD WAIT FOR THE NEXT OPPURTUNITY#

#ALWAYS LOOK AT THE VOLUME OF THE OPTION YOU ARE BUYING#

#PLAY STOCKS THAT YOU KNOW WHERE SUPPORT/RESISTANCE ARE IF POSSIBLE#

#EXIT ON THE SELL INDICATOR NO MATTER WHAT. YOU DECIDE WHETHER YOU GET BACK IN ON THE REVERSAL IF YOU GET A SELL INDICATOR AND BUY INDICATOR ON THE SAME CANDLE. I PERSONNALY LIKE TO WAIT AND LOOK FOR OTHER OPPURTUNITIES.

#GREEN "CALL" OR "PUT" ARE BUY INDICATORS TRENDING IN THE OPPOSITE DIRECTON AS THE COMPARISSON TICKER (VIX). ORANGE "CALL*" OR "PUT*" ARE BUY INDICATORS TRENDING IN THE SAME DIRECTON AS THE COMPARISSON TICKER (VIX). MAKE SURE YOU KNOW WHICH WAY YOUR TICKER IS TRENDING COMPARED TO THE COMPARRISON TICKER

declare upper;

input MovAvg = AverageType.EXPONENTIAL;
input TSITimeShort = AggregationPeriod.MIN;
input TSITimeLong = AggregationPeriod.TEN_MIN;
input EMATime = AggregationPeriod.TEN_MIN;
input MACDTime = AggregationPeriod.TEN_MIN;
input TSILongLength = 34;
input TSIShortLength = 5;
input TSISignalLength = 5;
input EMAFast1 = 5;
input EMAFast2 = 12;
input EMASlow1 = 34;
input EMASlow2 = 50;
input MACDFast = 10;
input MACDSlow = 22;
input MACDLength = 8;
input Symbol = "VIX";
input StartTime = 0930;
input StartTimeDelay = 29;
input EndTime = 1600;
input SignalEndTimeDelay = 89;
input StopEndTimeDelay = 0;

#CLOSE
def TSICloseShort = close(period = TSITimeShort);
def TSICloseLong = close(period = TSITimeLong);
def EMAClose = close(period = EMATime);
def MACDClose = close(period = MACDTime);
def Data = close(Symbol, period = EMATime);

#TRUE STENGTH INDEX(TSI)
def DiffShort = TSICloseShort - TSICloseShort[1];
def DiffLong = TSICloseLong - TSICloseLong[1];
def DoubleSmoothedAbsDiffShort = MovingAverage(MovAvg, MovingAverage(MovAvg, AbsValue(DiffShort), TSILongLength), TSIShortLength);
def DoubleSmoothedAbsDiffLong = MovingAverage(MovAvg, MovingAverage(MovAvg, AbsValue(DiffLong), TSILongLength), TSIShortLength);

#TSI 1 Min
def TSIShort;
def SignalShort;

TSIShort = if DoubleSmoothedAbsDiffShort == 0 then 0
else 100 * (MovingAverage(MovAvg, MovingAverage(MovAvg, DiffShort, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiffShort;
SignalShort = MovingAverage(MovAvg, TSIShort, TSISignalLength);

def ZeroLine2 = 0;

#TSI 10 Min
def TSILong;
def SignalLong;

TSILong = if DoubleSmoothedAbsDiffLong == 0 then 0
else 100 * (MovingAverage(MovAvg, MovingAverage(MovAvg, DiffLong, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiffLong;
SignalLong = MovingAverage(MovAvg, TSILong, TSISignalLength);

def ZeroLine1 = 0;

#EMAs
def EMA1 = MovingAverage(MovAvg, EMAClose, EMAFast1);
def EMA2 = MovingAverage(MovAvg, EMAClose, EMAFast2);
def EMA3 = MovingAverage(MovAvg, EMAClose, EMASlow1);
def EMA4 = MovingAverage(MovAvg, EMAClose, EMASlow2);
def CompareEMA1 = MovingAverage(MovAvg, Data, EMAFast1);
def CompareEMA2 = MovingAverage(MovAvg, Data, EMAFast2);

#EMA PERCENT
def EMApct = ((EMA1 / EMA2) * 100) - 100;
def EMApctRound = Round(EMApct, 2);

#MACD
def MACD = MovingAverage(MovAvg, MACDClose, MACDFast) -
MovingAverage(MovAvg, MACDClose, MACDSlow);
def MACDVar = MovingAverage(MovAvg, MACD, MACDLength);
def MACDDiff = MACD - MACDVar;

#START AND END TIME
def StartDay = (SecondsFromTime (StartTime)) > (StartTimeDelay * 60);
def EndSignal = (SecondsTillTime (EndTime)) > (SignalEndTimeDelay * 60);
def EndStop = (SecondsTillTime (EndTime)) > (StopEndTimeDelay * 60);

#GET READY
def GetReadyCall = (StartDay) and (EndSignal) and (TSIShort < -10) and (TSIShort < TSIShort[1]) and (EMA1>EMA2) and (EMA3>EMA4) and (MACDDiff>0);
def GetReadyPut = (StartDay) and (EndSignal) and (TSIShort > 10) and (TSIShort > TSIShort[1]) and (EMA1 < EMA2) and (EMA3 < EMA4) and (MACDDiff < 0);

#BUY CALL and PUT
def BuyCall = (StartDay) and (EndSignal) and (TSIShort > TSIShort[1]) and (EMApct > EMApct[1]) and (MACDDiff > MACDDiff[1]);
def BuyPut = (StartDay) and (EndSignal) and (TSIShort < TSIShort[1]) and (EMApct < EMApct[1]) and (MACDDiff < MACDDiff[1]);

#SELL CALL AND PUT
def SellCall = (StartDay) and (EndStop) and (BuyCall is true within 125 bars) and (MACDDiff < MACDDiff[1]);
def SellPut = (StartDay) and (EndStop) and (BuyPut is true within 125 bars) and (MACDDiff > MACDDiff[1]);

AddChartBubble(BuyCall and !BuyCall[10] and (CompareEMA1 > CompareEMA2), low, "Call", Color.GREEN, no);
AddChartBubble(BuyPut and !BuyPut[10] and (CompareEMA1 < CompareEMA2), high, "Put", Color.GREEN, yes);
AddChartBubble(BuyCall and !BuyCall[10] and (CompareEMA1 < CompareEMA2), low, "CallX", Color.ORANGE, no);
AddChartBubble(BuyPut and !BuyPut[10] and (CompareEMA1 > CompareEMA2), high, "PutX", Color.ORANGE, yes);
AddChartBubble(GetReadyCall and !GetReadyCall[1] and (CompareEMA1 < CompareEMA2), low, "C", Color.CYAN, no);
AddChartBubble(GetReadyPut and !GetReadyPut[1] and (CompareEMA1 > CompareEMA2), high, "P", Color.CYAN, yes);

AddChartBubble(SellPut and !SellPut[10], low, "Sell", Color.RED, no);
AddChartBubble(SellCall and !SellCall[10], high, "Sell", Color.RED, yes);

#ALERTS
Alert(BuyCall and !BuyCall[10], "CALL", Alert.BAR, Sound.Ring);
Alert(BuyPut and !BuyPut[10], "PUT", Alert.BAR, Sound.Ring);
Alert((SellPut and !SellPut[10]) or (SellCall and !SellCall[10]), "SELL", Alert.BAR, Sound.Bell);

#ORDERS
#AddOrder(OrderType.BUY_TO_OPEN, (BuyCall and !BuyCall[10]) and (CompareEMA1 > CompareEMA2), open[-1], 100, Color.green, Color.light_green,"BUY CALL");
#AddOrder(OrderType.SELL_TO_OPEN, (BuyPut and !BuyPut[10]) and (CompareEMA1 < CompareEMA2), open[-1], 100, Color.green, Color.light_green,"BUY PUT");
#AddOrder(OrderType.BUY_TO_OPEN, (BuyCall and !BuyCall[10]) and (CompareEMA1 < CompareEMA2), open[-1], 100, Color.orange, Color.light_orange,"BUY CALL*");
#AddOrder(OrderType.SELL_TO_OPEN, (BuyPut and !BuyPut[10]) and (CompareEMA1 > CompareEMA2), open[-1], 100, Color.orange, Color.light_orange,"BUY PUT*");
#AddOrder(OrderType.SELL_TO_CLOSE, (SellCall and !SellCall[10]), open[-1], 100, Color.red, Color.light_red,"SELL CALL");
#AddOrder(OrderType.BUY_TO_CLOSE, (SellPut and !SellPut[10]), open[-1], 100, Color.red, Color.light_red,"SELL PUT");

#WATCHLIST INDICATORS
#TSI WATCHLIST INDICTOR - http://tos.mx/XtJhm6P
#MOMO WATCHLIST INDICATOR - http://tos.mx/N3Y7a4Q
#CALL AND PUT WATCHLIST INDICTOR - http://tos.mx/KS68sJX
#MACD WATCHLIST INDICATOR - http://tos.mx/THMeAW1
#EMA WATCHLIST INDICATOR - http://tos.mx/2s4TNaf

Strategy: http://tos.mx/kjhL5LQ

#JT MOMO INDICATOR

#USED TO IDENTIFY REVERSALS IN DAILY TRENDS FOR SCALPS OR DAY TRADES ONLY.
#USE ON 1 MINUTE CHART ONLY BUT IN CONJUNCTION WITH 10 MINUTE CHART.
#I USE 5/12 AND 34/50 EMA CLOUDS ON MY 10 MINUTE CHART ALONG WITH A FASTER MACD (10, 22, 8) AND RSI.

#ONCE THE INDICATOR IS TRIGGERED WITH CALL OR PUT I WILL SUBMIT A 50ish DELTA CALL OR PUT WITH A MARKET ORDER

#ENSURE THAT THERE HAS NOT BEEN ANOTHER CALL OR PUT TRIGGER SINCE THE REVERSAL (USUALLY WITHIN THE PAST 20-30 MINUTES). IF THERE IS, THAN YOU ARE LATE AND SHOULD WAIT FOR THE NEXT OPPURTUNITY#

#ALWAYS LOOK AT THE VOLUME OF THE OPTION YOU ARE BUYING#

#PLAY STOCKS THAT YOU KNOW WHERE SUPPORT/RESISTANCE ARE IF POSSIBLE#

#EXIT ON THE SELL INDICATOR NO MATTER WHAT. YOU DECIDE WHETHER YOU GET BACK IN ON THE REVERSAL IF YOU GET A SELL INDICATOR AND BUY INDICATOR ON THE SAME CANDLE. I PERSONNALY LIKE TO WAIT AND LOOK FOR OTHER OPPURTUNITIES.

#GREEN "CALL" OR "PUT" ARE BUY INDICATORS TRENDING IN THE SAME DIRECTON AS THE COMPARISSON TICKER (VIX). ORANGE "CALL*" OR "PUT*" ARE BUY INDICATORS TRENDING IN THE OPPOSITE DIRECTON AS THE COMPARISSON TICKER (VIX). MAKE SURE YOU KNOW WHICH WAY YOUR TICKER IS TRENDING COMPARED TO THE COMPARRISON TICKER

declare upper;

input MovAvg = AverageType.EXPONENTIAL;
input TSITimeShort = aggregationPeriod.MIN;
input TSITimeLong = aggregationPeriod.TEN_MIN;
input EMATime = aggregationPeriod.TEN_MIN;
input MACDTime = aggregationPeriod.TEN_MIN;
input TSILongLength = 34;
input TSIShortLength = 5;
input TSISignalLength = 5;
input EMAFast1 = 5;
input EMAFast2 = 12;
input EMASlow1 = 34;
input EMASlow2 = 50;
input MACDFast = 10;
input MACDSlow = 22;
input MACDLength = 8;
input Symbol = "VIX";
input StartTime = 0930;
input StartTimeDelay = 29;
input EndTime = 1600;
input SignalEndTimeDelay = 89;
input StopEndTimeDelay = 0;

#CLOSE
def TSICloseShort = close(period=TSITimeShort);
def TSICloseLong = close(period=TSITimeLong);
def EMAClose = close(period=EMATime);
def MACDClose = close(period=MACDTime);
def Data = close(Symbol, period=EMATime);

#TRUE STENGTH INDEX(TSI)
def DiffShort = TSICloseShort - TSICloseShort[1];
def DiffLong = TSICloseLong - TSICloseLong[1];
def DoubleSmoothedAbsDiffShort = MovingAverage(MovAvg, MovingAverage(MovAvg, AbsValue(diffShort), TSILongLength), TSIShortLength);
def DoubleSmoothedAbsDiffLong = MovingAverage(MovAvg, MovingAverage(MovAvg, AbsValue(diffLong), TSILongLength), TSIShortLength);

#TSI 1 Min
def TSIShort;
def SignalShort;

TSIShort = if DoubleSmoothedAbsDiffShort == 0 then 0
else 100 * (MovingAverage(MovAvg, MovingAverage(MovAvg, DiffShort, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiffShort;
SignalShort = MovingAverage(MovAvg, TSIShort, TSISignalLength);

def ZeroLine2 = 0;

#TSI 10 Min
def TSILong;
def SignalLong;

TSILong = if DoubleSmoothedAbsDiffLong == 0 then 0
else 100 * (MovingAverage(MovAvg, MovingAverage(MovAvg, DiffLong, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiffLong;
SignalLong = MovingAverage(MovAvg, TSILong, TSISignalLength);

def ZeroLine1 = 0;

#EMAs
def EMA1 = MovingAverage(MovAvg, EMAClose, EMAFast1);
def EMA2 = MovingAverage(MovAvg, EMAClose, EMAFast2);
def EMA3 = MovingAverage(MovAvg, EMAClose, EMASlow1);
def EMA4 = MovingAverage(MovAvg, EMAClose, EMASlow2);
def CompareEMA1 = MovingAverage(MovAvg, Data, EMAFast1);
def CompareEMA2 = MovingAverage(MovAvg, Data, EMAFast2);

#EMA PERCENT
def EMApct = ((ema1 / ema2)*100)-100;
def EMApctRound = round(EMApct, 2);

#MACD
def MACD = MovingAverage(MovAvg, MACDClose, MACDFast) -
MovingAverage(MovAvg, MACDClose, MACDSlow);
def MACDVar = MovingAverage(MovAvg, MACD, MACDLength);
def MACDDiff = MACD - MACDVar;

#START AND END TIME
def StartDay = (secondsfromtime (StartTime)) > (StartTimeDelay*60);
def EndSignal = (secondstilltime (EndTime)) > (SignalEndTimeDelay*60);
def EndStop = (secondstilltime (EndTime)) > (StopEndTimeDelay*60);

#BUY CALL and PUT
def BuyCall = (StartDay) and (EndSignal) and (TSIShort > TSIShort[1]) and (EMAPctRound > EMAPctRound[1]) and (MACDDiff > MACDDiff[1]);
def BuyPut = (StartDay) and (EndSignal) and (TSIShort < TSIShort[1]) and (EMAPctRound < EMAPctRound[1]) and (MACDDiff < MACDDiff[1]);

#SELL CALL AND PUT
def SellCall = (StartDay) and (EndStop) and (BuyCall is true within 125 bars) and (MACDDiff < MACDDiff[1]);
def SellPut = (StartDay) and (EndStop) and (BuyPut is true within 125 bars) and (MACDDiff > MACDDiff[1]);

#AddChartBubble(BuyCall and !BuyCall[10] and (CompareEMA1 > CompareEMA2), low, "Call", color.green, no);
#AddChartBubble(BuyPut and !BuyPut[10] and (CompareEMA1 < CompareEMA2), high, "Put", color.green, yes);
#AddChartBubble(BuyCall and !BuyCall[10] and (CompareEMA1 < CompareEMA2), low, "CallX", color.orange, no);
#AddChartBubble(BuyPut and !BuyPut[10] and (CompareEMA1 > CompareEMA2), high, "PutX", color.orange, yes);

#AddChartBubble(SellPut and !SellPut[10], low, "Sell", color.red, no);
#AddChartBubble(SellCall and !SellCall[10], high, "Sell", color.red, yes);

#ALERTS
Alert(BuyCall and !BuyCall[10], "CALL", Alert.Bar, Sound.Ring);
Alert(BuyPut and !BuyPut[10], "PUT", Alert.Bar, Sound.Ring);
Alert((SellPut and !SellPut[10]) or (SellCall and !SellCall[10]), "SELL", Alert.Bar, Sound.Bell);

#ORDERS
##BUY
AddOrder(OrderType.BUY_TO_OPEN, (BuyCall) and (CompareEMA1 > CompareEMA2), open[-1], 100, Color.green, Color.light_green,"BUY CALL");
AddOrder(OrderType.SELL_TO_OPEN, (BuyPut) and (CompareEMA1 < CompareEMA2), open[-1], 100, Color.green, Color.light_green,"BUY PUT");
AddOrder(OrderType.BUY_TO_OPEN, (BuyCall) and (CompareEMA1 < CompareEMA2), open[-1], 100, Color.orange, Color.light_orange,"BUY CALL*");
AddOrder(OrderType.SELL_TO_OPEN, (BuyPut) and (CompareEMA1 > CompareEMA2), open[-1], 100, Color.orange, Color.light_orange,"BUY PUT*");

##SELL
AddOrder(OrderType.SELL_TO_CLOSE, (SellCall), open[-1], 100, Color.red, Color.light_red,"SELL CALL");
AddOrder(OrderType.BUY_TO_CLOSE, (SellPut), open[-1], 100, Color.red, Color.light_red,"SELL PUT");

###REVERSAL TEST
#AddOrder(OrderType.BUY_TO_OPEN, (BuyCall) and (CompareEMA1 > CompareEMA2) and (SellPut), open[-1], 100, Color.cyan, Color.cyan,"BUY CALL or SELL PUT");
#AddOrder(OrderType.SELL_TO_OPEN, (BuyPut) and (CompareEMA1 < CompareEMA2) and (SellCall), open[-1], 100, Color.cyan, Color.cyan,"BUY PUT or Sell CALL");
##REVERSAL TEST
#AddOrder(OrderType.BUY_TO_OPEN, (BuyCall) and (CompareEMA1 < CompareEMA2) and (SellPut), open[-1], 100, Color.cyan, Color.cyan,"BUY CALL or SELL PUT*");
#AddOrder(OrderType.SELL_TO_OPEN, (BuyPut) and (CompareEMA1 > CompareEMA2) and (SellCall), open[-1], 100, Color.cyan, Color.cyan,"BUY PUT or SELL CALL*");

#WATCHLIST INDICATORS
#TSI WATCHLIST INDICTOR - http://tos.mx/XtJhm6P
#MOMO WATCHLIST INDICATOR - http://tos.mx/N3Y7a4Q
#CALL AND PUT WATCHLIST INDICTOR - http://tos.mx/KS68sJX
#MACD WATCHLIST INDICATOR - http://tos.mx/THMeAW1
#EMA WATCHLIST INDICATOR - http://tos.mx/2s4TNaf


I am open to chart lines vs. bubbles or even candles that change colors based on call or put if that makes the coding easier.
 
Last edited:

Is there any code to say AddChartBubble(BuyCall "IF THE PREVIOUS BUBBLE IS NOT CALL OR CALLX" and (CompareEMA1 > CompareEMA2), low, "Call", color.green, no);


you are close , but asking the question incorrectly.
It's not a bubble condition you are looking for.
it is a variable you want, that can be used in the bubble and addorder, that is equal to a formula.

You have long formulas as enable conditions for bubbles and addorders.. Because of this it is hard and awkward to compare them and reference them.

try to have 1 final formula, that is set to a variable, that will be used to enable bubbles and addorders.
( 1 for buying calls, 1 for selling calls, 1 for buying puts, 1 for selling puts)


i did some experimenting with your study. I pulled the formulas out of the bubbles, the ones used to enable the bubbles, and set them equal to variables.
(ex. buycall, sellcall, buyput, sellput,...)

so far i have,
call buy, call sell, call buy, ...

don't have puts done.
I didn't evaluate the trigger signals.
I ignored callx and putx, I don't know what they are.


section 1
i reorganized some code lines.
i put all of the buy and sell conditions together. this way, sell variables can be used in the buy formulas ( and vice versa..). before they were down lower in the code and could be referenced.

section 2
then i made new formulas, for buying and selling.
[ rough examples... not complete
a variable that is true during the buy period. If this is true, then ignore future buy signals.
buy2 = if sell1 then 0 else if buy1 then 1
buy3 = if !buy2 then buy1... ]

section 3
then i put all of the bubbles together, and referenced the new variables.

later i will finish the put formulas. then i will post the code, not just a link.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.


please post codes, not just share links.
this is a coding forum, not a link forum. many people, and myself, read these pages from a phone. because of that we can't load links and can't look at the code.
and honestly, if all there is is a share link, i usually skip the post. i don't know if the link is to a study or to a workspace that would replace my workspace.
 
please post codes, not just share links.
this is a coding forum, not a link forum. many people, and myself, read these pages from a phone. because of that we can't load links and can't look at the code.
and honestly, if all there is is a share link, i usually skip the post. i don't know if the link is to a study or to a workspace that would replace my workspace.
Thanks for the heads up. I will definitely do that from now on.
 
you are close , but asking the question incorrectly.
It's not a bubble condition you are looking for.
it is a variable you want, that can be used in the bubble and addorder, that is equal to a formula.

You have long formulas as enable conditions for bubbles and addorders.. Because of this it is hard and awkward to compare them and reference them.

try to have 1 final formula, that is set to a variable, that will be used to enable bubbles and addorders.
( 1 for buying calls, 1 for selling calls, 1 for buying puts, 1 for selling puts)


i did some experimenting with your study. I pulled the formulas out of the bubbles, the ones used to enable the bubbles, and set them equal to variables.
(ex. buycall, sellcall, buyput, sellput,...)

so far i have,
call buy, call sell, call buy, ...

don't have puts done.
I didn't evaluate the trigger signals.
I ignored callx and putx, I don't know what they are.


section 1
i reorganized some code lines.
i put all of the buy and sell conditions together. this way, sell variables can be used in the buy formulas ( and vice versa..). before they were down lower in the code and could be referenced.

section 2
then i made new formulas, for buying and selling.
[ rough examples... not complete
a variable that is true during the buy period. If this is true, then ignore future buy signals.
buy2 = if sell1 then 0 else if buy1 then 1
buy3 = if !buy2 then buy1... ]

section 3
then i put all of the bubbles together, and referenced the new variables.

later i will finish the put formulas. then i will post the code, not just a link.
Thank you so much for doing all that work! You have no idea how much I appreciate it.

I have pasted the code in the original post.

The CallX is a Call Buy trigger when the VIX is trending up and PutX is a Put Buy trigger when the VIX is trending down. My thought is that someone else could use it and change the comparison ticker and maybe see if a S&P stock is trending with SPY or against SPY for example. Just helps to know if you are going with or against the market trend.
 
Last edited:
Thank you so much for doing all that work! You have no idea how much I appreciate it.

I have pasted the code in the original post.

The CallX is a Call Buy trigger when the VIX is trending up and PutX is a Put Buy trigger when the VIX is trending down. My thought is that someone else could use it and change the comparison ticker and maybe see if a S&P stock is trending with SPY or against SPY for example. Just helps to know if you are going with or against the market trend.


although i have good intentions of getting back to this tonight, things come up and i get distracted, so i will post what i have, so you can see what have done so far.
it's messy and put bubble code isn't done yet.

these formulas aren't perfect. i haven't test every possible outcome. not sure about the sell formulas.
i would add a bubble to display several values on every bar.

i tried to make several tiers for formulas. each tier relies on data from the previous one.
if you try to do too much in 1 formula, sometimes it just doesn't work or becomes a feedback mess.

i pulled your formulas from the bubbles and set them = to variables, like this,
call_bub , put_bub, callx_bub , putx_bub
sellc_bub , sellp_bub

made several formulas
call2_en , is true during a call
call2 , buy signal

for calls, i added profit labels, to track how the trades went.
it calculates the price difference when a sell happens. then adds them up.
also draws a horizontal line from the buy in bar, until a sell.


Ruby:
# TSI_EMA_MACD_COMPARE_MOMO_INDICATOR_01b

#JT MOMO INDICATOR

# -----------------------

# new call buy , call sell  bubbles
# profit labels


# ------------------------

# https://usethinkscript.com/threads/chart-bubble-exception.10457/
# Chart Bubble Exception
# a1cturner

#Study:
#http://tos.mx/zJ7PGw3
#TSI_EMA_MACD_COMPARE_MOMO_INDICATOR


#USED TO IDENTIFY REVERSALS IN DAILY TRENDS FOR SCALPS OR DAY TRADES ONLY.
#USE ON 1 MINUTE CHART ONLY BUT IN CONJUNCTION WITH 10 MINUTE CHART.
#I USE 5/12 AND 34/50 EMA CLOUDS ON MY 10 MINUTE CHART ALONG WITH A FASTER MACD (10, 22, 8) AND RSI.

#ONCE THE INDICATOR IS TRIGGERED WITH CALL OR PUT I WILL SUBMIT A 50ish DELTA CALL OR PUT WITH A MARKET ORDER

#*****ENSURE THAT THERE HAS NOT BEEN ANOTHER CALL OR PUT TRIGGER SINCE THE REVERSAL (USUALLY WITHIN THE PAST 20-30 MINUTES). IF THERE IS, THAN YOU ARE LATE AND SHOULD WAIT FOR THE NEXT OPPURTUNITY*****#

#*****ALWAYS LOOK AT THE VOLUME OF THE OPTION YOU ARE BUYING*****#

#*****PLAY STOCKS THAT YOU KNOW WHERE SUPPORT/RESISTANCE ARE IF POSSIBLE*****#

#EXIT ON THE SELL INDICATOR NO MATTER WHAT. YOU DECIDE WHETHER YOU GET BACK IN ON THE REVERSAL IF YOU GET A SELL INDICATOR AND BUY INDICATOR ON THE SAME CANDLE. I PERSONNALY LIKE TO WAIT AND LOOK FOR OTHER OPPURTUNITIES.

#GREEN "CALL" OR "PUT" ARE BUY INDICATORS TRENDING IN THE SAME DIRECTON AS THE COMPARISSON TICKER (VIX). ORANGE "CALL*" OR "PUT*" ARE BUY INDICATORS TRENDING IN THE OPPOSITE DIRECTON AS THE COMPARISSON TICKER (VIX). *****MAKE SURE YOU KNOW WHICH WAY YOUR TICKER IS TRENDING COMPARED TO THE COMPARRISON TICKER*****

declare upper;

input MovAvg = AverageType.EXPONENTIAL;
input TSITimeShort = aggregationPeriod.MIN;
input TSITimeLong = aggregationPeriod.TEN_MIN;
input EMATime = aggregationPeriod.TEN_MIN;
input MACDTime = aggregationPeriod.TEN_MIN;
input TSILongLength = 34;
input TSIShortLength = 5;
input TSISignalLength = 5;
input EMAFast1 = 5;
input EMAFast2 = 12;
input EMASlow1 = 34;
input EMASlow2 = 50;
input MACDFast = 10;
input MACDSlow = 22;
input MACDLength = 8;
input Symbol = "VIX";
input StartTime = 0930;
input StartTimeDelay = 29;
input EndTime = 1600;
input SignalEndTimeDelay = 89;
input StopEndTimeDelay = 0;

#CLOSE
def TSICloseShort = close(period=TSITimeShort);
def TSICloseLong = close(period=TSITimeLong);
def EMAClose = close(period=EMATime);
def MACDClose = close(period=MACDTime);
def Data = close(Symbol, period=EMATime);

#TRUE STENGTH INDEX(TSI)
def DiffShort = TSICloseShort - TSICloseShort[1];
def DiffLong = TSICloseLong - TSICloseLong[1];
def DoubleSmoothedAbsDiffShort = MovingAverage(MovAvg, MovingAverage(MovAvg, AbsValue(diffShort), TSILongLength), TSIShortLength);
def DoubleSmoothedAbsDiffLong = MovingAverage(MovAvg, MovingAverage(MovAvg, AbsValue(diffLong), TSILongLength), TSIShortLength);

#TSI 1 Min
def TSIShort;
def SignalShort;

TSIShort = if DoubleSmoothedAbsDiffShort == 0 then 0
      else 100 * (MovingAverage(MovAvg, MovingAverage(MovAvg, DiffShort, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiffShort;
SignalShort = MovingAverage(MovAvg, TSIShort, TSISignalLength);

def ZeroLine2 = 0;

#TSI 10 Min
def TSILong;
def SignalLong;

TSILong = if DoubleSmoothedAbsDiffLong == 0 then 0
      else 100 * (MovingAverage(MovAvg, MovingAverage(MovAvg, DiffLong, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiffLong;
SignalLong = MovingAverage(MovAvg, TSILong, TSISignalLength);

def ZeroLine1 = 0;

#EMAs
def EMA1 = MovingAverage(MovAvg, EMAClose, EMAFast1);
def EMA2 = MovingAverage(MovAvg, EMAClose, EMAFast2);
#def EMA3 = MovingAverage(MovAvg, EMAClose, EMASlow1);
#def EMA4 = MovingAverage(MovAvg, EMAClose, EMASlow2);
def CompareEMA1 = MovingAverage(MovAvg, Data, EMAFast1);
def CompareEMA2 = MovingAverage(MovAvg, Data, EMAFast2);

#EMA PERCENT
def EMApct = ((ema1 / ema2)*100)-100;
def EMApctRound = round(EMApct, 2);

#MACD
def MACD = MovingAverage(MovAvg, MACDClose, MACDFast) -
MovingAverage(MovAvg, MACDClose, MACDSlow);
def MACDVar = MovingAverage(MovAvg, MACD, MACDLength);
def MACDDiff = MACD - MACDVar;

#START AND END TIME
def StartDay = (secondsfromtime (StartTime)) > (StartTimeDelay*60);
def EndSignal = (secondstilltime (EndTime)) > (SignalEndTimeDelay*60);
def EndStop = (secondstilltime (EndTime)) > (StopEndTimeDelay*60);

#BUY CALL and PUT
def BuyCall = (StartDay) and (EndSignal) and (TSIShort > TSIShort[1]) and (EMAPctRound > EMAPctRound[1]) and (MACDDiff > MACDDiff[1]);
def BuyPut = (StartDay) and (EndSignal) and (TSIShort < TSIShort[1]) and (EMAPctRound < EMAPctRound[1]) and (MACDDiff < MACDDiff[1]);

#SELL CALL AND PUT
def SellCall = (StartDay) and (EndStop) and (BuyCall is true within 125 bars) and (MACDDiff < MACDDiff[1]);
def SellPut = (StartDay) and (EndStop) and (BuyPut is true within 125 bars) and (MACDDiff > MACDDiff[1]);

# --------------------------------------------------------

# new code - halcyonguy

def na = double.nan;

input show_original_buy_bubbles = yes;
input show_original_sell_bubbles = yes;

input show_ver2_buy_bubbles = yes;
input show_ver2_sell_bubbles = yes;


def call_bub = (BuyCall and !BuyCall[10] and (CompareEMA1 > CompareEMA2));
def put_bub = (BuyPut and !BuyPut[10] and (CompareEMA1 < CompareEMA2));
def callx_bub = (BuyCall and !BuyCall[10] and (CompareEMA1 < CompareEMA2));
def putx_bub = (BuyPut and !BuyPut[10] and (CompareEMA1 > CompareEMA2));

def sellc_bub = (SellCall and !SellCall[10]);
def sellp_bub = (SellPut and !SellPut[10]);

#-----------------------------------------------------
# if call or put was triggered, don't show another trigger
def call2_en = if sellc_bub then 0 else if call_bub then 1 else call2_en[1];
def put2_en = if sellp_bub then 0 else if put_bub then 1 else put2_en[1];

def call2 = if call2_en[1] == 0 and call2_en == 1 then 1 else 0;
def put2 = if put2_en[1] == 0 and put2_en == 1 then 1 else 0;

AddChartBubble(show_ver2_buy_bubbles and call2, low, "Call2", color.green, no);
AddChartBubble(show_ver2_buy_bubbles and put2, high, "put2", color.cyan, yes);

#-----------------------------------------------------
# if a sell was triggered, don't show another. act on the 1st sell

def sell_C2_en = if (call2_en[1] and sellc_bub) then 1 else if sell_C2_en[1] then 0 else sell_C2_en[1];

addchartbubble(sell_C2_en, high, "sell call2", color.magenta, yes);

def call2_pr = if call2 then close else call2_pr[1];
def call2_profit = if sell_C2_en then (call2_profit[1] + ( close - call2_pr)) else call2_profit[1];
def call2_qty = if call2 then call2_qty[1] + 1 else call2_qty[1];

addlabel(1, "   ", color.black);
addlabel(1, "call profit " + call2_profit, color.green);
addlabel(1, "trades " + call2_qty, color.yellow);
addlabel(1, "avg call trade $ " + ( call2_profit/call2_qty), color.yellow);


plot cbuy = if call2_en then call2_pr else na;
cbuy.setdefaultcolor(color.green);


input test2 = no;
addchartbubble(test2, high,
 call2_en + " bc2\n" +
 sellc_bub + " sc\n" +
 sell_c2_en + "  sc2\n" +
 "sell call2"
, (if sell_c2_en then color.magenta else color.gray), yes);






#-----------------------------------------------------

AddChartBubble(show_original_buy_bubbles and call_bub, low, "Call", color.green, no);
AddChartBubble(show_original_buy_bubbles and put_bub, high, "Put", color.green, yes);

AddChartBubble(show_original_sell_bubbles and sellp_bub, low, "Sell_P", color.red, no);
AddChartBubble(show_original_sell_bubbles and sellc_bub, high, "Sell_C", color.red, yes);

# -----------------------------------

AddChartBubble(show_original_buy_bubbles and callx_bub, low, "CallX", color.orange, no);
AddChartBubble(show_original_buy_bubbles and putx_bub, high, "PutX", color.orange, yes);


#ALERTS
Alert(BuyCall and !BuyCall[10], "CALL", Alert.Bar, Sound.Ring);
Alert(BuyPut and !BuyPut[10], "PUT", Alert.Bar, Sound.Ring);
Alert((SellPut and !SellPut[10]) or (SellCall and !SellCall[10]), "SELL", Alert.Bar, Sound.Bell);

#ORDERS
#AddOrder(OrderType.BUY_TO_OPEN, (BuyCall and !BuyCall[10]) and (CompareEMA1 > CompareEMA2), open[-1], 100, Color.green, Color.light_green,"BUY CALL");
#AddOrder(OrderType.SELL_TO_OPEN, (BuyPut and !BuyPut[10]) and (CompareEMA1 < CompareEMA2), open[-1], 100, Color.green, Color.light_green,"BUY PUT");
#AddOrder(OrderType.BUY_TO_OPEN, (BuyCall and !BuyCall[10]) and (CompareEMA1 < CompareEMA2), open[-1], 100, Color.orange, Color.light_orange,"BUY CALL*");
#AddOrder(OrderType.SELL_TO_OPEN, (BuyPut and !BuyPut[10]) and (CompareEMA1 > CompareEMA2), open[-1], 100, Color.orange, Color.light_orange,"BUY PUT*");
#AddOrder(OrderType.SELL_TO_CLOSE, (SellCall and !SellCall[10]), open[-1], 100, Color.red, Color.light_red,"SELL CALL");
#AddOrder(OrderType.BUY_TO_CLOSE, (SellPut and !SellPut[10]), open[-1], 100, Color.red, Color.light_red,"SELL PUT");

#WATCHLIST INDICATORS
#TSI WATCHLIST INDICTOR - http://tos.mx/XtJhm6P
#MOMO WATCHLIST INDICATOR - http://tos.mx/N3Y7a4Q
#CALL AND PUT WATCHLIST INDICTOR - http://tos.mx/KS68sJX
#MACD WATCHLIST INDICATOR - http://tos.mx/THMeAW1
#EMA WATCHLIST INDICATOR - http://tos.mx/2s4TNaf
#

new buy and sell bubbles. no 2 of the same in a row.
TTWO 1min 4day
Cz0JFQs.jpg


the 2 cyan lines near the current bar are unrelated and not included.
they are x bar high and low lines,
 
Hey I appreciate anything that gets me closer to my goal. I will play with it some more and see if I can get further. I will try my best not to mess it up.

Full disclosure. I have edited this code multiple times so I may have some things that don't make sense. Like on the call_bub I have CompareEMA1>CompareEMA2 which i noticed earlier should be "<" since I want VIX to be trending down before I buy a call.

I will work on it for about an hour or so and post what I have on here so we aren't working against each other.

Again, I really appreciate the assistance!
 
Hey I appreciate anything that gets me closer to my goal. I will play with it some more and see if I can get further. I will try my best not to mess it up.

Full disclosure. I have edited this code multiple times so I may have some things that don't make sense. Like on the call_bub I have CompareEMA1>CompareEMA2 which i noticed earlier should be "<" since I want VIX to be trending down before I buy a call.

I will work on it for about an hour or so and post what I have on here so we aren't working against each other.

Again, I really appreciate the assistance!

welcome. i looked at a few sp100 stocks and it seemed to do good.

I tend to make a some changes and then save a study and give it a name and save it as a text file. i use a number and a letter, 01b. when i'm done i name it as the next number, 02.
you could do something similar and add some letters, a1c_02
i will add an H
 
I was able to add the Call2X, Sell Call2X and Put2X as well as P/L labels for . Didn't fix any formatting just yet. I will wait until the end for that. I tried to make it clear what I changed but feel free to delete or change anything that is wrong. I am not experienced so you only need to annotate what you changed if you want to, I won't know the difference.

I corrected the "<" and ">" symbols for the comparison ticker.
I also changed (EMAPctRound > EMAPctRound[1]) to (EMA1 > EMA2) and (EMAPctRound < EMAPctRound[1]) to (EMA1 < EMA2)

I need to backtest the EMA edit to see which one works best. I can tell that the EMA1>EMA2 or EMA1<EMA2 is a little slower and less signals but probably higher probability. Will test once the code is cleaned up more.

Oh, and i don't get a P/L. It just shows "N/A"

------------------------------------

# TSI_EMA_MACD_COMPARE_MOMO_INDICATOR_A1C_02

#JT MOMO INDICATOR

# -----------------------

# new call buy , call sell bubbles
# profit labels


# ------------------------

# https://usethinkscript.com/threads/chart-bubble-exception.10457/
# Chart Bubble Exception
# a1cturner

#Study:
#http://tos.mx/xxT5JdV
#TSI_EMA_MACD_COMPARE_MOMO_INDICATOR


#USED TO IDENTIFY REVERSALS IN DAILY TRENDS FOR SCALPS OR DAY TRADES ONLY.
#USE ON 1 MINUTE CHART ONLY BUT IN CONJUNCTION WITH 10 MINUTE CHART.
#I USE 5/12 AND 34/50 EMA CLOUDS ON MY 10 MINUTE CHART ALONG WITH A FASTER MACD (10, 22, 8) AND RSI.

#ONCE THE INDICATOR IS TRIGGERED WITH CALL OR PUT I WILL SUBMIT A 50ish DELTA CALL OR PUT WITH A MARKET ORDER

#ENSURE THAT THERE HAS NOT BEEN ANOTHER CALL OR PUT TRIGGER SINCE THE REVERSAL (USUALLY WITHIN THE PAST 20-30 MINUTES). IF THERE IS, THAN YOU ARE LATE AND SHOULD WAIT FOR THE NEXT OPPURTUNITY#

#ALWAYS LOOK AT THE VOLUME OF THE OPTION YOU ARE BUYING#

#PLAY STOCKS THAT YOU KNOW WHERE SUPPORT/RESISTANCE ARE IF POSSIBLE#

#EXIT ON THE SELL INDICATOR NO MATTER WHAT. YOU DECIDE WHETHER YOU GET BACK IN ON THE REVERSAL IF YOU GET A SELL INDICATOR AND BUY INDICATOR ON THE SAME CANDLE. I PERSONNALY LIKE TO WAIT AND LOOK FOR OTHER OPPURTUNITIES.

#GREEN "CALL" OR "PUT" ARE BUY INDICATORS TRENDING IN THE SAME DIRECTON AS THE COMPARISSON TICKER (VIX). ORANGE "CALL*" OR "PUT*" ARE BUY INDICATORS TRENDING IN THE OPPOSITE DIRECTON AS THE COMPARISSON TICKER (VIX). MAKE SURE YOU KNOW WHICH WAY YOUR TICKER IS TRENDING COMPARED TO THE COMPARRISON TICKER

declare upper;

input MovAvg = AverageType.EXPONENTIAL;
input TSITimeShort = aggregationPeriod.MIN;
input TSITimeLong = aggregationPeriod.TEN_MIN;
input EMATime = aggregationPeriod.TEN_MIN;
input MACDTime = aggregationPeriod.TEN_MIN;
input TSILongLength = 34;
input TSIShortLength = 5;
input TSISignalLength = 5;
input EMAFast1 = 5;
input EMAFast2 = 12;
input EMASlow1 = 34;
input EMASlow2 = 50;
input MACDFast = 10;
input MACDSlow = 22;
input MACDLength = 8;
input Symbol = "VIX";
input StartTime = 0930;
input StartTimeDelay = 29;
input EndTime = 1600;
input SignalEndTimeDelay = 89;
input StopEndTimeDelay = 0;

#CLOSE
def TSICloseShort = close(period=TSITimeShort);
def TSICloseLong = close(period=TSITimeLong);
def EMAClose = close(period=EMATime);
def MACDClose = close(period=MACDTime);
def Data = close(Symbol, period=EMATime);

#TRUE STENGTH INDEX(TSI)
def DiffShort = TSICloseShort - TSICloseShort[1];
def DiffLong = TSICloseLong - TSICloseLong[1];
def DoubleSmoothedAbsDiffShort = MovingAverage(MovAvg, MovingAverage(MovAvg, AbsValue(diffShort), TSILongLength), TSIShortLength);
def DoubleSmoothedAbsDiffLong = MovingAverage(MovAvg, MovingAverage(MovAvg, AbsValue(diffLong), TSILongLength), TSIShortLength);

#TSI 1 Min
def TSIShort;
def SignalShort;

TSIShort = if DoubleSmoothedAbsDiffShort == 0 then 0
else 100 * (MovingAverage(MovAvg, MovingAverage(MovAvg, DiffShort, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiffShort;
SignalShort = MovingAverage(MovAvg, TSIShort, TSISignalLength);

def ZeroLine2 = 0;

#TSI 10 Min
def TSILong;
def SignalLong;

TSILong = if DoubleSmoothedAbsDiffLong == 0 then 0
else 100 * (MovingAverage(MovAvg, MovingAverage(MovAvg, DiffLong, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiffLong;
SignalLong = MovingAverage(MovAvg, TSILong, TSISignalLength);

def ZeroLine1 = 0;

#EMAs
def EMA1 = MovingAverage(MovAvg, EMAClose, EMAFast1);
def EMA2 = MovingAverage(MovAvg, EMAClose, EMAFast2);
#def EMA3 = MovingAverage(MovAvg, EMAClose, EMASlow1);
#def EMA4 = MovingAverage(MovAvg, EMAClose, EMASlow2);
def CompareEMA1 = MovingAverage(MovAvg, Data, EMAFast1);
def CompareEMA2 = MovingAverage(MovAvg, Data, EMAFast2);

#EMA PERCENT
def EMApct = ((ema1 / ema2)*100)-100;
def EMApctRound = round(EMApct, 2);

#MACD
def MACD = MovingAverage(MovAvg, MACDClose, MACDFast) -
MovingAverage(MovAvg, MACDClose, MACDSlow);
def MACDVar = MovingAverage(MovAvg, MACD, MACDLength);
def MACDDiff = MACD - MACDVar;

#START AND END TIME
def StartDay = (secondsfromtime (StartTime)) > (StartTimeDelay*60);
def EndSignal = (secondstilltime (EndTime)) > (SignalEndTimeDelay*60);
def EndStop = (secondstilltime (EndTime)) > (StopEndTimeDelay*60);

#BUY CALL and PUT

###*************JT changed (EMAPctRound > EMAPctRound[1]) to (EMA1 > EMA2) and (EMAPctRound < EMAPctRound[1]) to (EMA1 < EMA2)

def BuyCall = (StartDay) and (EndSignal) and (TSIShort > TSIShort[1]) and (EMA1>EMA2) and (MACDDiff > MACDDiff[1]);
def BuyPut = (StartDay) and (EndSignal) and (TSIShort < TSIShort[1]) and (EMA1<EMA2) and (MACDDiff < MACDDiff[1]);

#SELL CALL AND PUT
def SellCall = (StartDay) and (EndStop) and (BuyCall is true within 125 bars) and (MACDDiff < MACDDiff[1]);
def SellPut = (StartDay) and (EndStop) and (BuyPut is true within 125 bars) and (MACDDiff > MACDDiff[1]);

# --------------------------------------------------------

# new code - halcyonguy

def na = double.nan;

input show_original_buy_bubbles = yes;
input show_original_sell_bubbles = yes;

input show_ver2_buy_bubbles = yes;
input show_ver2_sell_bubbles = yes;

###*************JT changed "<" to ">" and ">" to "<" on the CompareEMA's
###*************JT changed !BuyCall[10] to !BuyCall[1] and the same for !BuyPut, !SellCall, and !SellPut

def call_bub = (BuyCall and !BuyCall[1] and (CompareEMA1 < CompareEMA2));
def put_bub = (BuyPut and !BuyPut[1] and (CompareEMA1 > CompareEMA2));
def callx_bub = (BuyCall and !BuyCall[1] and (CompareEMA1 > CompareEMA2));
def putx_bub = (BuyPut and !BuyPut[1] and (CompareEMA1 < CompareEMA2));

def sellc_bub = (SellCall and !SellCall[1]);
def sellp_bub = (SellPut and !SellPut[1]);

#-----------------------------------------------------
# if call or put was triggered, don't show another trigger
def call2_en = if sellc_bub then 0 else if call_bub then 1 else call2_en[1];
def put2_en = if sellp_bub then 0 else if put_bub then 1 else put2_en[1];

def call2 = if call2_en[1] == 0 and call2_en == 1 then 1 else 0;
def put2 = if put2_en[1] == 0 and put2_en == 1 then 1 else 0;

AddChartBubble(show_ver2_buy_bubbles and call2, low, "Call2", color.green, no);
AddChartBubble(show_ver2_buy_bubbles and put2, high, "Put2", color.cyan, yes);

###*************JT added def callx_bub= and putx_bub= and chart bubbles
def call2x_en = if sellc_bub then 0 else if callx_bub then 1 else call2x_en[1];
def put2x_en = if sellp_bub then 0 else if putx_bub then 1 else put2x_en[1];

def call2x = if call2x_en[1] == 0 and call2x_en == 1 then 1 else 0;
def put2x = if put2x_en[1] == 0 and put2x_en == 1 then 1 else 0;

AddChartBubble(show_ver2_buy_bubbles and call2x, low, "Call2x", color.green, no);
AddChartBubble(show_ver2_buy_bubbles and put2x, high, "Put2x", color.cyan, yes);


#-----------------------------------------------------
# if a sell was triggered, don't show another. act on the 1st sell

def sell_C2_en = if (call2_en[1] and sellc_bub) then 1 else if sell_C2_en[1] then 0 else sell_C2_en[1];

addchartbubble(sell_C2_en, high, "SellCall2", color.magenta, yes);

###*************JT added def sell_C2_en= and added chart bubble

def sell_C2x_en = if (call2x_en[1] and sellc_bub) then 1 else if sell_C2x_en[1] then 0 else sell_C2x_en[1];

addchartbubble(sell_C2x_en, high, "SellCall2x", color.magenta, yes);

#-----------------------------------------------------

def call2_pr = if call2 then close else call2_pr[1];
def call2_profit = if sell_C2_en then (call2_profit[1] + ( close - call2_pr)) else call2_profit[1];
def call2_qty = if call2 then call2_qty[1] + 1 else call2_qty[1];

addlabel(1, " ", color.black);
addlabel(1, "call2 profit " + call2_profit, color.green);
addlabel(1, "trades " + call2_qty, color.yellow);
addlabel(1, "avg call2 trade $ " + ( call2_profit/call2_qty), color.yellow);


plot c2buy = if call2_en then call2_pr else na;
c2buy.setdefaultcolor(color.green);


input test2 = no;
addchartbubble(test2, high,
call2_en + " bc2\n" +
sellc_bub + " sc\n" +
sell_c2_en + " sc2\n" +
"sell call2"
, (if sell_c2_en then color.magenta else color.gray), yes);

###*************JT added profit labels and lines

def call2x_pr = if call2x then close else call2x_pr[1];
def call2x_profit = if sell_C2x_en then (call2x_profit[1] + ( close - call2x_pr)) else call2x_profit[1];
def call2x_qty = if call2x then call2x_qty[1] + 1 else call2x_qty[1];

addlabel(1, " ", color.black);
addlabel(1, "call2x profit " + call2x_profit, color.green);
addlabel(1, "trades " + call2x_qty, color.yellow);
addlabel(1, "avg call2x trade $ " + ( call2x_profit/call2x_qty), color.yellow);


plot c2xbuy = if call2x_en then call2x_pr else na;
c2xbuy.setdefaultcolor(color.green);


input test2x = no;
addchartbubble(test2x, high,
call2x_en + " bc2x\n" +
sellc_bub + " sc\n" +
sell_c2x_en + " sc2x\n" +
"sell call2x"
, (if sell_c2x_en then color.magenta else color.gray), yes);


#-----------------------------------------------------

AddChartBubble(show_original_buy_bubbles and call_bub, low, "Call", color.green, no);
AddChartBubble(show_original_buy_bubbles and put_bub, high, "Put", color.green, yes);

AddChartBubble(show_original_sell_bubbles and sellp_bub, low, "Sell_P", color.red, no);
AddChartBubble(show_original_sell_bubbles and sellc_bub, high, "Sell_C", color.red, yes);

# -----------------------------------

AddChartBubble(show_original_buy_bubbles and callx_bub, low, "CallX", color.orange, no);
AddChartBubble(show_original_buy_bubbles and putx_bub, high, "PutX", color.orange, yes);


#ALERTS
Alert(BuyCall and !BuyCall[10], "CALL", Alert.Bar, Sound.Ring);
Alert(BuyPut and !BuyPut[10], "PUT", Alert.Bar, Sound.Ring);
Alert((SellPut and !SellPut[10]) or (SellCall and !SellCall[10]), "SELL", Alert.Bar, Sound.Bell);

#ORDERS
#AddOrder(OrderType.BUY_TO_OPEN, (BuyCall and !BuyCall[10]) and (CompareEMA1 > CompareEMA2), open[-1], 100, Color.green, Color.light_green,"BUY CALL");
#AddOrder(OrderType.SELL_TO_OPEN, (BuyPut and !BuyPut[10]) and (CompareEMA1 < CompareEMA2), open[-1], 100, Color.green, Color.light_green,"BUY PUT");
#AddOrder(OrderType.BUY_TO_OPEN, (BuyCall and !BuyCall[10]) and (CompareEMA1 < CompareEMA2), open[-1], 100, Color.orange, Color.light_orange,"BUY CALL*");
#AddOrder(OrderType.SELL_TO_OPEN, (BuyPut and !BuyPut[10]) and (CompareEMA1 > CompareEMA2), open[-1], 100, Color.orange, Color.light_orange,"BUY PUT*");
#AddOrder(OrderType.SELL_TO_CLOSE, (SellCall and !SellCall[10]), open[-1], 100, Color.red, Color.light_red,"SELL CALL");
#AddOrder(OrderType.BUY_TO_CLOSE, (SellPut and !SellPut[10]), open[-1], 100, Color.red, Color.light_red,"SELL PUT");

#WATCHLIST INDICATORS
#TSI WATCHLIST INDICTOR - http://tos.mx/XtJhm6P
#MOMO WATCHLIST INDICATOR - http://tos.mx/N3Y7a4Q
#CALL AND PUT WATCHLIST INDICTOR - http://tos.mx/KS68sJX
#MACD WATCHLIST INDICATOR - http://tos.mx/THMeAW1
#EMA WATCHLIST INDICATOR - http://tos.mx/2s4TNaf
 
Last edited:
I'll go ahead and mention this now just in case this is something you already know how to do. Since I am using MTF I have a repainting issue.

My thought process is that I restrict the signals to a 1 minute window every 10 minutes. I tried to add the below code to the buy triggers but then the bubbles just disappear. I am sure my GetTime() formula is wrong. On the def IndTime1= line I even tried 540, 600, and 660 but none of them worked.

#TIME
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def GetTime = GetTime() > RegularTradingStart(GetYYYYMMDD());
def IndTime1 = StartTime + 600;
def IndTime2 = IndTime1 + 600;
def IndTime3 = IndTime2 + 600;
def IndTime4 = IndTime3 + 600;
def IndTime5 = IndTime4 + 600;
def IndTime6 = IndTime5 + 600;
def IndTime7 = IndTime6 + 600;
def IndTime8 = IndTime7 + 600;
def IndTime9 = IndTime8 + 600;
def IndTime10 = IndTime9 + 600;
def IndTime11 = IndTime10 + 600;
def IndTime12 = IndTime11 + 600;
def IndTime13 = IndTime12 + 600;
def IndTime14 = IndTime13 + 600;
def IndTime15 = IndTime14 + 600;
def IndTime16 = IndTime15 + 600;
def IndTime17 = IndTime16 + 600;
def IndTime18 = IndTime17 + 600;
def IndTime19 = IndTime18 + 600;
def IndTime20 = IndTime19 + 600;
def IndTime21 = IndTime20 + 600;
def IndTime22 = IndTime21 + 600;
def IndTime23 = IndTime22 + 600;
def IndTime24 = IndTime23 + 600;
def IndTime25 = IndTime24 + 600;
def IndTime26 = IndTime25 + 600;
def IndTime27 = IndTime26 + 600;
def IndTime28 = IndTime27 + 600;
def IndTime29 = IndTime28 + 600;
def IndTime30 = IndTime29 + 600;
def IndTime31 = IndTime30 + 600;
def IndTime32 = IndTime31 + 600;
def IndTime33 = IndTime32 + 600;
def IndTime34 = IndTime33 + 600;
def IndTime35 = IndTime34 + 600;
def IndTime36 = IndTime35 + 600;
def IndTime37 = IndTime36 + 600;
def IndTime38 = IndTime37 + 600;
def IndTime39 = IndTime38 + 600;
def IndTime40 = IndTime39 + 600;
def IndTime41 = IndTime40 + 600;

def BtwTime1 = GetTime between IndTime1 and (IndTime1 + 60);
def BtwTime2 = GetTime between IndTime2 and (IndTime2 + 60);
def BtwTime3 = GetTime between IndTime3 and (IndTime3 + 60);
def BtwTime4 = GetTime between IndTime4 and (IndTime4 + 60);
def BtwTime5 = GetTime between IndTime5 and (IndTime5 + 60);
def BtwTime6 = GetTime between IndTime6 and (IndTime6 + 60);
def BtwTime7 = GetTime between IndTime7 and (IndTime7 + 60);
def BtwTime8 = GetTime between IndTime8 and (IndTime8 + 60);
def BtwTime9 = GetTime between IndTime9 and (IndTime9 + 60);
def BtwTime10 = GetTime between IndTime10 and (IndTime10 + 60);
def BtwTime11 = GetTime between IndTime11 and (IndTime11 + 60);
def BtwTime12 = GetTime between IndTime12 and (IndTime12 + 60);
def BtwTime13 = GetTime between IndTime13 and (IndTime13 + 60);
def BtwTime14 = GetTime between IndTime14 and (IndTime14 + 60);
def BtwTime15 = GetTime between IndTime15 and (IndTime15 + 60);
def BtwTime16 = GetTime between IndTime16 and (IndTime16 + 60);
def BtwTime17 = GetTime between IndTime17 and (IndTime17 + 60);
def BtwTime18 = GetTime between IndTime18 and (IndTime18 + 60);
def BtwTime19 = GetTime between IndTime19 and (IndTime19 + 60);
def BtwTime20 = GetTime between IndTime20 and (IndTime20 + 60);
def BtwTime21 = GetTime between IndTime21 and (IndTime21 + 60);
def BtwTime22 = GetTime between IndTime22 and (IndTime22 + 60);
def BtwTime23 = GetTime between IndTime23 and (IndTime23 + 60);
def BtwTime24 = GetTime between IndTime24 and (IndTime24 + 60);
def BtwTime25 = GetTime between IndTime25 and (IndTime25 + 60);
def BtwTime26 = GetTime between IndTime26 and (IndTime26 + 60);
def BtwTime27 = GetTime between IndTime27 and (IndTime27 + 60);
def BtwTime28 = GetTime between IndTime28 and (IndTime28 + 60);
def BtwTime29 = GetTime between IndTime29 and (IndTime29 + 60);
def BtwTime30 = GetTime between IndTime30 and (IndTime30 + 60);
def BtwTime31 = GetTime between IndTime31 and (IndTime31 + 60);
def BtwTime32 = GetTime between IndTime32 and (IndTime32 + 60);
def BtwTime33 = GetTime between IndTime33 and (IndTime33 + 60);
def BtwTime34 = GetTime between IndTime34 and (IndTime34 + 60);
def BtwTime35 = GetTime between IndTime35 and (IndTime35 + 60);
def BtwTime36 = GetTime between IndTime36 and (IndTime36 + 60);
def BtwTime37 = GetTime between IndTime37 and (IndTime37 + 60);
def BtwTime38 = GetTime between IndTime38 and (IndTime38 + 60);
def BtwTime39 = GetTime between IndTime39 and (IndTime39 + 60);
def BtwTime40 = GetTime between IndTime40 and (IndTime40 + 60);
def BtwTime41 = GetTime between IndTime41 and (IndTime41 + 60);

def MTFRepaintFix = BtwTime1 or BtwTime2 or BtwTime3 or BtwTime4 or BtwTime5 or BtwTime6 or BtwTime7 or BtwTime8 or BtwTime9 or BtwTime10 or BtwTime11 or BtwTime12 or BtwTime13 or BtwTime14 or BtwTime15 or BtwTime16 or BtwTime17 or BtwTime18 or BtwTime19 or BtwTime20 or BtwTime21 or BtwTime22 or BtwTime23 or BtwTime24 or BtwTime25 or BtwTime26 or BtwTime27 or BtwTime29 or BtwTime29 or BtwTime30 or BtwTime31 or BtwTime32 or BtwTime33 or BtwTime34 or BtwTime35 or BtwTime36 or BtwTime37 or BtwTime38 or BtwTime39 or BtwTime40 or BtwTime41;
 
@halcyonguy I worked on this a little more today.

I changed some of the def names so I could try to wrap my head around it a little better. I still can't see anything but the calls but then again I don't fully understand the code, lol

I added everything that I thought should be added and cleaned it up as much as possible.

Hopefully you can still understand what you wrote after I changed a lot of the names.

I also am not seeing any profit or loss, just "N/A" I'm sure it's just one tiny thing off for that.

Thanks again for all your help!

Code:
#TSI_EMA_MACD_COMPARE_MOMO_INDICATOR_A1C_03

#JT MOMO INDICATOR

# -----------------------

# new call buy , call sell  bubbles
# profit labels

#------------------------

# https://usethinkscript.com/threads/chart-bubble-exception.10457/
# Chart Bubble Exception
# a1cturner

#Study:
#http://tos.mx/xxT5JdV
#TSI_EMA_MACD_COMPARE_MOMO_INDICATOR

#USED TO IDENTIFY REVERSALS IN DAILY TRENDS FOR SCALPS OR DAY TRADES ONLY.
#USE ON 1 MINUTE CHART ONLY BUT IN CONJUNCTION WITH 10 MINUTE CHART.
#I USE 5/12 AND 34/50 EMA CLOUDS ON MY 10 MINUTE CHART ALONG WITH A FASTER MACD (10, 22, 8) AND RSI.

#ONCE THE INDICATOR IS TRIGGERED WITH CALL OR PUT I WILL SUBMIT A 50ish DELTA CALL OR PUT WITH A MARKET ORDER

#*****ENSURE THAT THERE HAS NOT BEEN ANOTHER CALL OR PUT TRIGGER SINCE THE REVERSAL (USUALLY WITHIN THE PAST 20-30 MINUTES). IF THERE IS, THAN YOU ARE LATE AND SHOULD WAIT FOR THE NEXT OPPURTUNITY*****#

#*****ALWAYS LOOK AT THE VOLUME OF THE OPTION YOU ARE BUYING*****#

#*****PLAY STOCKS THAT YOU KNOW WHERE SUPPORT/RESISTANCE ARE IF POSSIBLE*****#

#EXIT ON THE SELL INDICATOR NO MATTER WHAT. YOU DECIDE WHETHER YOU GET BACK IN ON THE REVERSAL IF YOU GET A SELL INDICATOR AND BUY INDICATOR ON THE SAME CANDLE. I PERSONNALY LIKE TO WAIT AND LOOK FOR OTHER OPPURTUNITIES.

#GREEN "CALL" OR "PUT" ARE BUY INDICATORS TRENDING IN THE SAME DIRECTON AS THE COMPARISSON TICKER (VIX). ORANGE "CALL*" OR "PUT*" ARE BUY INDICATORS TRENDING IN THE OPPOSITE DIRECTON AS THE COMPARISSON TICKER (VIX). *****MAKE SURE YOU KNOW WHICH WAY YOUR TICKER IS TRENDING COMPARED TO THE COMPARRISON TICKER*****

declare upper;

input MovAvg = AverageType.EXPONENTIAL;
input TSITime = aggregationPeriod.MIN;
input TSILongLength = 34;
input TSIShortLength = 5;
input TSISignalLength = 5;
input EMATime = aggregationPeriod.TEN_MIN;
input EMAFast = 5;
input EMASlow = 12;
input MACDTime = aggregationPeriod.TEN_MIN;
input MACDFast = 10;
input MACDSlow = 22;
input MACDLength = 8;
input Symbol = "VIX";
input StartTime = 0930;
input StartTimeDelay = 29;
input EndTime = 1600;
input SignalEndTimeDelay = 89;
input StopEndTimeDelay = 0;

#CLOSE
def TSIClose = close(period=TSITime);
def EMAClose = close(period=EMATime);
def MACDClose = close(period=MACDTime);
def CompareClose = close(Symbol, period=EMATime);

#TRUE STENGTH INDEX(TSI)
def TSIDiff = TSIClose - TSIClose[1];
def DoubleSmoothedAbsDiffShort = MovingAverage(MovAvg, MovingAverage(MovAvg, AbsValue(TSIDiff), TSILongLength), TSIShortLength);

#TSI 1 Min
def TSI = if DoubleSmoothedAbsDiffShort == 0 then 0 else 100 * (MovingAverage(MovAvg, MovingAverage(MovAvg, TSIDiff, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiffShort;
def SignalShort = MovingAverage(MovAvg, TSI, TSISignalLength);

#EMAs
def EMAFast1 = MovingAverage(MovAvg, EMAClose, EMAFast);
def EMASlow1 = MovingAverage(MovAvg, EMAClose, EMASlow);
def CompareEMAFast1 = MovingAverage(MovAvg, CompareClose, EMAFast);
def CompareEMASlow1 = MovingAverage(MovAvg, CompareClose, EMASlow);

#EMA PERCENT
def EMAPct = ((EMAFast1 / EMASlow1)*100)-100;

#MACD
def MACD = MovingAverage(MovAvg, MACDClose, MACDFast) -
MovingAverage(MovAvg, MACDClose, MACDSlow);
def MACDVar = MovingAverage(MovAvg, MACD, MACDLength);
def MACDDiff = MACD - MACDVar;

#START AND END TIME
def StartDay = (secondsfromtime (StartTime)) > (StartTimeDelay*60);
def EndSignal = (secondstilltime (EndTime)) > (SignalEndTimeDelay*60);
def EndStop = (secondstilltime (EndTime)) > (StopEndTimeDelay*60);

#BUY CALL and PUT
def BuyCallTimeRest = StartDay and EndSignal;
def BuyCall1Min = TSI > TSI[1];
def BuyCall10Min = (EMAFast1 > EMASlow1) and (MACDDiff > MACDDiff[1]);
def BuyCall = BuyCallTimeRest and BuyCall1Min and BuyCall10Min;

def BuyPutTimeRest = StartDay and EndSignal;
def BuyPut1Min = TSI < TSI[1];
def BuyPut10Min = (EMAFast1 < EMASlow1) and (MACDDiff < MACDDiff[1]);
def BuyPut = BuyPutTimeRest and BuyPut1Min and BuyPut10Min;

#SELL CALL AND PUT
def SellCallTimeRest = StartDay and EndStop;
def SellCall = SellCallTimeRest and BuyCall is true within 125 bars and (MACDDiff < MACDDiff[1]);

def SellPutTimeRest = StartDay and EndStop;
def SellPut = SellPutTimeRest and BuyPut is true within 125 bars and (MACDDiff > MACDDiff[1]);

# --------------------------------------------------------
# new code - halcyonguy
def na = double.nan;

input ShowOldBuyBubbles = no;
input ShowOldSellBubbles = no;

input ShowNewBuyBubbles = yes;
input ShowNewSellBubbles = yes;

def CompareTrendUp = CompareEMAFast1 > CompareEMASlow1;
def CompareTrendDown = CompareEMAFast1 < CompareEMASlow1;

def BuyCallInd = (BuyCall and !BuyCall[1] and CompareTrendDown);
def BuyPutInd = (BuyPut and !BuyPut[1] and CompareTrendUp);
def BuyCallXInd = (BuyCall and !BuyCall[1] and CompareTrendUp);
def BuyPutXInd = (BuyPut and !BuyPut[1] and CompareTrendDown);

def SellCallInd = SellCall and !SellCall[1];
def SellPutInd = SellPut and !SellPut[1];

#-----------------------------------------------------
# if call or put was triggered, don't show another trigger
def BuyCallElse = if SellCallInd then 0 else if BuyCallInd then 1 else BuyCallElse[1];
def BuyPutElse = if SellPutInd then 0 else if BuyPutInd then 1 else BuyPutElse[1];

def BuyCallElse2 = if BuyCallElse[1] == 0 and BuyCallElse == 1 then 1 else 0;
def BuyPutElse2 = if BuyPutElse[1] == 0 and BuyPutElse == 1 then 1 else 0;

AddChartBubble(ShowNewBuyBubbles and BuyCallElse2, low, "Call New", color.light_green, no);
AddChartBubble(ShowNewBuyBubbles and BuyPutElse2, high, "Put New", color.light_red, yes);

def BuyCallXElse = if SellCallInd then 0 else if BuyCallXInd then 1 else BuyCallXElse[1];
def BuyPutXElse = if SellPutInd then 0 else if BuyPutXInd then 1 else BuyPutXElse[1];

def BuyCallXElse2 = if BuyCallXElse[1] == 0 and BuyCallXElse == 1 then 1 else 0;
def BuyPutXElse2 = if BuyPutXElse[1] == 0 and BuyPutXElse == 1 then 1 else 0;

AddChartBubble(ShowNewBuyBubbles and BuyCallXElse2, low, "Call-X New", color.light_orange, no);
AddChartBubble(ShowNewBuyBubbles and BuyPutXElse2, high, "Put-X New", color.light_orange, yes);

#-----------------------------------------------------
# if a sell was triggered, don't show another. act on the 1st sell
def SellCallElse = if (BuyCallElse[1] and SellCallInd) then 1 else if SellCallElse[1] then 0 else SellCallElse[1];
addchartbubble(SellCallElse, high, "Sell Call New", color.light_red, yes);
def SellPutElse = if (BuyPutElse[1] and SellPutInd) then 1 else if SellPutElse[1] then 0 else SellPutElse[1];
addchartbubble(SellPutElse, high, "Sell Put New", color.light_red, yes);

def SellCallXElse = if (BuyCallXElse[1] and SellCallInd) then 1 else if SellCallXElse[1] then 0 else SellCallXElse[1];
addchartbubble(SellCallXElse, high, "Sell Call-X New", color.light_red, yes);
def SellPutXElse = if (BuyPutXElse[1] and SellPutInd) then 1 else if SellPutXElse[1] then 0 else SellPutXElse[1];
addchartbubble(SellPutXElse, high, "Sell Call-X New", color.light_red, yes);

#-----------------------------------------------------#PROFIT LABELS
def Call_PR = if BuyCallElse2 then close else Call_PR[1];
def CallProfit = if SellCallElse then (CallProfit[1] + ( close - Call_PR)) else CallProfit[1];
def CallQty = if BuyCallElse2 then CallQty[1] + 1 else CallQty[1];

addlabel(1, "   ", color.black);
addlabel(1, "Call Profit " + CallProfit, color.green);
addlabel(1, "Trades " + CallQty, color.yellow);
addlabel(1, "Avg Call Trade $ " + (CallProfit/CallQty), color.yellow);

plot CallBuy = if BuyCallElse then Call_PR else na;
CallBuy.setdefaultcolor(color.light_green);

def Put_PR = if BuyPutElse2 then close else Put_PR[1];
def PutProfit = if SellPutElse then (PutProfit[1] + ( close - Put_PR)) else PutProfit[1];
def PutQty = if BuyPutElse2 then PutQty[1] + 1 else PutQty[1];

addlabel(1, "   ", color.black);
addlabel(1, "Put Profit " + PutProfit, color.green);
addlabel(1, "Trades " + PutQty, color.yellow);
addlabel(1, "Avg Put Trade $ " + (PutProfit/PutQty), color.yellow);

plot PutBuy = if BuyPutElse then Put_PR else na;
PutBuy.setdefaultcolor(color.light_green);

def CallX_PR = if BuyCallXElse2 then close else CallX_PR[1];
def CallXProfit = if SellCallXElse then (CallXProfit[1] + ( close - CallX_PR)) else CallXProfit[1];
def CallXQty = if BuyCallXElse2 then CallXQty[1] + 1 else CallXQty[1];

addlabel(1, "   ", color.black);
addlabel(1, "Call-X Profit " + CallXProfit, color.green);
addlabel(1, "Trades " + CallXQty, color.yellow);
addlabel(1, "Avg Call-X Trade $ " + (CallXProfit/CallXQty), color.yellow);

plot CallXBuy = if BuyCallXElse then CallX_PR else na;
CallXBuy.setdefaultcolor(color.light_orange);

def PutX_PR = if BuyPutXElse2 then close else PutX_PR[1];
def PutXProfit = if SellPutXElse then (PutXProfit[1] + ( close - PutX_PR)) else PutXProfit[1];
def PutXQty = if BuyPutXElse2 then PutXQty[1] + 1 else PutXQty[1];

addlabel(1, "   ", color.black);
addlabel(1, "Put-X Profit " + PutXProfit, color.green);
addlabel(1, "Trades " + PutXQty, color.yellow);
addlabel(1, "Avg Put-X Trade $ " + (PutXProfit/PutXQty), color.yellow);

plot PutXBuy = if BuyPutXElse then PutX_PR else na;
PutXBuy.setdefaultcolor(color.light_orange);

#-----------------------------------------------------#TEST
input Test = no;
addchartbubble(Test, high,
 BuyCallElse + " bc2\n" +
 SellCallInd + " sc\n" +
 SellCallElse + "  sc2\n" +
 "sell call2"
,(if SellCallElse then color.magenta else color.gray), yes);

input TestX = no;
addchartbubble(TestX, high,
 BuyCallXElse + " bc2x\n" +
 SellCallInd + " sc\n" +
 SellCallXElse + "  sc2x\n" +
 "sell call2x"
,(if SellCallXElse then color.magenta else color.gray), yes);

#-----------------------------------------------------#OLD BUY BUBBLES
AddChartBubble(ShowOldBuyBubbles and BuyCallInd, low, "Call", color.green, no);
AddChartBubble(ShowOldBuyBubbles and BuyPutInd, high, "Put", color.green, yes);

AddChartBubble(ShowOldBuyBubbles and SellPutInd, low, "Sell Put", color.red, no);
AddChartBubble(ShowOldBuyBubbles and SellCallInd, high, "Sell Call", color.red, yes);

AddChartBubble(ShowOldBuyBubbles and BuyCallXInd, low, "Call-X", color.orange, no);
AddChartBubble(ShowOldBuyBubbles and BuyPutXInd, high, "Put-X", color.orange, yes);

#ALERTS
Alert(BuyCall and !BuyCall[10], "CALL", Alert.Bar, Sound.Ring);
Alert(BuyPut and !BuyPut[10], "PUT", Alert.Bar, Sound.Ring);
Alert((SellPut and !SellPut[10]) or (SellCall and !SellCall[10]), "SELL", Alert.Bar, Sound.Bell);

#ORDERS
#AddOrder(OrderType.BUY_TO_OPEN, (BuyCall and !BuyCall[10]) and (CompareEMA1 > CompareEMA2), open[-1], 100, Color.green, Color.light_green,"BUY CALL");
#AddOrder(OrderType.SELL_TO_OPEN, (BuyPut and !BuyPut[10]) and (CompareEMA1 < CompareEMA2), open[-1], 100, Color.green, Color.light_green,"BUY PUT");
#AddOrder(OrderType.BUY_TO_OPEN, (BuyCall and !BuyCall[10]) and (CompareEMA1 < CompareEMA2), open[-1], 100, Color.orange, Color.light_orange,"BUY CALL*");
#AddOrder(OrderType.SELL_TO_OPEN, (BuyPut and !BuyPut[10]) and (CompareEMA1 > CompareEMA2), open[-1], 100, Color.orange, Color.light_orange,"BUY PUT*");
#AddOrder(OrderType.SELL_TO_CLOSE, (SellCall and !SellCall[10]), open[-1], 100, Color.red, Color.light_red,"SELL CALL");
#AddOrder(OrderType.BUY_TO_CLOSE, (SellPut and !SellPut[10]), open[-1], 100, Color.red, Color.light_red,"SELL PUT");

#WATCHLIST INDICATORS
#TSI WATCHLIST INDICTOR - http://tos.mx/XtJhm6P
#MOMO WATCHLIST INDICATOR - http://tos.mx/N3Y7a4Q
#CALL AND PUT WATCHLIST INDICTOR - http://tos.mx/KS68sJX
#MACD WATCHLIST INDICATOR - http://tos.mx/THMeAW1
#EMA WATCHLIST INDICATOR - http://tos.mx/2s4TNaf
 
@halcyonguy I finally figured out how to limit the triggers to between 09:50-09:51, 10:00-10:01, 10:20-10:21 etc. Basically every 10 minutes so I don't get the triggers before it confirms.

Code:
#CURRENT TIME
def FromStart = (secondsfromtime(0000))/3600;
def Hour = rounddown(FromStart, 0);
def Min = ((FromStart - Hour)/100)*60;

#TIME
def GetTime = Hour + Min;
def IndTime1 = StartTime/100;
def IndTime2 = IndTime1 + .1;
def IndTime3 = IndTime2 + .1;
def IndTime4 = IndTime3 + .1;
def IndTime5 = IndTime4 + .1;
def IndTime6 = IndTime5 + .1;
def IndTime7 = IndTime6 + .1;
def IndTime8 = IndTime7 + .1;
def IndTime9 = IndTime8 + .1;
def IndTime10 = IndTime9 + .1;
def IndTime11 = IndTime10 + .1;
def IndTime12 = IndTime11 + .1;
def IndTime13 = IndTime12 + .1;
def IndTime14 = IndTime13 + .1;
def IndTime15 = IndTime14 + .1;
def IndTime16 = IndTime15 + .1;
def IndTime17 = IndTime16 + .1;
def IndTime18 = IndTime17 + .1;
def IndTime19 = IndTime18 + .1;
def IndTime20 = IndTime19 + .1;
def IndTime21 = IndTime20 + .1;
def IndTime22 = IndTime21 + .1;
def IndTime23 = IndTime22 + .1;
def IndTime24 = IndTime23 + .1;
def IndTime25 = IndTime24 + .1;
def IndTime26 = IndTime25 + .1;
def IndTime27 = IndTime26 + .1;
def IndTime28 = IndTime27 + .1;
def IndTime29 = IndTime28 + .1;
def IndTime30 = IndTime29 + .1;
def IndTime31 = IndTime30 + .1;
def IndTime32 = IndTime31 + .1;
def IndTime33 = IndTime32 + .1;
def IndTime34 = IndTime33 + .1;
def IndTime35 = IndTime34 + .1;
def IndTime36 = IndTime35 + .1;
def IndTime37 = IndTime36 + .1;
def IndTime38 = IndTime37 + .1;
def IndTime39 = IndTime38 + .1;
def IndTime40 = IndTime39 + .1;
def IndTime41 = IndTime40 + .1;

def BtwTime1 = GetTime between IndTime1 and (IndTime1 + 0.01);
def BtwTime2 = GetTime between IndTime2 and (IndTime2 + 0.01);
def BtwTime3 = GetTime between IndTime3 and (IndTime3 + 0.01);
def BtwTime4 = GetTime between IndTime4 and (IndTime4 + 0.01);
def BtwTime5 = GetTime between IndTime5 and (IndTime5 + 0.01);
def BtwTime6 = GetTime between IndTime6 and (IndTime6 + 0.01);
def BtwTime7 = GetTime between IndTime7 and (IndTime7 + 0.01);
def BtwTime8 = GetTime between IndTime8 and (IndTime8 + 0.01);
def BtwTime9 = GetTime between IndTime9 and (IndTime9 + 0.01);
def BtwTime10 = GetTime between IndTime10 and (IndTime10 + 0.01);
def BtwTime11 = GetTime between IndTime11 and (IndTime11 + 0.01);
def BtwTime12 = GetTime between IndTime12 and (IndTime12 + 0.01);
def BtwTime13 = GetTime between IndTime13 and (IndTime13 + 0.01);
def BtwTime14 = GetTime between IndTime14 and (IndTime14 + 0.01);
def BtwTime15 = GetTime between IndTime15 and (IndTime15 + 0.01);
def BtwTime16 = GetTime between IndTime16 and (IndTime16 + 0.01);
def BtwTime17 = GetTime between IndTime17 and (IndTime17 + 0.01);
def BtwTime18 = GetTime between IndTime18 and (IndTime18 + 0.01);
def BtwTime19 = GetTime between IndTime19 and (IndTime19 + 0.01);
def BtwTime20 = GetTime between IndTime20 and (IndTime20 + 0.01);
def BtwTime21 = GetTime between IndTime21 and (IndTime21 + 0.01);
def BtwTime22 = GetTime between IndTime22 and (IndTime22 + 0.01);
def BtwTime23 = GetTime between IndTime23 and (IndTime23 + 0.01);
def BtwTime24 = GetTime between IndTime24 and (IndTime24 + 0.01);
def BtwTime25 = GetTime between IndTime25 and (IndTime25 + 0.01);
def BtwTime26 = GetTime between IndTime26 and (IndTime26 + 0.01);
def BtwTime27 = GetTime between IndTime27 and (IndTime27 + 0.01);
def BtwTime28 = GetTime between IndTime28 and (IndTime28 + 0.01);
def BtwTime29 = GetTime between IndTime29 and (IndTime29 + 0.01);
def BtwTime30 = GetTime between IndTime30 and (IndTime30 + 0.01);
def BtwTime31 = GetTime between IndTime31 and (IndTime31 + 0.01);
def BtwTime32 = GetTime between IndTime32 and (IndTime32 + 0.01);
def BtwTime33 = GetTime between IndTime33 and (IndTime33 + 0.01);
def BtwTime34 = GetTime between IndTime34 and (IndTime34 + 0.01);
def BtwTime35 = GetTime between IndTime35 and (IndTime35 + 0.01);
def BtwTime36 = GetTime between IndTime36 and (IndTime36 + 0.01);
def BtwTime37 = GetTime between IndTime37 and (IndTime37 + 0.01);
def BtwTime38 = GetTime between IndTime38 and (IndTime38 + 0.01);
def BtwTime39 = GetTime between IndTime39 and (IndTime39 + 0.01);
def BtwTime40 = GetTime between IndTime40 and (IndTime40 + 0.01);
def BtwTime41 = GetTime between IndTime41 and (IndTime41 + 0.01);

def MTFRepaintFix = BtwTime1 or BtwTime2 or BtwTime3 or BtwTime4 or BtwTime5 or BtwTime6 or BtwTime7 or BtwTime8 or BtwTime9 or BtwTime10 or BtwTime11 or BtwTime12 or BtwTime13 or BtwTime14 or BtwTime15 or BtwTime16 or BtwTime17 or BtwTime18 or BtwTime19 or BtwTime20 or BtwTime21 or BtwTime22 or BtwTime23 or BtwTime24 or BtwTime25 or BtwTime26 or BtwTime27 or BtwTime29 or BtwTime29 or BtwTime30 or BtwTime31 or BtwTime32 or BtwTime33 or BtwTime34 or BtwTime35 or BtwTime36 or BtwTime37 or BtwTime38 or BtwTime39 or BtwTime40 or BtwTime41;
 
@halcyonguy I finally figured out how to limit the triggers to between 09:50-09:51, 10:00-10:01, 10:20-10:21 etc. Basically every 10 minutes so I don't get the triggers before it confirms.

Code:
#CURRENT TIME
def FromStart = (secondsfromtime(0000))/3600;
def Hour = rounddown(FromStart, 0);
def Min = ((FromStart - Hour)/100)*60;

#TIME
def GetTime = Hour + Min;
def IndTime1 = StartTime/100;
def IndTime2 = IndTime1 + .1;
def IndTime3 = IndTime2 + .1;
def IndTime4 = IndTime3 + .1;
def IndTime5 = IndTime4 + .1;
def IndTime6 = IndTime5 + .1;
def IndTime7 = IndTime6 + .1;
def IndTime8 = IndTime7 + .1;
def IndTime9 = IndTime8 + .1;
def IndTime10 = IndTime9 + .1;
def IndTime11 = IndTime10 + .1;
def IndTime12 = IndTime11 + .1;
def IndTime13 = IndTime12 + .1;
def IndTime14 = IndTime13 + .1;
def IndTime15 = IndTime14 + .1;
def IndTime16 = IndTime15 + .1;
def IndTime17 = IndTime16 + .1;
def IndTime18 = IndTime17 + .1;
def IndTime19 = IndTime18 + .1;
def IndTime20 = IndTime19 + .1;
def IndTime21 = IndTime20 + .1;
def IndTime22 = IndTime21 + .1;
def IndTime23 = IndTime22 + .1;
def IndTime24 = IndTime23 + .1;
def IndTime25 = IndTime24 + .1;
def IndTime26 = IndTime25 + .1;
def IndTime27 = IndTime26 + .1;
def IndTime28 = IndTime27 + .1;
def IndTime29 = IndTime28 + .1;
def IndTime30 = IndTime29 + .1;
def IndTime31 = IndTime30 + .1;
def IndTime32 = IndTime31 + .1;
def IndTime33 = IndTime32 + .1;
def IndTime34 = IndTime33 + .1;
def IndTime35 = IndTime34 + .1;
def IndTime36 = IndTime35 + .1;
def IndTime37 = IndTime36 + .1;
def IndTime38 = IndTime37 + .1;
def IndTime39 = IndTime38 + .1;
def IndTime40 = IndTime39 + .1;
def IndTime41 = IndTime40 + .1;

def BtwTime1 = GetTime between IndTime1 and (IndTime1 + 0.01);
def BtwTime2 = GetTime between IndTime2 and (IndTime2 + 0.01);
def BtwTime3 = GetTime between IndTime3 and (IndTime3 + 0.01);
def BtwTime4 = GetTime between IndTime4 and (IndTime4 + 0.01);
def BtwTime5 = GetTime between IndTime5 and (IndTime5 + 0.01);
def BtwTime6 = GetTime between IndTime6 and (IndTime6 + 0.01);
def BtwTime7 = GetTime between IndTime7 and (IndTime7 + 0.01);
def BtwTime8 = GetTime between IndTime8 and (IndTime8 + 0.01);
def BtwTime9 = GetTime between IndTime9 and (IndTime9 + 0.01);
def BtwTime10 = GetTime between IndTime10 and (IndTime10 + 0.01);
def BtwTime11 = GetTime between IndTime11 and (IndTime11 + 0.01);
def BtwTime12 = GetTime between IndTime12 and (IndTime12 + 0.01);
def BtwTime13 = GetTime between IndTime13 and (IndTime13 + 0.01);
def BtwTime14 = GetTime between IndTime14 and (IndTime14 + 0.01);
def BtwTime15 = GetTime between IndTime15 and (IndTime15 + 0.01);
def BtwTime16 = GetTime between IndTime16 and (IndTime16 + 0.01);
def BtwTime17 = GetTime between IndTime17 and (IndTime17 + 0.01);
def BtwTime18 = GetTime between IndTime18 and (IndTime18 + 0.01);
def BtwTime19 = GetTime between IndTime19 and (IndTime19 + 0.01);
def BtwTime20 = GetTime between IndTime20 and (IndTime20 + 0.01);
def BtwTime21 = GetTime between IndTime21 and (IndTime21 + 0.01);
def BtwTime22 = GetTime between IndTime22 and (IndTime22 + 0.01);
def BtwTime23 = GetTime between IndTime23 and (IndTime23 + 0.01);
def BtwTime24 = GetTime between IndTime24 and (IndTime24 + 0.01);
def BtwTime25 = GetTime between IndTime25 and (IndTime25 + 0.01);
def BtwTime26 = GetTime between IndTime26 and (IndTime26 + 0.01);
def BtwTime27 = GetTime between IndTime27 and (IndTime27 + 0.01);
def BtwTime28 = GetTime between IndTime28 and (IndTime28 + 0.01);
def BtwTime29 = GetTime between IndTime29 and (IndTime29 + 0.01);
def BtwTime30 = GetTime between IndTime30 and (IndTime30 + 0.01);
def BtwTime31 = GetTime between IndTime31 and (IndTime31 + 0.01);
def BtwTime32 = GetTime between IndTime32 and (IndTime32 + 0.01);
def BtwTime33 = GetTime between IndTime33 and (IndTime33 + 0.01);
def BtwTime34 = GetTime between IndTime34 and (IndTime34 + 0.01);
def BtwTime35 = GetTime between IndTime35 and (IndTime35 + 0.01);
def BtwTime36 = GetTime between IndTime36 and (IndTime36 + 0.01);
def BtwTime37 = GetTime between IndTime37 and (IndTime37 + 0.01);
def BtwTime38 = GetTime between IndTime38 and (IndTime38 + 0.01);
def BtwTime39 = GetTime between IndTime39 and (IndTime39 + 0.01);
def BtwTime40 = GetTime between IndTime40 and (IndTime40 + 0.01);
def BtwTime41 = GetTime between IndTime41 and (IndTime41 + 0.01);

def MTFRepaintFix = BtwTime1 or BtwTime2 or BtwTime3 or BtwTime4 or BtwTime5 or BtwTime6 or BtwTime7 or BtwTime8 or BtwTime9 or BtwTime10 or BtwTime11 or BtwTime12 or BtwTime13 or BtwTime14 or BtwTime15 or BtwTime16 or BtwTime17 or BtwTime18 or BtwTime19 or BtwTime20 or BtwTime21 or BtwTime22 or BtwTime23 or BtwTime24 or BtwTime25 or BtwTime26 or BtwTime27 or BtwTime29 or BtwTime29 or BtwTime30 or BtwTime31 or BtwTime32 or BtwTime33 or BtwTime34 or BtwTime35 or BtwTime36 or BtwTime37 or BtwTime38 or BtwTime39 or BtwTime40 or BtwTime41;

Hey man this is very interesting... I understand you were using this strat to trade the one min with 10min for confirmation... how does one go about implementing this repaint fix code?
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
309 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top