Repaints AGAIG ZigZag Lower Verticals For ThinkOrSwim

Repaints

csricksdds

Trader Educator
VIP
Several have asked if there is a way to make the vertical line edition of this indicator thicker, but of course there is not. I would like them thicker as well. In addition to using my upper vertical lines I made a lower Histogram to more easily catch the eye. Even though this indicator will repaint it has been the most accurate indicator I use. I typically day trade the SPY and/or QQQs on a 5 min. Daily Chart, although this is AsGoodAsItGets on most stocks or ETFs you trade.
yrLt6k0.png


Here is the code:
Ruby:
# AsGoodAsItGets Lower Indicator
#CSR Buy/Sell Arrows with Short/Long Bubbles
#Developed 4-23-23 First Edition 8-23-22 Revised
#Updated 3/16/24 by C. Ricks

declare lower;

input atrreversal = 2.0;

def priceh = MovingAverage(AverageType.EXPONENTIAL, high, 5);
def pricel = MovingAverage(AverageType.EXPONENTIAL, low, 5);

def EIL = ZigZagHighLow("price h" = priceh, "price l" = pricel, "percentage reversal" = .01, "absolute reversal" = .05, "atr length" = 5, "atr reversal" = atrreversal).lastL;
def EIH = ZigZagHighLow("price h" = priceh, "price l" = pricel, "percentage reversal" = .01, "absolute reversal" = .05, "atr length" = 5, "atr reversal" = atrreversal).lastH;

plot signaldown = !isNAN(EIH);
signaldown.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
signaldown.DefineColor("signaldown", Color.Red);
AddVerticalLine(!isNAN(EIH),"SHORT", color.red,curve.long_dash);

plot signalrevBot = !isNaN(EIL);

Signalrevbot.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
signalrevBot.DefineColor("signalrevBot", Color.GREEN);
AddVerticalLine(!isNAN(EIL),"LONG", color.Green,curve.long_dash);

##End Code
 
Last edited by a moderator:

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

Looks amazing for options trading.

.

I made substantial improvements!!!!!!!!!!

I added labels that tell you how many shares you can purchase with your budget at the plot lines.

I added Long & Short profit labels that tell you how much money you'll make if you buy with your budget at the bullish plot line, and how much money you would have made by shorting with your budget on the bearish plot line.


I also made the plot lines say what price they're at.

http://tos.mx/!Mho7uhTb

Code:
# AsGoodAsItGets Lower Indicator
# CSR Buy/Sell Arrows with Short/Long Bubbles
# Developed 4-23-23 First Edition 8-23-22 Revised
# Updated 3/16/24 by C. Ricks
# Enhanced to continuously display profit labels for both buy and sell signals
# and to show companion labels for the starting prices of shorting and longing

declare lower;

input atrreversal = 2.0;
input sharePurchaseBudget = 5000; # Adjusted your budget to $5000
input showProfitLabels = yes; # Toggle the display of profit labels

def priceh = MovingAverage(AverageType.EXPONENTIAL, high, 5);
def pricel = MovingAverage(AverageType.EXPONENTIAL, low, 5);

def EIL = ZigZagHighLow("price h" = priceh, "price l" = pricel, "percentage reversal" = .01, "absolute reversal" = .05, "atr length" = 5, "atr reversal" = atrreversal).lastL;
def EIH = ZigZagHighLow("price h" = priceh, "price l" = pricel, "percentage reversal" = .01, "absolute reversal" = .05, "atr length" = 5, "atr reversal" = atrreversal).lastH;

plot signaldown = !isNAN(EIH);
signaldown.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
signaldown.SetDefaultColor(Color.white);
AddVerticalLine(!isNAN(EIH),"SHORT @ " + AsDollars(priceh), Color.white, Curve.firm);
AddLabel(!isNAN(EIH) and showProfitLabels, "SHORT Signal Price: " + AsDollars(priceh), Color.WHITE);

plot signalrevBot = !isNaN(EIL);
signalrevBot.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
signalrevBot.SetDefaultColor(Color.cyan);
AddVerticalLine(!isNAN(EIL),"LONG @ " + AsDollars(pricel), Color.cyan, Curve.FIRM);
AddLabel(!isNAN(EIL) and showProfitLabels, "LONG Signal Price: " + AsDollars(pricel), Color.CYAN);

# Detect signal appearances to control profit calculations
def newBuySignal = Crosses(!IsNaN(EIL), 0.5, CrossingDirection.ABOVE);
def newSellSignal = Crosses(!IsNaN(EIH), 0.5, CrossingDirection.ABOVE);

def lastBuyPrice = if newBuySignal then pricel else lastBuyPrice[1];
def lastSellPrice = if newSellSignal then priceh else lastSellPrice[1];
def lastCoverPrice = if newBuySignal then pricel else lastCoverPrice[1];

# Calculate potential profits and update continuously
def sharesToShort = Round(sharePurchaseBudget / lastSellPrice);
def sharesToBuy = Round(sharePurchaseBudget / lastBuyPrice);

# Correcting the short profit calculation based on new entry and exit points
def shortEntryPrice = if newSellSignal then lastSellPrice else shortEntryPrice[1];
def shortExitPrice = if newBuySignal then lastCoverPrice else shortExitPrice[1];
def shortProfit = (shortEntryPrice - shortExitPrice) * sharesToShort;
def updatedShortProfit = if newBuySignal then shortProfit else updatedShortProfit[1]; # Update profit only on exit signal

# Adding Long Entry and Exit Prices, and Long Profit Calculation
def longEntryPrice = lastBuyPrice;
def longExitPrice = if newSellSignal then lastSellPrice else longExitPrice[1];
def longProfit = (longExitPrice - longEntryPrice) * sharesToBuy;
def updatedLongProfit = if newSellSignal then longProfit else updatedLongProfit[1]; # Update profit only on exit signal

# Corrected Short Profit display based on entry at signaldown and exit at signalrevBot
AddLabel(showProfitLabels, "Short Entry Price: " + AsDollars(shortEntryPrice) + ", Exit Price: " + AsDollars(shortExitPrice), Color.WHITE);
AddLabel(yes, "Shares to short @ GO-Short plot: " + sharesToShort + " shares", Color.WHITE);
AddLabel(showProfitLabels, "Short - Profit: " + AsDollars(updatedShortProfit), if updatedShortProfit > 0 then Color.white else Color.RED);

# Adding Labels for Long Position
AddLabel(showProfitLabels, "Long Entry Price: " + AsDollars(longEntryPrice) + ", Exit Price: " + AsDollars(longExitPrice), Color.CYAN);
AddLabel(yes, "Shares to Buy @ Go-Long plot: " + sharesToBuy + " shares", Color.CYAN);
AddLabel(showProfitLabels, "Long - Profit: " + AsDollars(updatedLongProfit), if updatedLongProfit > 0 then Color.CYAN else Color.RED);
 

Attachments

  • fcvdfdfsd.png
    fcvdfdfsd.png
    110.8 KB · Views: 49
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
352 Online
Create Post

Similar threads

Similar threads

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