ChatGPT, BARD, Other AI Scripts Which Can't Be Used In ThinkOrSwim

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
90% of the members attempting chatGPT scripting; do not provide good detailed specifications.

Members know what end result that they want but lack the ability to tell chatGPT, the step-by-step logic required to code a script to achieve that end result.
This results in chatGPT providing poor code.

Here is a video on how to successfully have chatGPT create functional scripts.

The above video, explains the basics of providing good specifications to AI which results in better scripts.
AOzhl05.png
 
Last edited:
Lines at the last 3 highest volume vwap level within the last 52 weeks.
This is what i got from ChatGPT. Price is shown but no line is drawn on the chart. This is for just one line for the last highest vwap level.. I need it to draw 3 lines for the last 3 highest vwap level, add a number on each line in ascending order. Thank you for any help.



input lookbackPeriod = 52; # Lookback period in weeks

# Calculate the number of bars in the lookback period
def barsInPeriod = lookbackPeriod * 5;

# Find the highest volume day within the lookback period
def highestVolumeDay = Highest(volume, barsInPeriod);

# Calculate VWAP for the highest volume day
def vwapHighestVolumeDay = if volume == highestVolumeDay then reference VWAP() else Double.NaN;

# Plot horizontal line at the VWAP level of the highest volume day
plot VWAPLine = if !IsNaN(vwapHighestVolumeDay) then vwapHighestVolumeDay else Double.NaN;
VWAPLine.SetDefaultColor(Color.BLUE);
VWAPLine.SetLineWeight(1);
 
Please help me find the error in this code. Thank you.
Goal of the code is to Scan for a Moving Average crossing above another moving average AFTER A SPECIFIED NUMBER OF DAYS (BARS)

# User inputs
input fastLength = 8;
input slowLength = 20;
input crossPeriod = 20;

# Calculate moving averages
def fastEMA = ExpAverage(close, fastLength);
def slowEMA = ExpAverage(close, slowLength);

# Check for crossover and if fastEMA has been below slowEMA for at least 5 days
def belowSlowEMA = fastEMA < slowEMA;
def belowSlowEMAPeriod = Sum(belowSlowEMA, crossPeriod) == crossPeriod;
def cross = if (fastEMA > slowEMA and belowSlowEMAPeriod) then 1 else 0;

# Plot the crossover signal
plot scanSignal = cross;

reply to #240
the cross = line is wrong,
it should be looking at the previous value of belowSlowEMAPeriod, not the current value.
i added an offset to read a value from 1 bar ago.

replace your code line with this one,
def cross = if (fastEMA > slowEMA and belowSlowEMAPeriod[1] ) then 1 else 0;
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
244 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