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:
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.
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:
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: