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:
Please fix these scripts for divergence detection. Thanks.

Code:
declare lower;

input prd = 5;
input source = close;
input searchdiv = "Regular";
input showindis = "Full";
input showlimit = 1;
input maxpp = 10;
input maxbars = 100;
input shownum = yes;
input showlast = no;
input dontconfirm = no;
input showlines = yes;
input showpivot = no;
input calcmacd = yes;
input calcmacda = yes;
input calcrsi = yes;
input calcstoc = yes;
input calccci = yes;
input calcmom = yes;
input calcobv = yes;
input calcvwmacd = yes;
input calccmf = yes;
input calcmfi = yes;
input calcext = no;
input externalindi = close;

# Define color constants
DefineGlobalColor("PositiveRegDiv", CreateColor(255, 255, 0)); # Yellow
DefineGlobalColor("NegativeRegDiv", CreateColor(0, 0, 255)); # Blue
DefineGlobalColor("PositiveHidDiv", CreateColor(0, 255, 0)); # Green
DefineGlobalColor("NegativeHidDiv", CreateColor(255, 0, 0)); # Red
DefineGlobalColor("PosDivText", CreateColor(0, 0, 0)); # Black
DefineGlobalColor("NegDivText", CreateColor(255, 255, 255)); # White

input reg_div_l_style_ = Curve.MEDIUM_DASH;
input hid_div_l_style_ = Curve.SHORT_DASH;
input reg_div_l_width = 2;
input hid_div_l_width = 1;
input showmas = no;

# Moving Averages
def cma1col = Color.GREEN;
def cma2col = Color.RED;

# Moving Averages
plot ma50 = if showmas then Average(close, 50) else Double.NaN;
ma50.SetDefaultColor(cma1col);

plot ma200 = if showmas then Average(close, 200) else Double.NaN;
ma200.SetDefaultColor(cma2col);

# RSI
def rsiValue = if calcrsi then RSI(close, 14) else Double.NaN;

# MACD
def macd = if calcmacd then MACD(close, 12, 26, 9) else Double.NaN;
def macdValue = if calcmacd then macd[1] - macd[2] else Double.NaN;

# Momentum
def moment = if calcmom then Momentum(close, 10) else Double.NaN;

# CCI
def cciValue = if calccci then CCI(close, 10) else Double.NaN;

# OBV
def obvValue = if calcobv then TotalSum(if close > close[1] then volume else if close < close[1] then -volume else 0) else Double.NaN;

# Stochastic
def stkValue = if calcstoc then StochasticSlow(14, 3) else Double.NaN;

# VW MACD
def vwmacd = if calcvwmacd then MovingAverage(AverageType.WILDERS, close, 12) - MovingAverage(AverageType.WILDERS, close, 26) else Double.NaN;

# Chaikin Money Flow
def cmf = if calccmf then ChaikinMoneyFlow(21) else Double.NaN;

# Money Flow Index
def mfi = if calcmfi then MoneyFlowIndex(close, 14) else Double.NaN;

# Pivot Points
def ph = if source == close then high else low;
def pl = if source == close then low else high;

def phValue = if high == Highest(high, prd) then high else Double.NaN;
def plValue = if low == Lowest(low, prd) then low else Double.NaN;

def phPosition = if !IsNaN(phValue) then BarNumber() else Double.NaN;
def plPosition = if !IsNaN(plValue) then BarNumber() else Double.NaN;

# Divergence Detection
def positiveRegular = if !IsNaN(phPosition) then
    (if macdValue > Highest(macdValue[prd], prd) and low < Lowest(low[prd], prd) then 1 else 0)
else 0;

def negativeRegular = if !IsNaN(plPosition) then
    (if macdValue < Lowest(macdValue[prd], prd) and high > Highest(high[prd], prd) then 1 else 0)
else 0;

def positiveHidden = if !IsNaN(phPosition) then
    (if macdValue < Lowest(macdValue[prd], prd) and low > Lowest(low[prd], prd) then 1 else 0)
else 0;

def negativeHidden = if !IsNaN(plPosition) then
    (if macdValue > Highest(macdValue[prd], prd) and high < Highest(high[prd], prd) then 1 else 0)
else 0;

plot PositiveRegularDivergence = positiveRegular;
PositiveRegularDivergence.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
PositiveRegularDivergence.SetDefaultColor(GlobalColor("PositiveRegDiv"));

plot NegativeRegularDivergence = negativeRegular;
NegativeRegularDivergence.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
NegativeRegularDivergence.SetDefaultColor(GlobalColor("NegativeRegDiv"));

plot PositiveHiddenDivergence = positiveHidden;
PositiveHiddenDivergence.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
PositiveHiddenDivergence.SetDefaultColor(GlobalColor("PositiveHidDiv"));

plot NegativeHiddenDivergence = negativeHidden;
NegativeHiddenDivergence.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
NegativeHiddenDivergence.SetDefaultColor(GlobalColor("NegativeHidDiv"));

reply to 261


next time look up the functions and see what are valid input parameters.

can't set a variable equal to a color.
def cma1col = Color.GREEN;
just put the color in the plot code line
https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/SetDefaultColor


input parameters for RSI() are in wrong order. length is 1st. price is 4th.
use the parameter names then put in any order
def rsiValue = if calcrsi then RSI(close, 14) else Double.NaN;
fixed
def rsiValue = if calcrsi then RSI(length = 14, price = close) else Double.NaN;
https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/R-S/RSI


input parameters for RSI() are wrong. no price input for macd.
def macd = if calcmacd then MACD(close, 12, 26, 9) else Double.NaN;
fixed
def macd = if calcmacd then MACD(12, 26, 9) else Double.NaN;
https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/M-N/MACD


input parameters for RSI() are in wrong order.
def moment = if calcmom then Momentum(close, 10) else Double.NaN;
fixed
def moment = if calcmom then Momentum(10,close) else Double.NaN;
https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/M-N/Momentum


input parameters for RSI() are in wrong order.
def cciValue = if calccci then CCI(close, 10) else Double.NaN;
fixed
def cciValue = if calccci then CCI(10,close) else Double.NaN;
https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/C-D/CCI


you are trying to plot booleans in a lower chart. that doesn't work as expected. it will plot them at price levels. might as well plot on the upper chart.


Code:
#chat261_fix_diverg

#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-14#post-143210
#James Chen
#261
#Please fix these scripts for divergence detection. Thanks.


#declare lower;

input prd = 5;
input source = close;
input searchdiv = "Regular";
input showindis = "Full";
input showlimit = 1;
input maxpp = 10;
input maxbars = 100;
input shownum = yes;
input showlast = no;
input dontconfirm = no;
input showlines = yes;
input showpivot = no;
input calcmacd = yes;
input calcmacda = yes;
input calcrsi = yes;
input calcstoc = yes;
input calccci = yes;
input calcmom = yes;
input calcobv = yes;
input calcvwmacd = yes;
input calccmf = yes;
input calcmfi = yes;
input calcext = no;
input externalindi = close;

# Define color constants
DefineGlobalColor("PositiveRegDiv", CreateColor(255, 255, 0)); # Yellow
DefineGlobalColor("NegativeRegDiv", CreateColor(0, 0, 255)); # Blue
DefineGlobalColor("PositiveHidDiv", CreateColor(0, 255, 0)); # Green
DefineGlobalColor("NegativeHidDiv", CreateColor(255, 0, 0)); # Red
DefineGlobalColor("PosDivText", CreateColor(0, 0, 0)); # Black
DefineGlobalColor("NegDivText", CreateColor(255, 255, 255)); # White

input reg_div_l_style_ = Curve.MEDIUM_DASH;
input hid_div_l_style_ = Curve.SHORT_DASH;
input reg_div_l_width = 2;
input hid_div_l_width = 1;
input showmas = no;

# Moving Averages
#def cma1col = Color.GREEN;
#def cma2col = Color.RED;

# Moving Averages
plot ma50 = if showmas then Average(close, 50) else Double.NaN;
#ma50.SetDefaultColor(cma1col);
ma50.SetDefaultColor(Color.GREEN);

plot ma200 = if showmas then Average(close, 200) else Double.NaN;
#ma200.SetDefaultColor(cma2col);
ma200.SetDefaultColor(Color.RED);


# RSI
#def rsiValue = if calcrsi then RSI(close, 14) else Double.NaN;
def rsiValue = if calcrsi then RSI(length = 14, price = close) else Double.NaN;


# MACD
#def macd = if calcmacd then MACD(close, 12, 26, 9) else Double.NaN;
def macd = if calcmacd then MACD(12, 26, 9) else Double.NaN;
def macdValue = if calcmacd then macd[1] - macd[2] else Double.NaN;

# Momentum
#def moment = if calcmom then Momentum(close, 10) else Double.NaN;
def moment = if calcmom then Momentum(10,close) else Double.NaN;

# CCI
#def cciValue = if calccci then CCI(close, 10) else Double.NaN;
def cciValue = if calccci then CCI(10,close) else Double.NaN;

# OBV
def obvValue = if calcobv then TotalSum(if close > close[1] then volume else if close < close[1] then -volume else 0) else Double.NaN;

# Stochastic
def stkValue = if calcstoc then StochasticSlow(14, 3) else Double.NaN;

# VW MACD
def vwmacd = if calcvwmacd then MovingAverage(AverageType.WILDERS, close, 12) - MovingAverage(AverageType.WILDERS, close, 26) else Double.NaN;

# Chaikin Money Flow
def cmf = if calccmf then ChaikinMoneyFlow(21) else Double.NaN;

# Money Flow Index
def mfi = if calcmfi then MoneyFlowIndex(close, 14) else Double.NaN;

# Pivot Points
def ph = if source == close then high else low;
def pl = if source == close then low else high;

def phValue = if high == Highest(high, prd) then high else Double.NaN;
def plValue = if low == Lowest(low, prd) then low else Double.NaN;

def phPosition = if !IsNaN(phValue) then BarNumber() else Double.NaN;
def plPosition = if !IsNaN(plValue) then BarNumber() else Double.NaN;

# Divergence Detection
def positiveRegular = if !IsNaN(phPosition) then
    (if macdValue > Highest(macdValue[prd], prd) and low < Lowest(low[prd], prd) then 1 else 0)
else 0;

def negativeRegular = if !IsNaN(plPosition) then
    (if macdValue < Lowest(macdValue[prd], prd) and high > Highest(high[prd], prd) then 1 else 0)
else 0;

def positiveHidden = if !IsNaN(phPosition) then
    (if macdValue < Lowest(macdValue[prd], prd) and low > Lowest(low[prd], prd) then 1 else 0)
else 0;

def negativeHidden = if !IsNaN(plPosition) then
    (if macdValue > Highest(macdValue[prd], prd) and high < Highest(high[prd], prd) then 1 else 0)
else 0;

plot PositiveRegularDivergence = positiveRegular;
PositiveRegularDivergence.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
PositiveRegularDivergence.SetDefaultColor(GlobalColor("PositiveRegDiv"));

plot NegativeRegularDivergence = negativeRegular;
NegativeRegularDivergence.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
NegativeRegularDivergence.SetDefaultColor(GlobalColor("NegativeRegDiv"));

plot PositiveHiddenDivergence = positiveHidden;
PositiveHiddenDivergence.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
PositiveHiddenDivergence.SetDefaultColor(GlobalColor("PositiveHidDiv"));

plot NegativeHiddenDivergence = negativeHidden;
NegativeHiddenDivergence.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
NegativeHiddenDivergence.SetDefaultColor(GlobalColor("NegativeHidDiv"));
#
 
I'm trying to create an indicator that would highlight the slope of VWAP. When descending, the VWAP would be colored red, and the ascending VWAP would be colored green. Also, as the slope of the VWAP increased, the line would intensify in color, and thicken.

I'm not a coder, I've tried to put a script together using Chat GPT but cannot resolve these errors:

Cannot access dynamic value for initialization of 'setdefaultcolor'
Cannot access dynamic value for initialization of 'setlineweight'

Here's what I've got so far:

# VWAP with Colored Slope Intensity and Variable Line Thickness

# Calculate VWAP
def vwapValue = reference VWAP();

# Calculate the slope of VWAP
def slopeVWAP = vwapValue - vwapValue[1];

# Calculate the angle of the slope in degrees
def angle = ATAN(slopeVWAP) * 180 / Double.Pi;

# Define the line thickness based on the steepness of the slope
def lineWeight = if AbsValue(angle) >= 40 then 5 else if AbsValue(angle) >= 30 then 4 else if AbsValue(angle) >= 20 then 3 else if AbsValue(angle) >= 10 then 2 else 1;

# Plot VWAP with conditional coloring and variable line thickness
plot VWAPPlot = vwapValue;
VWAPPlot.SetDefaultColor(if angle > 0 then Color.DARK_GREEN else if angle < 0 then Color.DARK_RED else Color.WHITE); # Set color based on slope
VWAPPlot.SetLineWeight(lineWeight); # Set line weight based on slope

# Ensure the study is plotted on the price chart (upper study)
AddLabel(yes, "VWAP", Color.WHITE);
 
There are two versions of PIVOT POINTS I tried to create for TOS (with my limited ability) but they're not working as they should. If anyone can help fix.

Version 1:

Code:
# Define inputs
input pivot_time_frame = {default "AUTO", "DAILY", "WEEKLY", "MONTHLY", "QUARTERLY", "YEARLY", "BIYEARLY", "TRIYEARLY", "QUINQUENNIALLY", "DECENNIALLY"};
input look_back = 1;
input is_daily_based = yes;
input show_labels = yes;
input show_prices = yes;
input position_labels = {default "Left", "Right"};
input line_width = 1;

# Define variables
def na = Double.NaN;
def resolution;

switch (pivot_time_frame) {
case "AUTO":
    if (GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN) {
        resolution = AggregationPeriod.DAY;
    } else {
        resolution = AggregationPeriod.WEEK;
    }
case "DAILY":
    resolution = AggregationPeriod.DAY;
case "WEEKLY":
    resolution = AggregationPeriod.WEEK;
case "MONTHLY":
    resolution = AggregationPeriod.MONTH;
case "QUARTERLY":
    resolution = AggregationPeriod.QUARTER;
case "YEARLY":
    resolution = AggregationPeriod.YEAR;
case "BIYEARLY":
    resolution = AggregationPeriod.YEAR * 2;
case "TRIYEARLY":
    resolution = AggregationPeriod.YEAR * 3;
case "QUINQUENNIALLY":
    resolution = AggregationPeriod.YEAR * 5;
case "DECENNIALLY":
    resolution = AggregationPeriod.YEAR * 10;
}

# Helper functions
script calc_pivot {
    input kind = {"TRADITIONAL", default "WOODIE"};
    input prev_high = close;
    input prev_low = close;
    input prev_close = close;
    def pivot_;
    def r1_;
    def s1_;
    def r2_;
    def s2_;
    def r3_;
    def s3_;
    def na = Double.NaN;

    if (kind == kind.TRADITIONAL) {
        pivot_ = (prev_high + prev_low + prev_close) / 3;
        r1_ = pivot_ * 2 - prev_low;
        s1_ = pivot_ * 2 - prev_high;
        r2_ = pivot_ + (prev_high - prev_low);
        s2_ = pivot_ - (prev_high - prev_low);
        r3_ = pivot_ * 2 + (prev_high - 2 * prev_low);
        s3_ = pivot_ * 2 - (2 * prev_high - prev_low);
    } else {
        pivot_ = na;
        r1_ = na;
        s1_ = na;
        r2_ = na;
        s2_ = na;
        r3_ = na;
        s3_ = na;
    }

    plot pivot_line = pivot_;
    plot r1_line = r1_;
    plot s1_line = s1_;
    plot r2_line = r2_;
    plot s2_line = s2_;
    plot r3_line = r3_;
    plot s3_line = s3_;
}

# Custom session start and end times
def sessionStart = 1800; # 6:00 PM
def sessionEnd = 1700; # 5:00 PM

# Adjust the session to span from 6:00 PM to 5:00 PM
def isInSession = SecondsFromTime(sessionStart) >= 0 or SecondsTillTime(sessionEnd) >= 0;
def newDay = GetDay() != GetDay()[1];
def prevHigh = if (newDay and isInSession) then high else if (isInSession) then Max(high, prevHigh[1]) else prevHigh[1];
def prevLow = if (newDay and isInSession) then low else if (isInSession) then Min(low, prevLow[1]) else prevLow[1];
def prevClose = if (newDay and isInSession) then close else prevClose[1];

# Ensure we only use the values from the correct session
def prevHighFiltered = if (SecondsFromTime(sessionStart) == 0) then prevHigh[1] else prevHigh;
def prevLowFiltered = if (SecondsFromTime(sessionStart) == 0) then prevLow[1] else prevLow;
def prevCloseFiltered = if (SecondsFromTime(sessionStart) == 0) then prevClose[1] else prevClose;

# Calculate pivot points using the filtered high, low, and close
def pivot_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).pivot_line;
def r1_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).r1_line;
def s1_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).s1_line;
def r2_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).r2_line;
def s2_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).s2_line;
def r3_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).r3_line;
def s3_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).s3_line;

# Plot lines
plot Pivot = pivot_;
Pivot.SetDefaultColor(Color.ORANGE);
Pivot.SetLineWeight(line_width);

plot R1 = r1_;
R1.SetDefaultColor(Color.ORANGE);
R1.SetLineWeight(line_width);

plot S1 = s1_;
S1.SetDefaultColor(Color.ORANGE);
S1.SetLineWeight(line_width);

plot R2 = r2_;
R2.SetDefaultColor(Color.ORANGE);
R2.SetLineWeight(line_width);

plot S2 = s2_;
S2.SetDefaultColor(Color.ORANGE);
S2.SetLineWeight(line_width);

plot R3 = r3_;
R3.SetDefaultColor(Color.ORANGE);
R3.SetLineWeight(line_width);

plot S3 = s3_;
S3.SetDefaultColor(Color.ORANGE);
S3.SetLineWeight(line_width);

Version 2:

Code:
# Define inputs
input pivot_time_frame = {default "AUTO", "DAILY", "WEEKLY", "MONTHLY", "QUARTERLY", "YEARLY", "BIYEARLY", "TRIYEARLY", "QUINQUENNIALLY", "DECENNIALLY"};
input look_back = 1;
input is_daily_based = yes;
input show_labels = yes;
input show_prices = yes;
input position_labels = {default "Left", "Right"};
input line_width = 1;

# Define variables
def na = Double.NaN;
def resolution;

switch (pivot_time_frame) {
case "AUTO":
    if (GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN) {
        resolution = AggregationPeriod.DAY;
    } else {
        resolution = AggregationPeriod.WEEK;
    }
case "DAILY":
    resolution = AggregationPeriod.DAY;
case "WEEKLY":
    resolution = AggregationPeriod.WEEK;
case "MONTHLY":
    resolution = AggregationPeriod.MONTH;
case "QUARTERLY":
    resolution = AggregationPeriod.QUARTER;
case "YEARLY":
    resolution = AggregationPeriod.YEAR;
case "BIYEARLY":
    resolution = AggregationPeriod.YEAR * 2;
case "TRIYEARLY":
    resolution = AggregationPeriod.YEAR * 3;
case "QUINQUENNIALLY":
    resolution = AggregationPeriod.YEAR * 5;
case "DECENNIALLY":
    resolution = AggregationPeriod.YEAR * 10;
}

# Helper functions
script calc_pivot {
    input kind = {"TRADITIONAL", default "WOODIE"};
    input prev_high = close;
    input prev_low = close;
    input prev_close = close;
    def pivot_;
    def r1_;
    def s1_;
    def r2_;
    def s2_;
    def r3_;
    def s3_;
    def na = Double.NaN;

    if (kind == kind.TRADITIONAL) {
        pivot_ = (prev_high + prev_low + prev_close) / 3;
        r1_ = pivot_ * 2 - prev_low;
        s1_ = pivot_ * 2 - prev_high;
        r2_ = pivot_ + (prev_high - prev_low);
        s2_ = pivot_ - (prev_high - prev_low);
        r3_ = pivot_ * 2 + (prev_high - 2 * prev_low);
        s3_ = pivot_ * 2 - (2 * prev_high - prev_low);
    } else {
        pivot_ = na;
        r1_ = na;
        s1_ = na;
        r2_ = na;
        s2_ = na;
        r3_ = na;
        s3_ = na;
    }

    plot pivot_line = pivot_;
    plot r1_line = r1_;
    plot s1_line = s1_;
    plot r2_line = r2_;
    plot s2_line = s2_;
    plot r3_line = r3_;
    plot s3_line = s3_;
}

# Get data for calculations
def prev_high = high(period = resolution)[1];
def prev_low = low(period = resolution)[1];
def prev_close = close(period = resolution)[1];

def pivot_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).pivot_line;
def r1_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).r1_line;
def s1_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).s1_line;
def r2_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).r2_line;
def s2_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).s2_line;
def r3_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).r3_line;
def s3_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).s3_line;

# Plot lines
plot Pivot = pivot_;
Pivot.SetDefaultColor(Color.ORANGE);
Pivot.SetLineWeight(line_width);

plot R1 = r1_;
R1.SetDefaultColor(Color.ORANGE);
R1.SetLineWeight(line_width);

plot S1 = s1_;
S1.SetDefaultColor(Color.ORANGE);
S1.SetLineWeight(line_width);

plot R2 = r2_;
R2.SetDefaultColor(Color.ORANGE);
R2.SetLineWeight(line_width);

plot S2 = s2_;
S2.SetDefaultColor(Color.ORANGE);
S2.SetLineWeight(line_width);

plot R3 = r3_;
R3.SetDefaultColor(Color.ORANGE);
R3.SetLineWeight(line_width);

plot S3 = s3_;
S3.SetDefaultColor(Color.ORANGE);
S3.SetLineWeight(line_width);
 
There are two versions of PIVOT POINTS I tried to create for TOS (with my limited ability) but they're not working as they should. If anyone can help fix.

Version 1:

Code:
# Define inputs
input pivot_time_frame = {default "AUTO", "DAILY", "WEEKLY", "MONTHLY", "QUARTERLY", "YEARLY", "BIYEARLY", "TRIYEARLY", "QUINQUENNIALLY", "DECENNIALLY"};
input look_back = 1;
input is_daily_based = yes;
input show_labels = yes;
input show_prices = yes;
input position_labels = {default "Left", "Right"};
input line_width = 1;

# Define variables
def na = Double.NaN;
def resolution;

switch (pivot_time_frame) {
case "AUTO":
    if (GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN) {
        resolution = AggregationPeriod.DAY;
    } else {
        resolution = AggregationPeriod.WEEK;
    }
case "DAILY":
    resolution = AggregationPeriod.DAY;
case "WEEKLY":
    resolution = AggregationPeriod.WEEK;
case "MONTHLY":
    resolution = AggregationPeriod.MONTH;
case "QUARTERLY":
    resolution = AggregationPeriod.QUARTER;
case "YEARLY":
    resolution = AggregationPeriod.YEAR;
case "BIYEARLY":
    resolution = AggregationPeriod.YEAR * 2;
case "TRIYEARLY":
    resolution = AggregationPeriod.YEAR * 3;
case "QUINQUENNIALLY":
    resolution = AggregationPeriod.YEAR * 5;
case "DECENNIALLY":
    resolution = AggregationPeriod.YEAR * 10;
}

# Helper functions
script calc_pivot {
    input kind = {"TRADITIONAL", default "WOODIE"};
    input prev_high = close;
    input prev_low = close;
    input prev_close = close;
    def pivot_;
    def r1_;
    def s1_;
    def r2_;
    def s2_;
    def r3_;
    def s3_;
    def na = Double.NaN;

    if (kind == kind.TRADITIONAL) {
        pivot_ = (prev_high + prev_low + prev_close) / 3;
        r1_ = pivot_ * 2 - prev_low;
        s1_ = pivot_ * 2 - prev_high;
        r2_ = pivot_ + (prev_high - prev_low);
        s2_ = pivot_ - (prev_high - prev_low);
        r3_ = pivot_ * 2 + (prev_high - 2 * prev_low);
        s3_ = pivot_ * 2 - (2 * prev_high - prev_low);
    } else {
        pivot_ = na;
        r1_ = na;
        s1_ = na;
        r2_ = na;
        s2_ = na;
        r3_ = na;
        s3_ = na;
    }

    plot pivot_line = pivot_;
    plot r1_line = r1_;
    plot s1_line = s1_;
    plot r2_line = r2_;
    plot s2_line = s2_;
    plot r3_line = r3_;
    plot s3_line = s3_;
}

# Custom session start and end times
def sessionStart = 1800; # 6:00 PM
def sessionEnd = 1700; # 5:00 PM

# Adjust the session to span from 6:00 PM to 5:00 PM
def isInSession = SecondsFromTime(sessionStart) >= 0 or SecondsTillTime(sessionEnd) >= 0;
def newDay = GetDay() != GetDay()[1];
def prevHigh = if (newDay and isInSession) then high else if (isInSession) then Max(high, prevHigh[1]) else prevHigh[1];
def prevLow = if (newDay and isInSession) then low else if (isInSession) then Min(low, prevLow[1]) else prevLow[1];
def prevClose = if (newDay and isInSession) then close else prevClose[1];

# Ensure we only use the values from the correct session
def prevHighFiltered = if (SecondsFromTime(sessionStart) == 0) then prevHigh[1] else prevHigh;
def prevLowFiltered = if (SecondsFromTime(sessionStart) == 0) then prevLow[1] else prevLow;
def prevCloseFiltered = if (SecondsFromTime(sessionStart) == 0) then prevClose[1] else prevClose;

# Calculate pivot points using the filtered high, low, and close
def pivot_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).pivot_line;
def r1_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).r1_line;
def s1_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).s1_line;
def r2_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).r2_line;
def s2_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).s2_line;
def r3_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).r3_line;
def s3_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).s3_line;

# Plot lines
plot Pivot = pivot_;
Pivot.SetDefaultColor(Color.ORANGE);
Pivot.SetLineWeight(line_width);

plot R1 = r1_;
R1.SetDefaultColor(Color.ORANGE);
R1.SetLineWeight(line_width);

plot S1 = s1_;
S1.SetDefaultColor(Color.ORANGE);
S1.SetLineWeight(line_width);

plot R2 = r2_;
R2.SetDefaultColor(Color.ORANGE);
R2.SetLineWeight(line_width);

plot S2 = s2_;
S2.SetDefaultColor(Color.ORANGE);
S2.SetLineWeight(line_width);

plot R3 = r3_;
R3.SetDefaultColor(Color.ORANGE);
R3.SetLineWeight(line_width);

plot S3 = s3_;
S3.SetDefaultColor(Color.ORANGE);
S3.SetLineWeight(line_width);

Version 2:

Code:
# Define inputs
input pivot_time_frame = {default "AUTO", "DAILY", "WEEKLY", "MONTHLY", "QUARTERLY", "YEARLY", "BIYEARLY", "TRIYEARLY", "QUINQUENNIALLY", "DECENNIALLY"};
input look_back = 1;
input is_daily_based = yes;
input show_labels = yes;
input show_prices = yes;
input position_labels = {default "Left", "Right"};
input line_width = 1;

# Define variables
def na = Double.NaN;
def resolution;

switch (pivot_time_frame) {
case "AUTO":
    if (GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN) {
        resolution = AggregationPeriod.DAY;
    } else {
        resolution = AggregationPeriod.WEEK;
    }
case "DAILY":
    resolution = AggregationPeriod.DAY;
case "WEEKLY":
    resolution = AggregationPeriod.WEEK;
case "MONTHLY":
    resolution = AggregationPeriod.MONTH;
case "QUARTERLY":
    resolution = AggregationPeriod.QUARTER;
case "YEARLY":
    resolution = AggregationPeriod.YEAR;
case "BIYEARLY":
    resolution = AggregationPeriod.YEAR * 2;
case "TRIYEARLY":
    resolution = AggregationPeriod.YEAR * 3;
case "QUINQUENNIALLY":
    resolution = AggregationPeriod.YEAR * 5;
case "DECENNIALLY":
    resolution = AggregationPeriod.YEAR * 10;
}

# Helper functions
script calc_pivot {
    input kind = {"TRADITIONAL", default "WOODIE"};
    input prev_high = close;
    input prev_low = close;
    input prev_close = close;
    def pivot_;
    def r1_;
    def s1_;
    def r2_;
    def s2_;
    def r3_;
    def s3_;
    def na = Double.NaN;

    if (kind == kind.TRADITIONAL) {
        pivot_ = (prev_high + prev_low + prev_close) / 3;
        r1_ = pivot_ * 2 - prev_low;
        s1_ = pivot_ * 2 - prev_high;
        r2_ = pivot_ + (prev_high - prev_low);
        s2_ = pivot_ - (prev_high - prev_low);
        r3_ = pivot_ * 2 + (prev_high - 2 * prev_low);
        s3_ = pivot_ * 2 - (2 * prev_high - prev_low);
    } else {
        pivot_ = na;
        r1_ = na;
        s1_ = na;
        r2_ = na;
        s2_ = na;
        r3_ = na;
        s3_ = na;
    }

    plot pivot_line = pivot_;
    plot r1_line = r1_;
    plot s1_line = s1_;
    plot r2_line = r2_;
    plot s2_line = s2_;
    plot r3_line = r3_;
    plot s3_line = s3_;
}

# Get data for calculations
def prev_high = high(period = resolution)[1];
def prev_low = low(period = resolution)[1];
def prev_close = close(period = resolution)[1];

def pivot_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).pivot_line;
def r1_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).r1_line;
def s1_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).s1_line;
def r2_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).r2_line;
def s2_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).s2_line;
def r3_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).r3_line;
def s3_ = calc_pivot("TRADITIONAL", prev_high, prev_low, prev_close).s3_line;

# Plot lines
plot Pivot = pivot_;
Pivot.SetDefaultColor(Color.ORANGE);
Pivot.SetLineWeight(line_width);

plot R1 = r1_;
R1.SetDefaultColor(Color.ORANGE);
R1.SetLineWeight(line_width);

plot S1 = s1_;
S1.SetDefaultColor(Color.ORANGE);
S1.SetLineWeight(line_width);

plot R2 = r2_;
R2.SetDefaultColor(Color.ORANGE);
R2.SetLineWeight(line_width);

plot S2 = s2_;
S2.SetDefaultColor(Color.ORANGE);
S2.SetLineWeight(line_width);

plot R3 = r3_;
R3.SetDefaultColor(Color.ORANGE);
R3.SetLineWeight(line_width);

plot S3 = s3_;
S3.SetDefaultColor(Color.ORANGE);
S3.SetLineWeight(line_width);

reply to 265

you are using start time of 1800? you didn't say anything about futures in your post.
i'm not making it work for futures. you need to read data at the end of one day and the beginning of the next day and combine the data ( have to span midnight).

i simplified ver1
you are calling the script once per bar and using each plot once per bar, so there is no need for the sub script, calc_pivot

no idea why this is in it
input kind = {"TRADITIONAL", default "WOODIE"};
so i disabled it

added
.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
to draw lines

i don't know if this is close to what you want. but it plots lines and is a starting point for you to experiment with.
there are plenty of other pivot studies, so no need to reinvent the wheel

Code:
#pivot_fix2

#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-14#post-143023
#dreams  7/3  #266

#There are two versions of PIVOT POINTS I tried to create for TOS (with my limited ability) but they're not working as they should. If anyone can help fix.

#Version 1:

# Define inputs
input pivot_time_frame = {default "AUTO", "DAILY", "WEEKLY", "MONTHLY", "QUARTERLY", "YEARLY", "BIYEARLY", "TRIYEARLY", "QUINQUENNIALLY", "DECENNIALLY"};
input look_back = 1;
input is_daily_based = yes;
input show_labels = yes;
input show_prices = yes;
input position_labels = {default "Left", "Right"};
input line_width = 1;

# Define variables
def na = Double.NaN;
def resolution;

switch (pivot_time_frame) {
case "AUTO":
    if (GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN) {
        resolution = AggregationPeriod.DAY;
    } else {
        resolution = AggregationPeriod.WEEK;
    }
case "DAILY":
    resolution = AggregationPeriod.DAY;
case "WEEKLY":
    resolution = AggregationPeriod.WEEK;
case "MONTHLY":
    resolution = AggregationPeriod.MONTH;
case "QUARTERLY":
    resolution = AggregationPeriod.QUARTER;
case "YEARLY":
    resolution = AggregationPeriod.YEAR;
case "BIYEARLY":
    resolution = AggregationPeriod.YEAR * 2;
case "TRIYEARLY":
    resolution = AggregationPeriod.YEAR * 3;
case "QUINQUENNIALLY":
    resolution = AggregationPeriod.YEAR * 5;
case "DECENNIALLY":
    resolution = AggregationPeriod.YEAR * 10;
}


# Custom session start and end times
def sessionStart = 1800; # 6:00 PM
def sessionEnd = 1700; # 5:00 PM

# Adjust the session to span from 6:00 PM to 5:00 PM
def isInSession = SecondsFromTime(sessionStart) >= 0 or SecondsTillTime(sessionEnd) >= 0;
def newDay = GetDay() != GetDay()[1];

def prevHigh = if (newDay and isInSession) then high else if (isInSession) then Max(high, prevHigh[1]) else prevHigh[1];
def prevLow = if (newDay and isInSession) then low else if (isInSession) then Min(low, prevLow[1]) else prevLow[1];
def prevClose = if (newDay and isInSession) then close else prevClose[1];

# Ensure we only use the values from the correct session
def prevHighFiltered = if (SecondsFromTime(sessionStart) == 0) then prevHigh[1] else prevHigh;
def prevLowFiltered = if (SecondsFromTime(sessionStart) == 0) then prevLow[1] else prevLow;
def prevCloseFiltered = if (SecondsFromTime(sessionStart) == 0) then prevClose[1] else prevClose;


# Helper functions
#script calc_pivot {
# (x, prevHighFiltered, prevLowFiltered, prevCloseFiltered).r1_line;
#   input kind = {"TRADITIONAL", default "WOODIE"};
#    input prev_high = close;
#    input prev_low = close;
#    input prev_close = close;

def prev_high = prevHighFiltered;
def prev_low = prevLowFiltered;
def prev_close = prevCloseFiltered;

    def pivot_;
    def r1_;
    def s1_;
    def r2_;
    def s2_;
    def r3_;
    def s3_;
#    def na = Double.NaN;
#    if (kind == kind.TRADITIONAL) {
        pivot_ = (prev_high + prev_low + prev_close) / 3;
        r1_ = pivot_ * 2 - prev_low;
        s1_ = pivot_ * 2 - prev_high;
        r2_ = pivot_ + (prev_high - prev_low);
        s2_ = pivot_ - (prev_high - prev_low);
        r3_ = pivot_ * 2 + (prev_high - 2 * prev_low);
        s3_ = pivot_ * 2 - (2 * prev_high - prev_low);
#    } else {
#        pivot_ = na;
#        r1_ = na;
#        s1_ = na;
#        r2_ = na;
#        s2_ = na;
#        r3_ = na;
#        s3_ = na;
#    }

#    plot pivot_line = pivot_;
#    plot r1_line = r1_;
#    plot s1_line = s1_;
#    plot r2_line = r2_;
#    plot s2_line = s2_;
#    plot r3_line = r3_;
#    plot s3_line = s3_;
#}


# Calculate pivot points using the filtered high, low, and close
#def pivot_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).pivot_line;
#def r1_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).r1_line;
#def s1_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).s1_line;
#def r2_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).r2_line;
#def s2_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).s2_line;
#def r3_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).r3_line;
#def s3_ = calc_pivot("TRADITIONAL", prevHighFiltered, prevLowFiltered, prevCloseFiltered).s3_line;


# Plot lines
plot Pivot = pivot_;
Pivot.SetDefaultColor(Color.ORANGE);
Pivot.SetLineWeight(line_width);
pivot.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


plot R1 = r1_;
R1.SetDefaultColor(Color.ORANGE);
R1.SetLineWeight(line_width);
r1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot S1 = s1_;
S1.SetDefaultColor(Color.ORANGE);
S1.SetLineWeight(line_width);
s1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


plot R2 = r2_;
R2.SetDefaultColor(Color.ORANGE);
R2.SetLineWeight(line_width);
r2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot S2 = s2_;
S2.SetDefaultColor(Color.ORANGE);
S2.SetLineWeight(line_width);
s2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot R3 = r3_;
R3.SetDefaultColor(Color.ORANGE);
R3.SetLineWeight(line_width);
r3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot S3 = s3_;
S3.SetDefaultColor(Color.ORANGE);
S3.SetLineWeight(line_width);
s3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#
 
Last edited:
I'm trying to create an indicator that would highlight the slope of VWAP. When descending, the VWAP would be colored red, and the ascending VWAP would be colored green. Also, as the slope of the VWAP increased, the line would intensify in color, and thicken.

I'm not a coder, I've tried to put a script together using Chat GPT but cannot resolve these errors:

Cannot access dynamic value for initialization of 'setdefaultcolor'
Cannot access dynamic value for initialization of 'setlineweight'

Here's what I've got so far:

# VWAP with Colored Slope Intensity and Variable Line Thickness

# Calculate VWAP
def vwapValue = reference VWAP();

# Calculate the slope of VWAP
def slopeVWAP = vwapValue - vwapValue[1];

# Calculate the angle of the slope in degrees
def angle = ATAN(slopeVWAP) * 180 / Double.Pi;

# Define the line thickness based on the steepness of the slope
def lineWeight = if AbsValue(angle) >= 40 then 5 else if AbsValue(angle) >= 30 then 4 else if AbsValue(angle) >= 20 then 3 else if AbsValue(angle) >= 10 then 2 else 1;

# Plot VWAP with conditional coloring and variable line thickness
plot VWAPPlot = vwapValue;
VWAPPlot.SetDefaultColor(if angle > 0 then Color.DARK_GREEN else if angle < 0 then Color.DARK_RED else Color.WHITE); # Set color based on slope
VWAPPlot.SetLineWeight(lineWeight); # Set line weight based on slope

# Ensure the study is plotted on the price chart (upper study)
AddLabel(yes, "VWAP", Color.WHITE);

reply to 265

use .AssignValueColor( ) to choose a color for a plot shape
can't use a formula to calc a line weight. it has to be a constant.


Code:
#chat265_vwap

#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-14#post-142524
# Calculate VWAP
def vwapValue = reference VWAP();

# Calculate the slope of VWAP
def slopeVWAP = vwapValue - vwapValue[1];

# Calculate the angle of the slope in degrees
def angle = ATan(slopeVWAP) * 180 / Double.Pi;

# Define the line thickness based on the steepness of the slope
def lineWeight = if AbsValue(angle) >= 40 then 5 else if AbsValue(angle) >= 30 then 4 else if AbsValue(angle) >= 20 then 3 else if AbsValue(angle) >= 10 then 2 else 1;

# Plot VWAP with conditional coloring and variable line thickness
plot VWAPPlot = vwapValue;
#VWAPPlot.SetDefaultColor(if angle > 0 then Color.DARK_GREEN else if angle < 0 then Color.DARK_RED else Color.WHITE); # Set 
vwapplot.AssignValueColor(if angle > 0 then Color.DARK_GREEN else if angle < 0 then Color.DARK_RED else Color.WHITE);

#color based on slope
#VWAPPlot.SetLineWeight(lineWeight); # Set line weight based on slope
#VWAPPlot.SetLineWeight( if AbsValue(angle) >= 40 then 5 else if AbsValue(angle) >= 30 then 4 else if AbsValue(angle) >= 20 then 3 else if AbsValue(angle) >= 10 then 2 else 1);
VWAPPlot.SetLineWeight(2);

# Ensure the study is plotted on the price chart (upper study)
AddLabel(yes, "VWAP", Color.WHITE);
#
 
I tried to do the Multi Time Frame So I could use the 5min in the 1min time frame but get errors on TOS with the following script. Any help appreciated in advance.

https://usethinkscript.com/threads/blue-magik-ssl-indicator-for-thinkorswim.619/
# Blue Magik SSL - Multi-Timeframe Script
# Assembled by BenTen at useThinkScript.com

input period = AggregationPeriod.DAY; # Default to daily timeframe
input len = 10;

# Define functions to fetch data from different timeframes
def timeframeHigh = high(period);
def timeframeLow = low(period);
def timeframeClose = close(period);

def smaHigh = SimpleMovingAvg(timeframeHigh, len);
def smaLow = SimpleMovingAvg(timeframeLow, len);
def Hlv = if timeframeClose > smaHigh then 1 else if timeframeClose < smaLow then -1 else Hlv[1];

def sslDown = if Hlv < 0 then smaHigh else smaLow;
def sslUp = if Hlv < 0 then smaLow else smaHigh;

# Plot SSL values
plot up = sslUp;
plot down = sslDown;

up.SetDefaultColor(GetColor(1));
down.SetDefaultColor(GetColor(0));
 
Last edited by a moderator:
This script may need some fine tuning. Below are the errors I am coming across.

# Advanced Entry & Exit Signals with RSI, MACD, and Moving Averages

# Input parameters for moving averages
input shortLength = 9; # Short-term moving average length
input longLength = 21; # Long-term moving average length

# Input parameters for RSI
input rsiLength = 14; # RSI length
input rsiOverbought = 70; # RSI overbought level
input rsiOversold = 30; # RSI oversold level

# Input parameters for MACD
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;

# Calculate the moving averages
def shortMA = Average(close, shortLength);
def longMA = Average(close, longLength);

# Calculate the RSI
def rsi = RSI(close, rsiLength);

# Calculate the MACD
def MACDValue = MACD(fastLength, slowLength, macdLength, AverageType.EXPONENTIAL).Value;
def MACDSignal = MACD(fastLength, slowLength, macdLength, AverageType.EXPONENTIAL).Avg;

# Define the crossover conditions
def bullishCrossover = shortMA crosses above longMA;
def bearishCrossover = shortMA crosses below longMA;

# Define MACD crossover conditions
def MACDBullish = MACDValue crosses above MACDSignal;
def MACDBearish = MACDValue crosses below MACDSignal;

# Define entry signals based on crossover and RSI conditions
def buySignal = bullishCrossover and rsi < rsiOverbought and MACDBullish;
def sellSignal = bearishCrossover and rsi > rsiOversold and MACDBearish;

# Plot the moving averages
plot Short_MA = shortMA;
Short_MA.SetDefaultColor(Color.CYAN);
Short_MA.SetLineWeight(2);

plot Long_MA = longMA;
Long_MA.SetDefaultColor(Color.ORANGE);
Long_MA.SetLineWeight(2);

# Plot arrows for buy and sell signals
plot BuySignal = if buySignal then low else Double.NaN;
BuySignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BuySignal.SetDefaultColor(Color.GREEN);
BuySignal.SetLineWeight(3);

plot SellSignal = if sellSignal then high else Double.NaN;
SellSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SellSignal.SetDefaultColor(Color.RED);
SellSignal.SetLineWeight(3);

# Add labels for buy and sell signals
AddLabel(buySignal, "Buy Signal", Color.GREEN);
AddLabel(sellSignal, "Sell Signal", Color.RED);

# Define exit signals
def rsiExitOverbought = rsi > rsiOverbought;
def rsiExitOversold = rsi < rsiOversold;

# Plot arrows for exit signals
plot ExitBuySignal = if rsiExitOverbought then high else Double.NaN;
ExitBuySignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ExitBuySignal.SetDefaultColor(Color.YELLOW);
ExitBuySignal.SetLineWeight(2);

plot ExitSellSignal = if rsiExitOversold then low else Double.NaN;
ExitSellSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ExitSellSignal.SetDefaultColor(Color.BLUE);
ExitSellSignal.SetLineWeight(2);

# Add labels for exit signals
AddLabel(rsiExitOverbought, "Exit Buy Signal", Color.YELLOW);
AddLabel(rsiExitOversold, "Exit Sell Signal", Color.BLUE);
 

Attachments

  • Screen Shot 2024-06-25 at 3.24.29 AM.png
    Screen Shot 2024-06-25 at 3.24.29 AM.png
    38.2 KB · Views: 78
  • Screen Shot 2024-06-25 at 3.33.32 AM.png
    Screen Shot 2024-06-25 at 3.33.32 AM.png
    143.5 KB · Views: 72
  • Screen Shot 2024-06-25 at 3.33.39 AM.png
    Screen Shot 2024-06-25 at 3.33.39 AM.png
    24.9 KB · Views: 76
I'm looking to create a scan that looks for stocks whose stochastic is making its first appearance in the oversold territory (lets say below value of -20) since the last time the 9 EMA has crossed above the 21 MA. Here is what I have below but I don't think it is working correctly:

Code:
# Define the lengths for the EMAs
input shortEmaLength = 9;
input longEmaLength = 21;

# Calculate the 9 EMA and 21 EMA
def shortEma = ExpAverage(close, shortEmaLength);
def longEma = ExpAverage(close, longEmaLength);

# Condition to check if 9 EMA is crossing above 21 EMA
def emaCrossAbove = shortEma crosses above longEma;

# Calculate the Stochastic Momentum Index (SMI)
input smiLength = 14;
input kPeriod = 3;
input dPeriod = 3;
input averageType = AverageType.SIMPLE;

def minLow = Lowest(low, smiLength);
def maxHigh = Highest(high, smiLength);
def smi = if (maxHigh - minLow) != 0 then 100 * (close - (minLow + maxHigh) / 2) / ((maxHigh - minLow) / 2) else 0;
def smiK = ExpAverage(smi, kPeriod);
def smiD = ExpAverage(smiK, dPeriod);

# Track the state of SMI and EMA crossover
def lastEmaCrossAbove = CompoundValue(1, if emaCrossAbove then 1 else if smiK < 0 then 0 else lastEmaCrossAbove[1], 1);
def smiBecomingOversold = smiK is less than 0;

# Condition to check if SMI is becoming oversold for the first time since the crossover
def smiCondition = smiBecomingOversold and lastEmaCrossAbove;

# Create the scan condition combining both conditions
plot scanCondition = smiCondition and emaCrossAbove[1];

Here is also a picture of the condition I am looking for:
The right arrow is about where I would want the scanner to pull up the stock.
Thank you in advance for your help!

reply to 267

here is a lower study to experiment with
it plots a green vertical line for a buy signal

your stoch code doesn't seem to match the tos code, but i left it.


Code:
#chat267_stoch_scan

#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-14#post-143064
#Chedderbob9
#7/3
#267
#I'm looking to create a scan that looks for,
#  the 9 EMA crosses above the 21EMA
#  after the crossing,
#  stochastic crosses below  -20
#  


declare lower;

def na = double.nan;
def bn = barnumber();

# Define the lengths for the EMAs
input shortEmaLength = 9;
input longEmaLength = 21;

# Calculate the 9 EMA and 21 EMA
def shortEma = ExpAverage(close, shortEmaLength);
def longEma = ExpAverage(close, longEmaLength);

# Condition to check if 9 EMA is crossing above 21 EMA
def emaCrossAbove = shortEma crosses above longEma;
#def emaCrossbelow = shortEma crosses below longEma;


# Calculate the Stochastic Momentum Index (SMI)
input smiLength = 14;
input kPeriod = 3;
input dPeriod = 3;
input averageType = AverageType.SIMPLE;

def minLow = Lowest(low, smiLength);
def maxHigh = Highest(high, smiLength);
def smi = if (maxHigh - minLow) != 0 then 100 * (close - (minLow + maxHigh) / 2) / ((maxHigh - minLow) / 2) else 0;
def smiK = ExpAverage(smi, kPeriod);
def smiD = ExpAverage(smiK, dPeriod);


def p = -20;
def smidrop = smik < p and smik[1] > p;


def maxseq = 2;
def seq = if bn == 1 then 0
# reset
 else if seq[1] == maxseq then 0
# rule 1
 else if seq[1] == 0 and emaCrossAbove then 1
# rule 2
 else if seq[1] == 1 and smidrop then 2
 else seq[1];

def buy = seq == maxseq;


# Track the state of SMI and EMA crossover
#def lastEmaCrossAbove = CompoundValue(1, if emaCrossAbove then 1 else if smiK < 0 then 0 else lastEmaCrossAbove[1], 1);
#def smiBecomingOversold = smiK is less than 0;

# Condition to check if SMI is becoming oversold for the first time since the crossover
#def smiCondition = smiBecomingOversold and lastEmaCrossAbove;

# Create the scan condition combining both conditions
#plot scanCondition = smiCondition and emaCrossAbove[1];


#------------------------------
addverticalline(emaCrossAbove, "ema cross", color.cyan);
addverticalline(smidrop, "smi drop", color.yellow);
addverticalline(buy, "buy", color.green);

plot z = smik;
plot y = p;
 
This script may need some fine tuning. Below are the errors I am coming across.

# Advanced Entry & Exit Signals with RSI, MACD, and Moving Averages

# Input parameters for moving averages
input shortLength = 9; # Short-term moving average length
input longLength = 21; # Long-term moving average length

# Input parameters for RSI
input rsiLength = 14; # RSI length
input rsiOverbought = 70; # RSI overbought level
input rsiOversold = 30; # RSI oversold level

# Input parameters for MACD
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;

# Calculate the moving averages
def shortMA = Average(close, shortLength);
def longMA = Average(close, longLength);

# Calculate the RSI
def rsi = RSI(close, rsiLength);

# Calculate the MACD
def MACDValue = MACD(fastLength, slowLength, macdLength, AverageType.EXPONENTIAL).Value;
def MACDSignal = MACD(fastLength, slowLength, macdLength, AverageType.EXPONENTIAL).Avg;

# Define the crossover conditions
def bullishCrossover = shortMA crosses above longMA;
def bearishCrossover = shortMA crosses below longMA;

# Define MACD crossover conditions
def MACDBullish = MACDValue crosses above MACDSignal;
def MACDBearish = MACDValue crosses below MACDSignal;

# Define entry signals based on crossover and RSI conditions
def buySignal = bullishCrossover and rsi < rsiOverbought and MACDBullish;
def sellSignal = bearishCrossover and rsi > rsiOversold and MACDBearish;

# Plot the moving averages
plot Short_MA = shortMA;
Short_MA.SetDefaultColor(Color.CYAN);
Short_MA.SetLineWeight(2);

plot Long_MA = longMA;
Long_MA.SetDefaultColor(Color.ORANGE);
Long_MA.SetLineWeight(2);

# Plot arrows for buy and sell signals
plot BuySignal = if buySignal then low else Double.NaN;
BuySignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BuySignal.SetDefaultColor(Color.GREEN);
BuySignal.SetLineWeight(3);

plot SellSignal = if sellSignal then high else Double.NaN;
SellSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SellSignal.SetDefaultColor(Color.RED);
SellSignal.SetLineWeight(3);

# Add labels for buy and sell signals
AddLabel(buySignal, "Buy Signal", Color.GREEN);
AddLabel(sellSignal, "Sell Signal", Color.RED);

# Define exit signals
def rsiExitOverbought = rsi > rsiOverbought;
def rsiExitOversold = rsi < rsiOversold;

# Plot arrows for exit signals
plot ExitBuySignal = if rsiExitOverbought then high else Double.NaN;
ExitBuySignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ExitBuySignal.SetDefaultColor(Color.YELLOW);
ExitBuySignal.SetLineWeight(2);

plot ExitSellSignal = if rsiExitOversold then low else Double.NaN;
ExitSellSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ExitSellSignal.SetDefaultColor(Color.BLUE);
ExitSellSignal.SetLineWeight(2);

# Add labels for exit signals
AddLabel(rsiExitOverbought, "Exit Buy Signal", Color.YELLOW);
AddLabel(rsiExitOversold, "Exit Sell Signal", Color.BLUE);

reply to 269


rsi formula is wrong
def rsi = RSI(close, rsiLength);

open the rsi study and look at the code. here are the inputs.
length is first, price is 4th
if you use the parameter names, then they don't have to be in the correct order.

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

corrected,
def rsi = RSI(length = rsiLength, price = close);


can only use a variable name once. you have duplicates.
rename the plot variables


Code:
#chat269_Entry_Exit

#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-14#post-143282
#Likos
#269
#This script may need some fine tuning. Below are the errors I am coming across.

# Advanced Entry & Exit Signals with RSI, MACD, and Moving Averages

# Input parameters for moving averages
input shortLength = 9; # Short-term moving average length
input longLength = 21; # Long-term moving average length

# Input parameters for RSI
input rsiLength = 14; # RSI length
input rsiOverbought = 70; # RSI overbought level
input rsiOversold = 30; # RSI oversold level

# Input parameters for MACD
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;

# Calculate the moving averages
def shortMA = Average(close, shortLength);
def longMA = Average(close, longLength);

# Calculate the RSI
#def rsi = RSI(close, rsiLength);
def rsi = RSI(length = rsiLength, price = close);


# Calculate the MACD
def MACDValue = MACD(fastLength, slowLength, macdLength, AverageType.EXPONENTIAL).Value;
def MACDSignal = MACD(fastLength, slowLength, macdLength, AverageType.EXPONENTIAL).Avg;

# Define the crossover conditions
def bullishCrossover = shortMA crosses above longMA;
def bearishCrossover = shortMA crosses below longMA;

# Define MACD crossover conditions
def MACDBullish = MACDValue crosses above MACDSignal;
def MACDBearish = MACDValue crosses below MACDSignal;

# Define entry signals based on crossover and RSI conditions
def buySignal = bullishCrossover and rsi < rsiOverbought and MACDBullish;
def sellSignal = bearishCrossover and rsi > rsiOversold and MACDBearish;

# Plot the moving averages
plot Short_MA = shortMA;
Short_MA.SetDefaultColor(Color.CYAN);
Short_MA.SetLineWeight(2);

plot Long_MA = longMA;
Long_MA.SetDefaultColor(Color.ORANGE);
Long_MA.SetLineWeight(2);

# Plot arrows for buy and sell signals
plot zBuySignal = if BuySignal then low else Double.NaN;
zBuySignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zBuySignal.SetDefaultColor(Color.GREEN);
zBuySignal.SetLineWeight(3);

plot zSellSignal = if SellSignal then high else Double.NaN;
zSellSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zSellSignal.SetDefaultColor(Color.RED);
zSellSignal.SetLineWeight(3);

# Add labels for buy and sell signals
AddLabel(BuySignal, "Buy Signal", Color.GREEN);
AddLabel(SellSignal, "Sell Signal", Color.RED);

# Define exit signals
def rsiExitOverbought = rsi > rsiOverbought;
def rsiExitOversold = rsi < rsiOversold;

# Plot arrows for exit signals
plot ExitBuySignal = if rsiExitOverbought then high else Double.NaN;
ExitBuySignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ExitBuySignal.SetDefaultColor(Color.YELLOW);
ExitBuySignal.SetLineWeight(2);

plot ExitSellSignal = if rsiExitOversold then low else Double.NaN;
ExitSellSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ExitSellSignal.SetDefaultColor(Color.BLUE);
ExitSellSignal.SetLineWeight(2);

# Add labels for exit signals
AddLabel(rsiExitOverbought, "Exit Buy Signal", Color.YELLOW);
AddLabel(rsiExitOversold, "Exit Sell Signal", Color.BLUE);
#
 
I'm looking to create a scan that looks for stocks whose stochastic is making its first appearance in the oversold territory (lets say below value of -20) since the last time the 9 EMA has crossed above the 21 MA. Here is what I have below but I don't think it is working correctly:

Code:
# Define the lengths for the EMAs
input shortEmaLength = 9;
input longEmaLength = 21;

# Calculate the 9 EMA and 21 EMA
def shortEma = ExpAverage(close, shortEmaLength);
def longEma = ExpAverage(close, longEmaLength);

# Condition to check if 9 EMA is crossing above 21 EMA
def emaCrossAbove = shortEma crosses above longEma;

# Calculate the Stochastic Momentum Index (SMI)
input smiLength = 14;
input kPeriod = 3;
input dPeriod = 3;
input averageType = AverageType.SIMPLE;

def minLow = Lowest(low, smiLength);
def maxHigh = Highest(high, smiLength);
def smi = if (maxHigh - minLow) != 0 then 100 * (close - (minLow + maxHigh) / 2) / ((maxHigh - minLow) / 2) else 0;
def smiK = ExpAverage(smi, kPeriod);
def smiD = ExpAverage(smiK, dPeriod);

# Track the state of SMI and EMA crossover
def lastEmaCrossAbove = CompoundValue(1, if emaCrossAbove then 1 else if smiK < 0 then 0 else lastEmaCrossAbove[1], 1);
def smiBecomingOversold = smiK is less than 0;

# Condition to check if SMI is becoming oversold for the first time since the crossover
def smiCondition = smiBecomingOversold and lastEmaCrossAbove;

# Create the scan condition combining both conditions
plot scanCondition = smiCondition and emaCrossAbove[1];

Here is also a picture of the condition I am looking for:

ADT.png


The right arrow is about where I would want the scanner to pull up the stock.

Thank you in advance for your help!
 
I tried to do the Multi Time Frame So I could use the 5min in the 1min time frame but get errors on TOS with the following script. Any help appreciated in advance.

https://usethinkscript.com/threads/blue-magik-ssl-indicator-for-thinkorswim.619/
# Blue Magik SSL - Multi-Timeframe Script
# Assembled by BenTen at useThinkScript.com

input period = AggregationPeriod.DAY; # Default to daily timeframe
input len = 10;

# Define functions to fetch data from different timeframes
def timeframeHigh = high(period);
def timeframeLow = low(period);
def timeframeClose = close(period);

def smaHigh = SimpleMovingAvg(timeframeHigh, len);
def smaLow = SimpleMovingAvg(timeframeLow, len);
def Hlv = if timeframeClose > smaHigh then 1 else if timeframeClose < smaLow then -1 else Hlv[1];

def sslDown = if Hlv < 0 then smaHigh else smaLow;
def sslUp = if Hlv < 0 then smaLow else smaHigh;

# Plot SSL values
plot up = sslUp;
plot down = sslDown;

up.SetDefaultColor(GetColor(1));
down.SetDefaultColor(GetColor(0));

reply to 268

you are missing the input parameter name , period =
def timeframeHigh = high(period = period);


Code:
#chat268_mtf_fix

#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-14#post-143253
#stocksniper
#268
#I tried to do the Multi Time Frame So I could use the 5min in the 1min time frame but get errors on TOS with the following script. Any help appreciated in advance.

#https://usethinkscript.com/threads/blue-magik-ssl-indicator-for-thinkorswim.619/
# Blue Magik SSL - Multi-Timeframe Script
# Assembled by BenTen at useThinkScript.com

input period = AggregationPeriod.DAY; # Default to daily timeframe
input len = 10;

# Define functions to fetch data from different timeframes
def timeframeHigh = high(period = period);
def timeframeLow = low(period = period);
def timeframeClose = close(period = period);

def smaHigh = SimpleMovingAvg(timeframeHigh, len);
def smaLow = SimpleMovingAvg(timeframeLow, len);
def Hlv = if timeframeClose > smaHigh then 1 else if timeframeClose < smaLow then -1 else Hlv[1];

def sslDown = if Hlv < 0 then smaHigh else smaLow;
def sslUp = if Hlv < 0 then smaLow else smaHigh;

# Plot SSL values
plot up = sslUp;
plot down = sslDown;

up.SetDefaultColor(GetColor(1));
down.SetDefaultColor(GetColor(0));
#
 
I'm looking to create a scan that looks for stocks whose stochastic is making its first appearance in the oversold territory (lets say below value of -20) since the last time the 9 EMA has crossed above the 21 MA. Here is what I have below but I don't think it is working correctly:

Code:
# Define the lengths for the EMAs
input shortEmaLength = 9;
input longEmaLength = 21;

# Calculate the 9 EMA and 21 EMA
def shortEma = ExpAverage(close, shortEmaLength);
def longEma = ExpAverage(close, longEmaLength);

# Condition to check if 9 EMA is crossing above 21 EMA
def emaCrossAbove = shortEma crosses above longEma;

# Calculate the Stochastic Momentum Index (SMI)
input smiLength = 14;
input kPeriod = 3;
input dPeriod = 3;
input averageType = AverageType.SIMPLE;

def minLow = Lowest(low, smiLength);
def maxHigh = Highest(high, smiLength);
def smi = if (maxHigh - minLow) != 0 then 100 * (close - (minLow + maxHigh) / 2) / ((maxHigh - minLow) / 2) else 0;
def smiK = ExpAverage(smi, kPeriod);
def smiD = ExpAverage(smiK, dPeriod);

# Track the state of SMI and EMA crossover
def lastEmaCrossAbove = CompoundValue(1, if emaCrossAbove then 1 else if smiK < 0 then 0 else lastEmaCrossAbove[1], 1);
def smiBecomingOversold = smiK is less than 0;

# Condition to check if SMI is becoming oversold for the first time since the crossover
def smiCondition = smiBecomingOversold and lastEmaCrossAbove;

# Create the scan condition combining both conditions
plot scanCondition = smiCondition and emaCrossAbove[1];

Here is also a picture of the condition I am looking for:



The right arrow is about where I would want the scanner to pull up the stock.

Thank you in advance for your help!

reply 272

fyi
your smi code doesn't match the code in TOS. smi doesn't have lowest and highest..? don't know why you have that in your code?
def smi =
so i can't compare to the real code to verify.


this is a lower study.
you weren't properly monitoring and keeping ema cross and waiting for stoch cross.
i added new code, using a variable, seq, as a progressing counter. as each rule is met, it increases. when the last rule is met, it plots a value of 1, else its 0.
if ema crosses below or smi crosses above the undersold, then it resets (cancels).


Code:
#chat273_scan_stoch_ema

#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-14#post-143064

declare lower;

def na = double.nan;
def bn = barnumber();

# Define the lengths for the EMAs
input shortEmaLength = 9;
input longEmaLength = 21;

# Calculate the 9 EMA and 21 EMA
def shortEma = ExpAverage(close, shortEmaLength);
def longEma = ExpAverage(close, longEmaLength);

# Condition to check if 9 EMA is crossing above 21 EMA
def emaCrossAbove = shortEma crosses above longEma;

def ema_cancel = shortEma crosses below longEma;

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

# Calculate the Stochastic Momentum Index (SMI)
input smiLength = 14;
input kPeriod = 3;
input dPeriod = 3;
input averageType = AverageType.SIMPLE;


def minLow = Lowest(low, smiLength);
def maxHigh = Highest(high, smiLength);
def smi = if (maxHigh - minLow) != 0 then 100 * (close - (minLow + maxHigh) / 2) / ((maxHigh - minLow) / 2) else 0;
def smiK = ExpAverage(smi, kPeriod);
def smiD = ExpAverage(smiK, dPeriod);

input over_sold = -20;
def smibelow = smi crosses below over_sold;

def smi_cancel = smi crosses above over_sold;

def cancel = smi_cancel or ema_cancel;

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

# Track the state of SMI and EMA crossover
#def lastEmaCrossAbove = CompoundValue(1, if emaCrossAbove then 1 else if smiK < 0 then 0 else lastEmaCrossAbove[1], 1);
#def smiBecomingOversold = smiK is less than 0;

# Condition to check if SMI is becoming oversold for the first time since the crossover
#def smiCondition = smiBecomingOversold and lastEmaCrossAbove;

# Create the scan condition combining both conditions
#plot scanCondition = smiCondition and emaCrossAbove[1];

#Here is also a picture of the condition I am looking for:
#ADT.png
#The right arrow is about where I would want the scanner to pull up the stock.

def seqmax = 2;

def seq;
if bn == 1 then {
# initialize
 seq = 0;
} else if cancel or seq[1] == seqmax then {
# cancel if,
 seq = 0;
} else if seq[1] == 0 and emaCrossAbove then {
# ema cross
 seq = 1;
} else if seq[1] == 1 and smibelow then {
# smi cross
 seq = 2;
} else {
 seq = seq[1];
}
 
plot scan1 = if seq == seqmax then 1 else 0;

# scale smi smaller so can see output pulses
#plot z1 = smi/10;
#
 
Last edited:
The following script should show bid/ask for 25 delta and for current position ob TOS chart
It has an Invalid statement error at the lines with ******, can anyone correct this script. Thanks

# Define inputs
input targetDelta = 0.25;

# Get today's date
def today = GetYYYYMMDD();

# Define a function to get the absolute delta difference
******* def getDeltaDiff(delta) { #### this gives me an error - Invalid statement
return AbsValue(delta - targetDelta);
}

# Filter options data for calls and puts with deltas around 25
****** def callOptions = GetOptionData("CALL", today); ##### also this gives an error - Invalid statement
def putOptions = GetOptionData("PUT", today);

def callDeltaDiff = callOptions.delta - targetDelta;
def putDeltaDiff = putOptions.delta - targetDelta;

# Find the option with the minimum delta difference
def minCallDeltaDiff = Lowest(callDeltaDiff, 1);
def minPutDeltaDiff = Lowest(putDeltaDiff, 1);

def targetCallOption = if callDeltaDiff == minCallDeltaDiff then callOptions else Double.NaN;
def targetPutOption = if putDeltaDiff == minPutDeltaDiff then putOptions else Double.NaN;

# Get the bid and ask prices for the target options
def targetCallBid = if !IsNaN(targetCallOption.bid) then targetCallOption.bid else Double.NaN;
def targetCallAsk = if !IsNaN(targetCallOption.ask) then targetCallOption.ask else Double.NaN;
def targetPutBid = if !IsNaN(targetPutOption.bid) then targetPutOption.bid else Double.NaN;
def targetPutAsk = if !IsNaN(targetPutOption.ask) then targetPutOption.ask else Double.NaN;

# Add labels to the chart for call and put options
AddLabel(!IsNaN(targetCallBid) and !IsNaN(targetCallAsk), "25 Delta Call Option Bid: " + targetCallBid + " Ask: " + targetCallAsk, Color.YELLOW);
AddLabel(!IsNaN(targetPutBid) and !IsNaN(targetPutAsk), "25 Delta Put Option Bid: " + targetPutBid + " Ask: " + targetPutAsk, Color.YELLOW);
 
Scanner script help!

# Price range filter
def price = close;
def priceFilter = price >= 2 and price <= 10;

# Unusual volume filter
def avgVolume = Average(volume, 50);
def unusualVolume = volume > 1.5 * avgVolume;

# StochRSI filter for 1-minute chart
def RSI = RSI(length = 14);
def StochRSI1 = StochRSI(RSI, KPeriod = 3, DPeriod = 3, "over bought" = 14);
def stochRSI_1minFilter = StochRSI1 < 20;

# StochRSI filter for 5-minute chart
def RSI_5min = RSI(length = 14, close(period = AggregationPeriod.FIVE_MIN));
def StochRSI_5min = StochasticRSI(RSI_5min, length = 14, KPeriod = 3, DPeriod = 3);
def stochRSI_5minFilter = StochRSI_5min < 20;

# MACD filter for 5-minute chart
def MACD_5min = MACD(fastLength = 12, slowLength = 26, MACDLength = 9, price = close(period = AggregationPeriod.FIVE_MIN)).Value;
def MACD_5minFilter = MACD_5min > 0;

# MACD filter for 30-minute chart
def MACD_30min = MACD(fastLength = 12, slowLength = 26, MACDLength = 9, price = close(period = AggregationPeriod.THIRTY_MIN)).Value;
def MACD_30minFilter = MACD_30min > 0;

# Combine all filters
plot scan = priceFilter and unusualVolume and stochRSI_1minFilter and stochRSI_5minFilter and MACD_5minFilter and MACD_30minFilter;

can someone help me fix errors on this script? followings are highlighted red:
Line 15 "RSI"
Line 16 StochRSI_5min = StochasticRSI
Line 20 MACD and price
 
Last edited by a moderator:
Scanner script help!

# Price range filter
def price = close;
def priceFilter = price >= 2 and price <= 10;

# Unusual volume filter
def avgVolume = Average(volume, 50);
def unusualVolume = volume > 1.5 * avgVolume;

# StochRSI filter for 1-minute chart
def RSI = RSI(length = 14);
def StochRSI1 = StochRSI(RSI, KPeriod = 3, DPeriod = 3, "over bought" = 14);
def stochRSI_1minFilter = StochRSI1 < 20;

# StochRSI filter for 5-minute chart
def RSI_5min = RSI(length = 14, close(period = AggregationPeriod.FIVE_MIN));
def StochRSI_5min = StochasticRSI(RSI_5min, length = 14, KPeriod = 3, DPeriod = 3);
def stochRSI_5minFilter = StochRSI_5min < 20;

# MACD filter for 5-minute chart
def MACD_5min = MACD(fastLength = 12, slowLength = 26, MACDLength = 9, price = close(period = AggregationPeriod.FIVE_MIN)).Value;
def MACD_5minFilter = MACD_5min > 0;

# MACD filter for 30-minute chart
def MACD_30min = MACD(fastLength = 12, slowLength = 26, MACDLength = 9, price = close(period = AggregationPeriod.THIRTY_MIN)).Value;
def MACD_30minFilter = MACD_30min > 0;

# Combine all filters
plot scan = priceFilter and unusualVolume and stochRSI_1minFilter and stochRSI_5minFilter and MACD_5minFilter and MACD_30minFilter;

can someone help me fix errors on this script? followings are highlighted red:
Line 15 "RSI"
Line 16 StochRSI_5min = StochasticRSI
Line 20 MACD and price
reply 276

partial answer,
look up functions when using them.
you would have noticed rsi() has price as a 4th parameter, not 2nd. use the parameter names when assigning data.
probably same issue for other errors.

https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/R-S/RSI
 
The following script should show bid/ask for 25 delta and for current position ob TOS chart
It has an Invalid statement error at the lines with ******, can anyone correct this script. Thanks

# Define inputs
input targetDelta = 0.25;

# Get today's date
def today = GetYYYYMMDD();

# Define a function to get the absolute delta difference
******* def getDeltaDiff(delta) { #### this gives me an error - Invalid statement
return AbsValue(delta - targetDelta);
}

# Filter options data for calls and puts with deltas around 25
****** def callOptions = GetOptionData("CALL", today); ##### also this gives an error - Invalid statement
def putOptions = GetOptionData("PUT", today);

def callDeltaDiff = callOptions.delta - targetDelta;
def putDeltaDiff = putOptions.delta - targetDelta;

# Find the option with the minimum delta difference
def minCallDeltaDiff = Lowest(callDeltaDiff, 1);
def minPutDeltaDiff = Lowest(putDeltaDiff, 1);

def targetCallOption = if callDeltaDiff == minCallDeltaDiff then callOptions else Double.NaN;
def targetPutOption = if putDeltaDiff == minPutDeltaDiff then putOptions else Double.NaN;

# Get the bid and ask prices for the target options
def targetCallBid = if !IsNaN(targetCallOption.bid) then targetCallOption.bid else Double.NaN;
def targetCallAsk = if !IsNaN(targetCallOption.ask) then targetCallOption.ask else Double.NaN;
def targetPutBid = if !IsNaN(targetPutOption.bid) then targetPutOption.bid else Double.NaN;
def targetPutAsk = if !IsNaN(targetPutOption.ask) then targetPutOption.ask else Double.NaN;

# Add labels to the chart for call and put options
AddLabel(!IsNaN(targetCallBid) and !IsNaN(targetCallAsk), "25 Delta Call Option Bid: " + targetCallBid + " Ask: " + targetCallAsk, Color.YELLOW);
AddLabel(!IsNaN(targetPutBid) and !IsNaN(targetPutAsk), "25 Delta Put Option Bid: " + targetPutBid + " Ask: " + targetPutAsk, Color.YELLOW);

reply 275

you have too many made up functions.
you didn't describe what you are trying to do well enough. i can't decipher what you want to do.

go here and learn valid functions
https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Option-Related
then rewrite a thorough description
 
Help! Why is this code not plotting? I used ChatGPT

# User inputs for opening range start and end timesinput openingRangeStartTime = 0930; # Start time of the opening range in HHmm formatinput openingRangeEndTime = 1000; # End time of the opening range in HHmm format# User input for the length of the current price lineinput currentPriceLineLength = 10; # Number of bars to plot the current price line# Convert times to minutes past midnightdef startTime = openingRangeStartTime / 100 * 60;def endTime = openingRangeEndTime / 100 * 60;# Define the condition for being within the opening range perioddef isInOpeningRange = SecondsFromTime(startTime * 60) >= 0 and SecondsFromTime(endTime * 60) <= 0;def isNewDay = GetDay() != GetDay()[1]; # Detect new trading day# Initialize and update opening range high, low, and middledef openingRangeHigh = if isNewDay then high else if isInOpeningRange then Max(openingRangeHigh[1], high) else openingRangeHigh[1];def openingRangeLow = if isNewDay then low else if isInOpeningRange then Min(openingRangeLow[1], low) else openingRangeLow[1];def openingRangeMiddle = (openingRangeHigh + openingRangeLow) / 2;# Plot horizontal lines for the opening range high, low, and middleplot highLine = if !isInOpeningRange and !IsNaN(openingRangeHigh) then openingRangeHigh else Double.NaN;plot lowLine = if !isInOpeningRange and !IsNaN(openingRangeLow) then openingRangeLow else Double.NaN;plot middleLine = if !isInOpeningRange and !IsNaN(openingRangeMiddle) then openingRangeMiddle else Double.NaN;highLine.SetDefaultColor(Color.GREEN);lowLine.SetDefaultColor(Color.RED);middleLine.SetDefaultColor(Color.YELLOW);# Determine the current price and calculate the percentage change from the opening rangedef currentPrice = close;def percentageChangeFromHigh = if openingRangeHigh != 0 then (currentPrice - openingRangeHigh) / openingRangeHigh * 100 else Double.NaN;def percentageChangeFromLow = if openingRangeLow != 0 then (currentPrice - openingRangeLow) / openingRangeLow * 100 else Double.NaN;# Plot a horizontal line at the current price for a specified number of barsdef currentPriceOffset = if currentPriceLineLength > 0 then close[currentPriceLineLength] else Double.NaN;plot currentPriceLine = currentPriceOffset;currentPriceLine.SetDefaultColor(Color.CYAN);currentPriceLine.SetLineWeight(2);# Display a bubble with the percentage change from the opening range when the current price is above or below the opening rangeAddChartBubble(currentPrice > openingRangeHigh and !IsNaN(openingRangeHigh), currentPrice, Concat("Above High: ", AsPercent(percentageChangeFromHigh)), Color.GREEN, yes);AddChartBubble(currentPrice < openingRangeLow and !IsNaN(openingRangeLow), currentPrice, Concat("Below Low: ", AsPercent(percentageChangeFromLow)), Color.RED, yes);
 
Last edited by a moderator:
Help! Why is this code not plotting? I used ChatGPT

# User inputs for opening range start and end timesinput openingRangeStartTime = 0930; # Start time of the opening range in HHmm formatinput openingRangeEndTime = 1000; # End time of the opening range in HHmm format# User input for the length of the current price lineinput currentPriceLineLength = 10; # Number of bars to plot the current price line# Convert times to minutes past midnightdef startTime = openingRangeStartTime / 100 * 60;def endTime = openingRangeEndTime / 100 * 60;# Define the condition for being within the opening range perioddef isInOpeningRange = SecondsFromTime(startTime * 60) >= 0 and SecondsFromTime(endTime * 60) <= 0;def isNewDay = GetDay() != GetDay()[1]; # Detect new trading day# Initialize and update opening range high, low, and middledef openingRangeHigh = if isNewDay then high else if isInOpeningRange then Max(openingRangeHigh[1], high) else openingRangeHigh[1];def openingRangeLow = if isNewDay then low else if isInOpeningRange then Min(openingRangeLow[1], low) else openingRangeLow[1];def openingRangeMiddle = (openingRangeHigh + openingRangeLow) / 2;# Plot horizontal lines for the opening range high, low, and middleplot highLine = if !isInOpeningRange and !IsNaN(openingRangeHigh) then openingRangeHigh else Double.NaN;plot lowLine = if !isInOpeningRange and !IsNaN(openingRangeLow) then openingRangeLow else Double.NaN;plot middleLine = if !isInOpeningRange and !IsNaN(openingRangeMiddle) then openingRangeMiddle else Double.NaN;highLine.SetDefaultColor(Color.GREEN);lowLine.SetDefaultColor(Color.RED);middleLine.SetDefaultColor(Color.YELLOW);# Determine the current price and calculate the percentage change from the opening rangedef currentPrice = close;def percentageChangeFromHigh = if openingRangeHigh != 0 then (currentPrice - openingRangeHigh) / openingRangeHigh * 100 else Double.NaN;def percentageChangeFromLow = if openingRangeLow != 0 then (currentPrice - openingRangeLow) / openingRangeLow * 100 else Double.NaN;# Plot a horizontal line at the current price for a specified number of barsdef currentPriceOffset = if currentPriceLineLength > 0 then close[currentPriceLineLength] else Double.NaN;plot currentPriceLine = currentPriceOffset;currentPriceLine.SetDefaultColor(Color.CYAN);currentPriceLine.SetLineWeight(2);# Display a bubble with the percentage change from the opening range when the current price is above or below the opening rangeAddChartBubble(currentPrice > openingRangeHigh and !IsNaN(openingRangeHigh), currentPrice, Concat("Above High: ", AsPercent(percentageChangeFromHigh)), Color.GREEN, yes);AddChartBubble(currentPrice < openingRangeLow and !IsNaN(openingRangeLow), currentPrice, Concat("Below Low: ", AsPercent(percentageChangeFromLow)), Color.RED, yes);

reply to 277

everything is wrong.
if you want to learn read below
or just search for ORB and find a working study. not sure if i will be able to fix this mess.

search for ORB
https://usethinkscript.com/search/1652591/?q=orb&o=date

here is a simple ORB i made
https://usethinkscript.com/threads/shaded-opening-range-no-breakout.17922/#post-137958
can choose orb time

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

please learn how to post code in a code window
your whole code block pastes in as 1 huge comment, not usable code. there are to carriage returns. i had to separate every single code line.
when making a post, click on </> in the header, and a window opens up. post code in that window.

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

chatgpt is near worthless. just take the time to study and you can understand thinkscript in a couple of months. look at every function
https://toslc.thinkorswim.com/center/reference/thinkScript/Functions
and look at the code examples and try them. see what happens.

learn about bubbles. then you can use it to display variables
https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddChartBubble

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

next time, tell us what the code is supposed to do. don't just say, it doesn't work.
what do want to see on the chart?

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

your bad code
Code:
#chat277_doesnt_plot

#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-14#post-144491
#Dany2k #277
#Help! Why is this code not plotting? I used ChatGPT

# User inputs for opening range start and end times
input openingRangeStartTime = 0930;
 # Start time of the opening range in HHmm format
input openingRangeEndTime = 1000;
 # End time of the opening range in HHmm format
# User input for the length of the current price line
input currentPriceLineLength = 10;
 # Number of bars to plot the current price line
# Convert times to minutes past midnight
def startTime = openingRangeStartTime / 100 * 60;
def endTime = openingRangeEndTime / 100 * 60;
# Define the condition for being within the opening range period

def isInOpeningRange = SecondsFromTime(startTime * 60) >= 0 and SecondsFromTime(endTime * 60) <= 0;
def isNewDay = GetDay() != GetDay()[1];
# Detect new trading day

# Initialize and update opening range high, low, and middle
def openingRangeHigh = if isNewDay then high else if isInOpeningRange then Max(openingRangeHigh[1], high) else openingRangeHigh[1];
def openingRangeLow = if isNewDay then low else if isInOpeningRange then Min(openingRangeLow[1], low) else openingRangeLow[1];
def openingRangeMiddle = (openingRangeHigh + openingRangeLow) / 2;

# Plot horizontal lines for the opening range high, low, and middle
plot highLine = if !isInOpeningRange and !IsNaN(openingRangeHigh) then openingRangeHigh else Double.NaN;
plot lowLine = if !isInOpeningRange and !IsNaN(openingRangeLow) then openingRangeLow else Double.NaN;
plot middleLine = if !isInOpeningRange and !IsNaN(openingRangeMiddle) then openingRangeMiddle else Double.NaN;
highLine.SetDefaultColor(Color.GREEN);
lowLine.SetDefaultColor(Color.RED);
middleLine.SetDefaultColor(Color.YELLOW);

# Determine the current price and calculate the percentage change from the opening range
def currentPrice = close;
def percentageChangeFromHigh = if openingRangeHigh != 0 then (currentPrice - openingRangeHigh) / openingRangeHigh * 100 else Double.NaN;
def percentageChangeFromLow = if openingRangeLow != 0 then (currentPrice - openingRangeLow) / openingRangeLow * 100 else Double.NaN;

# Plot a horizontal line at the current price for a specified number of bars
def currentPriceOffset = if currentPriceLineLength > 0 then close[currentPriceLineLength] else Double.NaN;
plot currentPriceLine = currentPriceOffset;
currentPriceLine.SetDefaultColor(Color.CYAN);
currentPriceLine.SetLineWeight(2);

# Display a bubble with the percentage change from the opening range when the current price is above or below the opening range
AddChartBubble(currentPrice > openingRangeHigh and !IsNaN(openingRangeHigh), currentPrice, Concat("Above High: ", AsPercent(percentageChangeFromHigh)), Color.GREEN, yes);
AddChartBubble(currentPrice < openingRangeLow and !IsNaN(openingRangeLow), currentPrice, Concat("Below Low: ", AsPercent(percentageChangeFromLow)), Color.RED, yes);
#



wrong things,

def startTime = openingRangeStartTime / 100 * 60;
..openingRangeStartTime is just a number, 930 , not milliseconds
..if it was milliseconds, would need to /1000 not 100.


def isInOpeningRange = SecondsFromTime(startTime * 60) >= 0 0 and SecondsfromTime(endTime) <= 0;
..why is the *60 in there? the function returns seconds. if you want minutes, divide by 60
..startTime is in HHMM format
https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Date---Time/SecondsFromTime
..SecondsfromTime(endTime) endtime should use , till, SecondstillTime(endTime) >


calculate a percent by using 100*
if you use AsPercent() on that number, it will be 100x too big



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


i'm not going to fix this. there are already many orb studies.
here is the modified code , but still wrong. it doesn't plot horizontal lines.
i changed the bubbles to appear only on last bar, to show % change.


Code:
#chat277_doesnt_plot

#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-14#post-144491
#Dany2k #277
#Help! Why is this code not plotting? I used ChatGPT

# User inputs for opening range start and end times
input orb_start = 0930;
 # Start time of the opening range in HHmm format
input orb_end = 1000;
 # End time of the opening range in HHmm format

# User input for the length of the current price line
input currentPriceLineLength = 10;
 # Number of bars to plot the current price line

# Define the condition for being within the opening range period
def isorb = SecondsFromTime(orb_start) >= 0 and SecondstillTime(orb_end) > 0;
def isNewDay = GetDay() != GetDay()[1];
 # Detect new trading day

#addverticalline(isorb);

# Initialize and update opening range high, low, and middle
def orbhigh = if isNewDay then high else if isorb then Max(orbhigh[1], high) else orbhigh[1];
def orblow = if isNewDay then low else if isorb then Min(orblow[1], low) else orblow[1];
def openingRangeMiddle = (orbhigh + orblow) / 2;

# Plot horizontal lines for the opening range high, low, and middle
#plot highLine = if !isorb and !IsNaN(openingRangeHigh) then openingRangeHigh else Double.NaN;
plot highLine = if isorb then orbhigh else Double.NaN;
plot lowLine = if isorb then orblow else Double.NaN;
plot middleLine = if isorb then openingRangeMiddle else Double.NaN;
highLine.SetDefaultColor(Color.GREEN);
lowLine.SetDefaultColor(Color.RED);
middleLine.SetDefaultColor(Color.YELLOW);

def lastbar = (!isnan(close) and isnan(close[-1]));

# Determine the current price and calculate the percentage change from the opening range
def currentPrice = close;
def perchgFromHigh = round(100*(currentPrice - orbhigh) / orbhigh,1);
def perchgFromLow = round(100*(currentPrice - orblow) / orblow,1);

addchartbubble(0, low,
currentPrice + "\n" +
orbhigh
, color.yellow, no);


# Plot a horizontal line at the current price for a specified number of bars
#def currentPriceOffset = if currentPriceLineLength > 0 then close[currentPriceLineLength] else Double.NaN;
#plot currentPriceLine = currentPriceOffset;
#currentPriceLine.SetDefaultColor(Color.CYAN);
#currentPriceLine.SetLineWeight(2);
# Display a bubble with the percentage change from the opening range when the current price is above or below the opening range

AddChartBubble(
 lastbar,
 high,
 ("High chg: " + perchgFromHigh + "%"),
 Color.GREEN,
 yes);

AddChartBubble(
 lastbar,
 low,
 ("Low chg: " + perchgFromLow + "%"),
 Color.RED,
 no);
#
 
I am building a simple strategy and it works on the daily, 1hr, 15min, and below timeframes but does not show up on the 4hr, weekly, monthly, and above timeframes. I've tried using the aggregateperiod function but to no avail.

Code:
# Stochastic Slow Trading Strategy for Any Time Frame
declare upper;

input over_bought = 80;
input over_sold = 20;
input k_period = 10;
input d_period = 10;
input price_h = high;
input price_l = low;
input price_c = close;
input average_type = AverageType.SIMPLE;
input show_breakout_signals = no;

# Determine the aggregation period of the current chart
def aggregationPeriod = GetAggregationPeriod();

# Calculate High, Low, and Close based on the current aggregation period
def aggregatedHigh = high(period = aggregationPeriod);
def aggregatedLow = low(period = aggregationPeriod);
def aggregatedClose = close(period = aggregationPeriod);

# Calculate the Stochastic Slow using the aggregated data
def slowK = StochasticSlow(
    kPeriod = k_period,
    dPeriod = d_period,
    priceH = aggregatedHigh,
    priceL = aggregatedLow,
    priceC = aggregatedClose,
    averageType = average_type
).SlowK;

def slowD = StochasticSlow(
    kPeriod = k_period,
    dPeriod = d_period,
    priceH = aggregatedHigh,
    priceL = aggregatedLow,
    priceC = aggregatedClose,
    averageType = average_type
).SlowD;

# Define buy signal when SlowK crosses below the oversold level from above
def buySignal = slowK crosses below over_sold;

# Define sell signal when SlowD crosses above the overbought level from below
def sellSignal = slowD crosses above over_bought;

# Place multiple buy orders using the aggregation period, allowing repeated buy signals
AddOrder(OrderType.BUY_AUTO, buySignal, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "StochBuy");

# Place sell orders to close out all open positions when the sell signal is triggered
AddOrder(OrderType.SELL_TO_CLOSE, sellSignal, tickcolor = GetColor(8), arrowcolor = GetColor(8), name = "StochSell");

# Add arrows to chart for visual representation if breakout signals are enabled
AddChartBubble(show_breakout_signals and buySignal, aggregatedLow, "Buy", Color.GREEN, no);
AddChartBubble(show_breakout_signals and sellSignal, aggregatedHigh, "Sell", Color.RED, yes);

# Add label to show current position size
AddLabel(yes, "Position: " + if GetOpenPL() > 0 then "Long" else if GetOpenPL() < 0 then "Short" else "Flat", Color.WHITE);
 
I am building a simple strategy and it works on the daily, 1hr, 15min, and below timeframes but does not show up on the 4hr, weekly, monthly, and above timeframes. I've tried using the aggregateperiod function but to no avail.

Code:
# Stochastic Slow Trading Strategy for Any Time Frame
declare upper;

input over_bought = 80;
input over_sold = 20;
input k_period = 10;
input d_period = 10;
input price_h = high;
input price_l = low;
input price_c = close;
input average_type = AverageType.SIMPLE;
input show_breakout_signals = no;

# Determine the aggregation period of the current chart
def aggregationPeriod = GetAggregationPeriod();

# Calculate High, Low, and Close based on the current aggregation period
def aggregatedHigh = high(period = aggregationPeriod);
def aggregatedLow = low(period = aggregationPeriod);
def aggregatedClose = close(period = aggregationPeriod);

# Calculate the Stochastic Slow using the aggregated data
def slowK = StochasticSlow(
    kPeriod = k_period,
    dPeriod = d_period,
    priceH = aggregatedHigh,
    priceL = aggregatedLow,
    priceC = aggregatedClose,
    averageType = average_type
).SlowK;

def slowD = StochasticSlow(
    kPeriod = k_period,
    dPeriod = d_period,
    priceH = aggregatedHigh,
    priceL = aggregatedLow,
    priceC = aggregatedClose,
    averageType = average_type
).SlowD;

# Define buy signal when SlowK crosses below the oversold level from above
def buySignal = slowK crosses below over_sold;

# Define sell signal when SlowD crosses above the overbought level from below
def sellSignal = slowD crosses above over_bought;

# Place multiple buy orders using the aggregation period, allowing repeated buy signals
AddOrder(OrderType.BUY_AUTO, buySignal, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "StochBuy");

# Place sell orders to close out all open positions when the sell signal is triggered
AddOrder(OrderType.SELL_TO_CLOSE, sellSignal, tickcolor = GetColor(8), arrowcolor = GetColor(8), name = "StochSell");

# Add arrows to chart for visual representation if breakout signals are enabled
AddChartBubble(show_breakout_signals and buySignal, aggregatedLow, "Buy", Color.GREEN, no);
AddChartBubble(show_breakout_signals and sellSignal, aggregatedHigh, "Sell", Color.RED, yes);

# Add label to show current position size
AddLabel(yes, "Position: " + if GetOpenPL() > 0 then "Long" else if GetOpenPL() < 0 then "Short" else "Flat", Color.WHITE);

reply to 279

good on you for trying something, even though the aggregation didn't fix it. that's how i learned, i kept trying things.

set the chart on week,
then on the upper chart, look in the upper left. is there a small white circle with a ! in it.
click on it and it will say portfolio functions don't work with all time periods.

look up portfolio functions
https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio
you have a GetOpenPL() in the last line, in a label.
disable that line and it will work.
 

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
296 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