Pekelo: Here is a TOS ThinkScript I wrote a while back I used to aid analyzing similar trades. For the Notation (m,n) m is Number days prior to ExDividend for trade entry n is Number of days after ExDividend for exit m is 4,3,2, & 1 n is 1,0 All trades default to Close on Daily bars. (only viable on daily bars). Depending on period selected for your chart, The interval is evaluated for which value of (m,n) if used for the entire interval, produced the greatest return. Labels are displayed to show results. --------------- # This study evaluates 8 cases for excess price reduction arround Ex Dividend # date, and displays the most profitable case as measured in favorable # price action total over the sampling interval. The trades are also # individually identified with the price change and success/fail for # each. Add verbose to observe results from all 8 cases. # # # Used to help identify Dividend trade. #DTEX is set to 1,2,3, or 4 depending upon lead time to trade entry # as identified per Security Back Test screening. # Trades attempt to capitalize on excess downward price action # arround Ex Dividend time. # By gcw on 12/29/2015 # Trade and PnL info are not suggestions, but merely an indication of possible # trades. Likely real trades would use Options for leverage. input AvgChangeThreshold = 0.20; input verbose = 1; input headroom = 0.0; def numEarnings=if (HasEarnings()) then numEarnings[1]+1 else numEarnings[1]; def totalEarnings=highestall(numEarnings); def ChartTimeSettingInYears=(totalEarnings)/4; def ChartSetting=round(ChartTimeSettingInYears,0); def blanking; #if ChartSetting==2 and BarNumber()<140 then #blanking=1; #else if ChartSetting==3 and BarNumber()< 240 then #blanking=1; #else #blanking=0; blanking=if ((ChartSetting==2) and (BarNumber()<240)) then 1 else if ((ChartSetting==3) and (BarNumber()<240)) then 1 else 0; def spanMod = if blanking then 1 else spanMod[1]; #plot blnk=blanking; #def startup = (BarNumber() < 5) or (ChartTimeSettingInYears < (2.50-fudge) and (totalEarnings -numEarnings)>4) or (ChartTimeSettingInYears < (3.50-fudge) and (totalEarnings -numEarnings)>8); def startup = (BarNumber() < 5) or blanking; def dp4 = if IsNaN(GetEventOffset()) then 0 else startup==0 and (GetEventOffset() == -4); def dp3 = if IsNaN(GetEventOffset()) then 0 else startup==0 and (GetEventOffset() == -3); def dp2 = if IsNaN(GetEventOffset()) then 0 else startup==0 and (GetEventOffset() == -2); def dp1 = if IsNaN(GetEventOffset()) then 0 else startup==0 and (GetEventOffset() == -1); def enable_close=dp4 or enable_close[1]; # Require a dp4 event prior to the first close, to insure a clean start. def d = if IsNaN(GetEventOffset()) then 0 else enable_close and (GetEventOffset() == 0); def dm1 = d[1]; #plot enc=enable_close; #plot dp4P=dp4; def dividend; if (d) # Ex date! { dividend = GetDividend(); } else { dividend = dividend[1]; } def entryPrice4 = if dp4 then close else entryPrice4[1]; def entryPrice3 = if dp3 then close else entryPrice3[1]; def entryPrice2 = if dp2 then close else entryPrice2[1]; def entryPrice1 = if dp1 then close else entryPrice1[1]; def exitprice0 = if d then close else exitprice0[1]; # closing price on EX date def exitprice1 = if dm1 then close else exitprice1[1]; #closing price day aver EX date def Change40 = if d then entryPrice4 - exitprice0 - dividend else Change40[1]; def Change30 = if d then entryPrice3 - exitprice0 - dividend else Change30[1]; def Change20 = if d then entryPrice2 - exitprice0 - dividend else Change20[1]; def Change10 = if d then entryPrice1 - exitprice0 - dividend else Change10[1]; def Change41 = if dm1 then entryPrice4 - exitprice1 - dividend else Change41[1]; def Change31 = if dm1 then entryPrice3 - exitprice1 - dividend else Change31[1]; def Change21 = if dm1 then entryPrice2 - exitprice1 - dividend else Change21[1]; def Change11 = if dm1 then entryPrice1 - exitprice1 - dividend else Change11[1]; def Val40=Change40/entryPrice4; def Val30=Change30/entryPrice3; def Val20=Change20/entryPrice2; def Val10=Change10/entryPrice1; def Val41=Change41/entryPrice4; def Val31=Change31/entryPrice3; def Val21=Change21/entryPrice2; def Val11=Change11/entryPrice1; # Sum each case here (Change40 .. Change11) def SChange40 = if startup then 0 else if d then (Change40 + SChange40[1]) else SChange40[1]; def SChange30 = if startup then 0 else if d then (Change30 + SChange30[1]) else SChange30[1]; def SChange20 = if startup then 0 else if d then (Change20 + SChange20[1]) else SChange20[1]; def SChange10 = if startup then 0 else if d then (Change10 + SChange10[1]) else SChange10[1]; def SChange41 = if startup then 0 else if dm1 then (Change41 + SChange41[1]) else SChange41[1]; def SChange31 = if startup then 0 else if dm1 then (Change31 + SChange31[1]) else SChange31[1]; def SChange21 = if startup then 0 else if dm1 then (Change21 + SChange21[1]) else SChange21[1]; def SChange11 = if startup then 0 else if dm1 then (Change11 + SChange11[1]) else SChange11[1]; def SVal40=if startup then 0 else if d then (Val40 + SVal40[1]) else SVal40[1]; def SVal30=if startup then 0 else if d then (Val30 + SVal30[1]) else SVal30[1]; def SVal20=if startup then 0 else if d then (Val20 + SVal20[1]) else SVal20[1]; def SVal10=if startup then 0 else if d then (Val10 + SVal10[1]) else SVal10[1]; def SVal41=if startup then 0 else if d then (Val41 + SVal41[1]) else SVal41[1]; def SVal31=if startup then 0 else if d then (Val31 + SVal31[1]) else SVal31[1]; def SVal21=if startup then 0 else if d then (Val21 + SVal21[1]) else SVal21[1]; def SVal11=if startup then 0 else if d then (Val11 + SVal11[1]) else SVal11[1]; def TotalSChange40=highestall(SChange40); def TotalSChange30=highestall(SChange30); def TotalSChange20=highestall(SChange20); def TotalSChange10=highestall(SChange10); def TotalSChange41=highestall(SChange41); def TotalSChange31=highestall(SChange31); def TotalSChange21=highestall(SChange21); def TotalSChange11=highestall(SChange11); def mdA=(TotalSChange40 > TotalSChange30) and (TotalSChange40 > TotalSChange20) and (TotalSChange40 > TotalSChange10) and (TotalSChange40 > TotalSChange41) and (TotalSChange40 > TotalSChange31) and (TotalSChange40 > TotalSChange21) and (TotalSChange40 > TotalSChange11); def mdB=(TotalSChange30 > TotalSChange40) and (TotalSChange30 > TotalSChange20) and (TotalSChange30 > TotalSChange10) and (TotalSChange30 > TotalSChange41) and (TotalSChange30 > TotalSChange31) and (TotalSChange30 > TotalSChange21) and (TotalSChange30 > TotalSChange11); def mdC=(TotalSChange20 > TotalSChange40) and (TotalSChange20 > TotalSChange30) and (TotalSChange20 > TotalSChange10) and (TotalSChange20 > TotalSChange41) and (TotalSChange20 > TotalSChange31) and (TotalSChange20 > TotalSChange21) and (TotalSChange20 > TotalSChange11); def mdD=(TotalSChange10 > TotalSChange40) and (TotalSChange10 > TotalSChange30) and (TotalSChange10 > TotalSChange20) and (TotalSChange10 > TotalSChange41) and (TotalSChange10 > TotalSChange31) and (TotalSChange10 > TotalSChange21) and (TotalSChange10 > TotalSChange11); def mDDA=(TotalSChange41 > TotalSChange40) and (TotalSChange41 > TotalSChange30) and (TotalSChange41 > TotalSChange20) and (TotalSChange41 > TotalSChange10) and (TotalSChange41 > TotalSChange31) and (TotalSChange41 > TotalSChange21) and (TotalSChange41 > TotalSChange11); def mDDB=(TotalSChange31 > TotalSChange40) and (TotalSChange31 > TotalSChange30) and (TotalSChange31 > TotalSChange20) and (TotalSChange31 > TotalSChange10) and (TotalSChange31 > TotalSChange41) and (TotalSChange31 > TotalSChange21) and (TotalSChange31 > TotalSChange11); def mDDC=(TotalSChange21 > TotalSChange40) and (TotalSChange21 > TotalSChange30) and (TotalSChange21 > TotalSChange20) and (TotalSChange21 > TotalSChange10) and (TotalSChange21 > TotalSChange41) and (TotalSChange21 > TotalSChange31) and (TotalSChange21 > TotalSChange11); def mDDD=(TotalSChange11 > TotalSChange40) and (TotalSChange11 > TotalSChange30) and (TotalSChange11 > TotalSChange20) and (TotalSChange11 > TotalSChange10) and (TotalSChange11 > TotalSChange41) and (TotalSChange11 > TotalSChange31) and (TotalSChange11 > TotalSChange21); #def Wins40 = if d then Wins40[1] + (Change40 > 0) else Wins40[1]; #def Wins30 = if d then Wins30[1] + (Change30 > 0) else Wins30[1]; #def Wins20 = if d then Wins20[1] + (Change20 > 0) else Wins20[1]; #def Wins10D = if d then Wins10D[1] + (Change10 > 0) else Wins10D[1]; # Delay setting the wins below to be concident with the latest possible trade completion. def Wins40 = if startup then 0 else if dm1 then Wins40[1] + (Change40 > 0) else Wins40[1]; def Wins30 = if startup then 0 else if dm1 then Wins30[1] + (Change30 > 0) else Wins30[1]; def Wins20 = if startup then 0 else if dm1 then Wins20[1] + (Change20 > 0) else Wins20[1]; def Wins10 = if startup then 0 else if dm1 then Wins10[1] + (Change10 > 0) else Wins10[1]; def Wins41 = if startup then 0 else if dm1 then Wins41[1] + (Change41 > 0) else Wins41[1]; def Wins31 = if startup then 0 else if dm1 then Wins31[1] + (Change31 > 0) else Wins31[1]; def Wins21 = if startup then 0 else if dm1 then Wins21[1] + (Change21 > 0) else Wins21[1]; def Wins11 = if startup then 0 else if dm1 then Wins11[1] + (Change11 > 0) else Wins11[1]; def entries = if startup then 0 else if dp4 then entries[1] + 1 else entries[1]; def trades = if startup then 0 else if dm1 then trades[1] + 1 else trades[1]; #plot dm1P=dm1; def lowprice = LowestAll(low); def highprice = HighestAll(high); def pricechg = highprice - lowprice; AddChartBubble(mdA and (entries > 0) and d, close, "(4,0): " + Change40 +" or ["+Val40*100+ "%]", if Change40 > 0 then Color.GREEN else Color.RED); AddChartBubble(mdB and (entries > 0) and d, close, "(3,0): " + Change30 +" or ["+Val30*100+ "%]", if Change30 > 0 then Color.GREEN else Color.RED); AddChartBubble(mdC and (entries > 0) and d, close, "(2,0): " + Change20 +" or ["+Val20*100+ "%]", if Change20 > 0 then Color.GREEN else Color.RED); AddChartBubble(mdD and (entries > 0) and d, close, "(1,0): " + Change10 +" or ["+Val10*100+ "%]", if Change10 > 0 then Color.GREEN else Color.RED); AddChartBubble(mDDA and (entries > 0) and dm1, close, "(4,1): " + Change41 +" or ["+Val41*100+ "%]", if Change41 > 0 then Color.GREEN else Color.RED); AddChartBubble(mDDB and (entries > 0) and dm1, close, "(3,1): " + Change31 +" or ["+Val31*100+ "%]", if Change31 > 0 then Color.GREEN else Color.RED); AddChartBubble(mDDC and (entries > 0) and dm1, close, "(2,1): " + Change21 +" or ["+Val21*100+ "%]", if Change21 > 0 then Color.GREEN else Color.RED); AddChartBubble(mDDD and (entries > 0) and dm1, close, "(1,1): " + Change11 +" or ["+Val11*100+ "%]", if Change11 > 0 then Color.GREEN else Color.RED); def PerCentMove =if mdA then SVal40*100/trades else if mdB then SVal30*100/trades else if mdC then SVal20*100/trades else if mdD then SVal10*100/trades else if mDDA then SVal41*100/trades else if mDDB then SVal31*100/trades else if mDDC then SVal21*100/trades else if mDDD then SVal11*100/trades else 0; #AddChartBubble((entries > 0) and (hit and (hit[-1]==0)),close,tradepnl,if tradepnl>0 then Color.GREEN else Color.RED); #def mediocre = CreateColor(128,40,40); AddLabel(mdA, "(4,0) Opportunities for trading Ex Dividend action: # Winning Trades = " + Wins40 + "/" + trades + ", success rate = " + Round((Wins40 / trades) * 100, 0) + "%, Total examined movement=" + SChange40 + ", Average Move (" + SChange40 / trades + "), {"+SVal40*100/trades+"%}", if (SChange40 / trades) > AvgChangeThreshold then Color.GREEN else if (SChange40 / trades) < -AvgChangeThreshold then Color.RED else CreateColor(158, 40, 40)); AddLabel(mdB, "(3,0) Opportunities for trading Ex Dividend action: # Winning Trades = " + Wins30 + "/" + trades + ", success rate = " + Round((Wins30 / trades) * 100, 0) + "%, Total examined movement=" + SChange30 + ", Average Move (" + SChange30 / trades + "), {"+SVal30*100/trades+"%}", if (SChange30 / trades) > AvgChangeThreshold then Color.GREEN else if (SChange30 / trades) < -AvgChangeThreshold then Color.RED else CreateColor(158, 40, 40)); AddLabel(mdC, "(2,0) Opportunities for trading Ex Dividend action: # Winning Trades = " + Wins20 + "/" + trades + ", success rate = " + Round((Wins20 / trades) * 100, 0) + "%, Total examined movement=" + SChange20 + ", Average Move (" + SChange20 / trades + "), {"+SVal20*100/trades+"%}", if (SChange20 / trades) > AvgChangeThreshold then Color.GREEN else if (SChange20 / trades) < -AvgChangeThreshold then Color.RED else CreateColor(158, 40, 40)); AddLabel(mdD, "(1,0) Opportunities for trading Ex Dividend action: # Winning Trades = " + Wins10 + "/" + trades + ", success rate = " + Round((Wins10 / trades) * 100, 0) + "%, Total examined movement=" + SChange10 + ", Average Move (" + SChange10 / trades + "), {"+SVal10*100/trades+"%}", if (SChange10 / trades) > AvgChangeThreshold then Color.GREEN else if (SChange10 / trades) < -AvgChangeThreshold then Color.RED else CreateColor(158, 40, 40)); AddLabel(mDDA, "(4,1) Opportunities for trading Ex Dividend action: # Winning Trades = " + Wins41 + "/" + trades + ", success rate = " + Round((Wins41 / trades) * 100, 0) + "%, Total examined movement=" + SChange41 + ", Average Move (" + SChange41 / trades + "), {"+SVal41*100/trades+"%}", if (SChange41 / trades) > AvgChangeThreshold then Color.GREEN else if (SChange41 / trades) < -AvgChangeThreshold then Color.RED else CreateColor(158, 40, 40)); AddLabel(mDDB, "(3,1) Opportunities for trading Ex Dividend action: # Winning Trades = " + Wins31 + "/" + trades + ", success rate = " + Round((Wins31 / trades) * 100, 0) + "%, Total examined movement=" + SChange31 + ", Average Move (" + SChange31 / trades + "), {"+SVal31*100/trades+"%}", if (SChange31 / trades) > AvgChangeThreshold then Color.GREEN else if (SChange31 / trades) < -AvgChangeThreshold then Color.RED else CreateColor(158, 40, 40)); AddLabel(mDDC, "(2,1) Opportunities for trading Ex Dividend action: # Winning Trades = " + Wins21 + "/" + trades + ", success rate = " + Round((Wins21 / trades) * 100, 0) + "%, Total examined movement=" + SChange21 + ", Average Move (" + SChange21 / trades + "), {"+SVal21*100/trades+"%}", if (SChange21 / trades) > AvgChangeThreshold then Color.GREEN else if (SChange21 / trades) < -AvgChangeThreshold then Color.RED else CreateColor(158, 40, 40)); AddLabel(mDDD, "(1,1) Opportunities for trading Ex Dividend action: # Winning Trades = " + Wins11 + "/" + trades + ", success rate = " + Round((Wins11 / trades) * 100, 0) + "%, Total examined movement=" + SChange11 + ", Average Move (" + SChange11 / trades + "), {"+SVal11*100/trades+"%}", if (SChange11 / trades) > AvgChangeThreshold then Color.GREEN else if (SChange11 / trades) < -AvgChangeThreshold then Color.RED else CreateColor(158, 40, 40)); AddLabel(verbose, "# Trades = " + trades + ", Change per trade: (4,0)=" + SChange40 / trades + ", (3,0)=" + SChange30 / trades + ", (2,0)=" + SChange20 / trades + ", (1,0) =" + SChange10 / trades + ", (4,1)=" + SChange41 / trades + ", (3,1)=" + SChange31 / trades + ", (2,1)=" + SChange21 / trades + ", (1,1)=" + SChange11 / trades, Color.LIGHT_GRAY); #AddLabel(verbose, "(4,0)=" + mdA + ", mdB=" + mdB + ", mdC=" + mdC + ",mdD=" + mdD + ", mDA=" + mDDA + ", mDB=" + mDDB + ", mDC=" + mDDC + ", mDD=" + mDDD, Color.YELLOW); AddLabel(verbose, "WINs: (4,0)=" + Wins40 + ", (3,0)=" + Wins30 + ", (2,0)=" + Wins20 + ",(1,0)=" + Wins10 + ", (4,1)=" + Wins41 + ", (3,1)=" + Wins31 + ", (2,1)=" + Wins21 + ", (1,1)=" + Wins11, Color.WHITE); #AddLabel(yes,"dp4 ="+dp4+", dp3="+dp3+", dp2="+dp2+", dp1="+dp1+", d="+d+", dm1="+dm1+", mDC="+mDDC+", mDD="+mDDD,color.pink); #AddLabel(yes,"Opportunities for trading Ex Dividend action: # Trades found = " + trades + ", success rate = " + Round((wins/trades)*100,0) + "%, Total examined movement=" + runningPnL,if runningPnL > 0 then Color.GREEN else Color.RED); #plot Total examined movement= if mdA then SChange40 else if mdB then SChange30 else if mdC then SChange20 else if mdD then SChange10 else if mDDA then SChange40 else if mDDB then SChange30 else if mDDC then SChange20 else if mDDD then SChange10 else 0; def TradeON = if mdA then (dp4 or dp3 or dp2 or dp1 or d) else if mdB then (dp3 or dp2 or dp1 or d) else if mdC then (dp2 or dp1 or d) else if mdD then (dp1 or d) else if mDDA then (dp4 or dp3 or dp2 or dp1 or d or dm1) else if mDDB then (dp3 or dp2 or dp1 or d or dm1) else if mDDC then (dp2 or dp1 or d or dm1) else if mDDD then (dp1 or d or dm1) else 0; def cloudit; def shade = TradeON * pricechg + lowprice; if (entries > 0 ) { cloudit = shade; } else { cloudit = Double.NaN; #Mask shading of invalid trade. } AddCloud(cloudit, lowprice, Color.VIOLET , Color.PINK); AddVerticalLine(enable_close and TradeON and TradeON[1]==0," Enter near close "+GetMonth()+"/"+GetDayOfMonth(GetYYYYMMDD())+"/"+GetYear(),Color.violet,curve.SHORT_DASH); AddVerticalLine(enable_close and TradeON==0 and TradeON[1]==1," Exit near close "+GetMonth()[1]+"/"+GetDayOfMonth(GetYYYYMMDD()[1])+"/"+GetYear()[1],Color.violet,curve.SHORT_DASH); #plot sh=shade; def blkcld; if blanking { blkcld=highprice; } else { blkcld=Double.NaN;} #AddLabel(ChartTimeSettingInYears>1 and ChartTimeSettingInYears<3.75,"Truncated Eval region on left to observe 1 year or 2 year periods, Chart time in years= "+ChartTimeSettingInYEars+", Chart Setting=" +ChartSetting+"Years",Color.violet); AddLabel(spanMod,"Truncated Eval region on left to observe 1 year or 2 year periods",Color.violet); AddCloud(blkcld,lowprice,Color.light_gray,Color.pink); def temp=close-open[-1]-dividend[-1]; def temp41=close-close[-5]-dividend[-4]; def temp40=close-close[-4]-dividend[-4]; def temp31=close-close[-4]-dividend[-4]; def temp30=close-close[-3]-dividend[-3]; def temp21=close-close[-3]-dividend[-3]; def temp20=close-close[-2]-dividend[-2]; def temp11=close-close[-2]-dividend[-2]; def temp10=close-close[-1]-dividend[-1]; def rel41=(close-close[-5]-dividend[-4])/close; def rel40=(close-close[-4]-dividend[-4])/close; def rel31=(close-close[-4]-dividend[-4])/close; def rel30=(close-close[-3]-dividend[-3])/close; def rel21=(close-close[-3]-dividend[-3])/close; def rel20=(close-close[-2]-dividend[-2])/close; def rel11=(close-close[-2]-dividend[-2])/close; def rel10=(close-close[-1]-dividend[-1])/close; def all41= if dp4 then all41[1]+temp41 else all41[1]; def all40= if dp4 then all40[1]+temp40 else all40[1]; def all31= if dp3 then all31[1]+temp31 else all31[1]; def all30= if dp3 then all30[1]+temp30 else all30[1]; def all21= if dp2 then all21[1]+temp21 else all21[1]; def all20= if dp2 then all20[1]+temp20 else all20[1]; def all11= if dp1 then all11[1]+temp11 else all11[1]; def all10= if dp1 then all10[1]+temp10 else all10[1]; def rall41= if dp4 then rall41[1]+rel41 else rall41[1]; def rall40= if dp4 then rall40[1]+rel40 else rall40[1]; def rall31= if dp3 then rall31[1]+rel31 else rall31[1]; def rall30= if dp3 then rall30[1]+rel30 else rall30[1]; def rall21= if dp2 then rall21[1]+rel21 else rall21[1]; def rall20= if dp2 then rall20[1]+rel20 else rall20[1]; def rall11= if dp1 then rall11[1]+rel11 else rall11[1]; def rall10= if dp1 then rall10[1]+rel10 else rall10[1]; def tot41 = if isNaN(close[-1]) or isNan(all41[-1]) then all41 else Double.NaN; def tot40 = if isNaN(close[-1]) or isNan(all40[-1]) then all40 else Double.NaN; def tot31 = if isNaN(close[-1]) or isNan(all31[-1]) then all31 else Double.NaN; def tot30 = if isNaN(close[-1]) or isNan(all30[-1]) then all30 else Double.NaN; def tot21 = if isNaN(close[-1]) or isNan(all21[-1]) then all21 else Double.NaN; def tot20 = if isNaN(close[-1]) or isNan(all20[-1]) then all20 else Double.NaN; def tot11 = if isNaN(close[-1]) or isNan(all11[-1]) then all11 else Double.NaN; def tot10 = if isNaN(close[-1]) or isNan(all10[-1]) then all10 else Double.NaN; def rtot41 = if isNaN(close[-1]) or isNan(rall41[-1]) then rall41 else Double.NaN; def rtot40 = if isNaN(close[-1]) or isNan(rall40[-1]) then rall40 else Double.NaN; def rtot31 = if isNaN(close[-1]) or isNan(rall31[-1]) then rall31 else Double.NaN; def rtot30 = if isNaN(close[-1]) or isNan(rall30[-1]) then rall30 else Double.NaN; def rtot21 = if isNaN(close[-1]) or isNan(rall21[-1]) then rall21 else Double.NaN; def rtot20 = if isNaN(close[-1]) or isNan(rall20[-1]) then rall20 else Double.NaN; def rtot11 = if isNaN(close[-1]) or isNan(rall11[-1]) then rall11 else Double.NaN; def rtot10 = if isNaN(close[-1]) or isNan(rall10[-1]) then rall10 else Double.NaN; def spacing=pricechg/45; def toggle=trades % 2 == 1; def highest_bubble = highprice-(spacing*headroom); AddChartBubble(dp4 and verbose>1, highest_bubble-(spacing*0), "(4,1)="+ temp41, if temp41 < 0 then Color.RED else color.green); AddChartBubble(dp4 and verbose>1, highest_bubble-(spacing*1), "(4,0)="+ temp40, if temp40 < 0 then Color.RED else color.green); AddChartBubble(dp3 and verbose>1, highest_bubble-(spacing*2), "(3,1)="+ temp31, if temp31 < 0 then Color.RED else color.green); AddChartBubble(dp3 and verbose>1, highest_bubble-(spacing*3), "(3,0)="+ temp30, if temp30 < 0 then Color.RED else color.green); AddChartBubble(dp2 and verbose>1, highest_bubble-(spacing*4), "(2,1)="+ temp21, if temp21 < 0 then Color.RED else color.green); AddChartBubble(dp2 and verbose>1, highest_bubble-(spacing*5), "(2,0)="+ temp20, if temp20 < 0 then Color.RED else color.green); AddChartBubble(dp1 and verbose>1, highest_bubble-(spacing*6), "(1,1)="+ temp11, if temp11 < 0 then Color.RED else color.green); AddChartBubble(dp1 and verbose>1, highest_bubble-(spacing*7), "(1,0)="+ temp10, if temp10 < 0 then Color.RED else color.green); #AddChartBubble(dp1 and verbose>1 and toggle==0, highest_bubble-(spacing*9), "C - O[-1]-div= " + temp+";("+close+" - "+open[-1]+" - "+dividend[-1]+")" , if temp < 0 then Color.RED else color.yellow); AddChartBubble(dp1 and verbose>1 and toggle==0, highest_bubble-(spacing*9), "C - O[-1]-div= " + temp, if temp < 0 then Color.RED else color.yellow); AddChartBubble(dp1 and verbose>1 and toggle==1, highest_bubble-(spacing*10), "C - O[-1]-div= " + temp, if temp < 0 then Color.RED else color.yellow); AddChartBubble(d and verbose>1 and toggle==0, highest_bubble-(spacing*11), "div="+ dividend, color.dark_orange); AddChartBubble(d and verbose>1 and toggle==1, highest_bubble-(spacing*12), "div="+ dividend, color.dark_orange); AddChartBubble((barnumber()==3) and verbose>1, highest_bubble-(spacing*0), "(4,1) sum ="+ highestall(tot41)+" Avg="+highestall(tot41)/highestall(trades)+" "+highestall(rtot41)*100/highestall(trades)+"%", if highestall(tot41) < 0 then Color.RED else color.green); AddChartBubble((barnumber()==3) and verbose>1, highest_bubble-(spacing*1), "(4,0) sum ="+ highestall(tot40)+" Avg="+highestall(tot40)/highestall(trades)+" "+highestall(rtot40)*100/highestall(trades)+"%", if highestall(tot40) < 0 then Color.RED else color.green); AddChartBubble((barnumber()==3) and verbose>1, highest_bubble-(spacing*2), "(3,1) sum ="+ highestall(tot31)+" Avg="+highestall(tot31)/highestall(trades)+" "+highestall(rtot31)*100/highestall(trades)+"%", if highestall(tot31) < 0 then Color.RED else color.green); AddChartBubble((barnumber()==3) and verbose>1, highest_bubble-(spacing*3), "(3,0) sum ="+ highestall(tot30)+" Avg="+highestall(tot30)/highestall(trades)+" "+highestall(rtot30)*100/highestall(trades)+"%", if highestall(tot30) < 0 then Color.RED else color.green); AddChartBubble((barnumber()==3) and verbose>1, highest_bubble-(spacing*4), "(2,1) sum ="+ highestall(tot21)+" Avg="+highestall(tot21)/highestall(trades)+" "+highestall(rtot21)*100/highestall(trades)+"%", if highestall(tot21) < 0 then Color.RED else color.green); AddChartBubble((barnumber()==3) and verbose>1, highest_bubble-(spacing*5), "(2,0) sum ="+ highestall(tot20)+" Avg="+highestall(tot20)/highestall(trades)+" "+highestall(rtot20)*100/highestall(trades)+"%", if highestall(tot20) < 0 then Color.RED else color.green); AddChartBubble((barnumber()==3) and verbose>1, highest_bubble-(spacing*6), "(1,1) sum ="+ highestall(tot11)+" Avg="+highestall(tot11)/highestall(trades)+" "+highestall(rtot11)*100/highestall(trades)+"%", if highestall(tot11) < 0 then Color.RED else color.green); AddChartBubble((barnumber()==3) and verbose>1, highest_bubble-(spacing*7), "(1,0) sum ="+ highestall(tot10)+" Avg="+highestall(tot10)/highestall(trades)+" "+highestall(rtot10)*100/highestall(trades)+"%", if highestall(tot10) < 0 then Color.RED else color.green); #plot tot41P=tot41; #plot dp4P=dp4; #plot all41P=all41;
I used the TOS SCAN, to find upcoming dividend plays, and sorted in profitability order. -- This scan (grading in the SCAN) was complicated, so you may prefer a manual process. --- many more scripts required and was difficult to manage.
Another twist: (This has not been vetted, so consider with doubt). If the underlying is trending down already, it "could" be possible the value of the underlying is being held up only by some waiting for the Dividend, then plan to dump. If so, NAT could also be interesting! (Ie.. something like BUY 17MAR $8 strike PUT. SELL the PUT back Thur. -- very short term trade)
This might be the case with XOM, it has been in a downtrend. Thanks for your work, although all those coding is above my paygrade. Again, I am looking for stocks with close to 1% dividend and a good option chain, possibly strikes for each dollar.
Pekelo: Ah! If you would like to observe how the script works without having to "mess with it", here is a link: "http://tos.mx/mNoH9C" To use this in TOS, the easiest mechanism is to Click Setup: Open shared item ... And paste that link as follows: In the Shared item URL: Then "Open". Then: Select which ever underlying you want! Results should look like this:
For best results, set the Time frame to 2 years or greater to insure you evaluate multiples of 1 year periods.
OK I have 2 candidates with upcoming dividends: 1. BP paying 60 cents on Feb 13th after the close. Right now BP at $34.5 I would sell the 17 Febr 34.5/35 spread for 19 cents and I am betting that in 4 days it won't recover the drop. 2. GSK paying 57 cents on Febr 21st after the close. I would sell the 24 Febr 40/40.5 call spread for 22 cents that expiring 3 days after the dividend pay. Right now GSK is at 40, so assuming the price is the same just before the drop, I am betting that it won't recover 57 cents in 3 days. Of course the underlying could move way up before the dividend day....
Just a suggestion, but instead of thinking "I am betting that it won't recover 57 cents in 3 days." you might want to think "I am betting that it won't recover 1.425% in 3 days.", and then look at how often it's realized that volatility in the past X weeks. It's a subtle shift in the way you think, but I find it changes my "gut feel" quite a bit when I put it like that, and often provides a bit of a reality check.
In the BP spread you might be assigned before dividend. If the stock goes up about 15 cents I think you will be. So then you will lose a bit more deltas and be more short then you would think. On the other hand, you're getting a little bit extra premium on that 34.50 call. If it isn't exercised before dividend that 34.50 call will lose value more quickly. It's about 7 cents priced higher than it would be. You would have the same issue in GSK. So you might lose more on a recovery than you would think, because you might end up being short the stock at 34.50 for BP and 40 for GSK (minus some premium).