chop vs trend strategy help needed..
Forums › ProRealTime English forum › ProBuilder support › chop vs trend strategy help needed..
- This topic has 6 replies, 4 voices, and was last updated 2 days ago by Raj999.
-
-
01/01/2025 at 1:20 PM #242026
Hi all, I am getting error when running this code on thinkorswim with the message as “expected double when decleraing time variable;
declare lower;
# User inputs
input fastLength = 12;
input slowLength = 50;
input endHour = 9;
input endMinute = 30;# Variables for current time
def currentHour = GetHour(); # Retrieves the current hour of the bar
def currentMinute = GetMinute(); # Retrieves the current minute of the bar# Determine premarket status
def isPremarket = if currentHour < endHour or (currentHour == endHour and currentMinute <= endMinute) then 1 else 0;# Variables for premarket high and low
rec premarketHigh = if isPremarket then Max(high, premarketHigh[1]) else premarketHigh[1];
rec premarketLow = if isPremarket then Min(low, premarketLow[1]) else premarketLow[1];# Trend functions
def fastEMA = ExpAverage(close, fastLength);
def slowEMA = ExpAverage(close, slowLength);
def fastEMA_Short = ExpAverage(close, 5);
def slowEMA_Short = ExpAverage(close, 12);def trend1250 = if fastEMA > slowEMA then 1 else -1; # 1 for Bullish, -1 for Bearish
def trend512 = if fastEMA_Short > slowEMA_Short then 1 else -1; # 1 for Bullish, -1 for Bearish# Chop or Trend determination
def chopOrTrend = if close > premarketHigh or close < premarketLow then 1 else 0;
# 1 for Trending, 0 for Chop Range# Price Action Trend
def priceActionTrend =
if chopOrTrend and close > premarketHigh then 1
else if chopOrTrend and close < premarketLow then -1
else 0;
# 1 for Bullish, -1 for Bearish, 0 for Chop Range# Convert numerical conditions to strings for AddLabel
AddLabel(yes,
“Price Action: ” +
(if priceActionTrend == 1 then “Bullish” else if priceActionTrend == -1 then “Bearish” else “Chop Range”),
if priceActionTrend == 1 then Color.GREEN else if priceActionTrend == -1 then Color.RED else Color.ORANGE);AddLabel(yes,
“Ripster Clouds 12/50: ” + (if trend1250 == 1 then “Bullish” else “Bearish”),
if trend1250 == 1 then Color.GREEN else Color.RED);AddLabel(yes,
“Ripster Clouds 5/12: ” + (if trend512 == 1 then “Bullish” else “Bearish”),
if trend512 == 1 then Color.GREEN else Color.RED);# Highlighting premarket levels
plot premarketHighPlot = premarketHigh;
premarketHighPlot.SetDefaultColor(Color.LIGHT_GREEN);
premarketHighPlot.SetStyle(Curve.SHORT_DASH);plot premarketLowPlot = premarketLow;
premarketLowPlot.SetDefaultColor(Color.LIGHT_RED);
premarketLowPlot.SetStyle(Curve.SHORT_DASH);01/01/2025 at 1:30 PM #242027C’est normal ce code n’est pas un code prorealtime.It’s normal this code is not a prorealtime code.
01/01/2025 at 1:52 PM #242028Hi,
Although I don’t know the language, this error message probably means that you are using the wrong data type when declaring the times…
“Double” indicates that you should use a “floating point” (decimal) number and not an integer for assigning “input endHour” and “input endMinute”…
01/01/2025 at 7:13 PM #24204201/01/2025 at 7:28 PM #242043Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
Thanks 🙂
01/01/2025 at 7:39 PM #24204401/01/2025 at 8:03 PM #242047 -
AuthorPosts
Find exclusive trading pro-tools on