This is the complete code the setups are the key ingredients although it can be scripted into one.do you have the complete code for this strategy and perhaps could you forward a screenshot? thx
The script was removed by the author, after further research it turns out it was meaningless and potentially misleading.
Do you mind doing a chart share link? I am getting different results compared to your screenshots. Thanks in advance!I assembled some scripts together so you can get some performance information, must install in TOS as a strategy
The input parameters are setup for 1 Hour time frame
Screen Capture
2023-01-31-TOS_CHARTS - NMQ 1 Hour with stats
#start
input Enable= yes;
# QQE Indicator
# Converted by Kory Gill for BenTen at useThinkScript.com
# Original https://www.tradingview.com/script/zwbe2plA-Ghosty-s-Zero-Line-QQE/
#declare lower;
input RSI_Period = 23;
input Slow_Factor = 11;
input QQE = 4.236;
def Wilder_Period = RSI_Period * 2 - 1;
def vClose = close;
def rsi = RSI(price = vClose, length = RSI_Period).RSI;
def rsi_ma = MovingAverage(AverageType.EXPONENTIAL, rsi, Slow_Factor);
def atr_rsi = AbsValue(rsi_ma[1] - rsi_ma);
def atr_rsi_ma = MovingAverage(AverageType.EXPONENTIAL, atr_rsi, Wilder_Period);
def dar = MovingAverage(AverageType.EXPONENTIAL, atr_rsi_ma, Wilder_Period) * QQE;
def DeltaFastAtrRsi = dar;
def RSIndex = rsi_ma;
def newshortband = RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;
def longband = if RSIndex[1] > longband[1] and RSIndex > longband[1]
then max(longband[1],newlongband)
else newlongband;
def shortband = if RSIndex[1] < shortband[1] and RSIndex < shortband[1]
then min(shortband[1], newshortband)
else newshortband;
def trend = if Crosses(RSIndex, shortband[1])
then 1
else if Crosses(longband[1], RSIndex)
then -1
else if !IsNAN(trend[1])
then trend[1]
else 1;
def FastAtrRsiTL = if trend == 1
then longband
else shortband;
input useorder = yes;
def entryPrice = if trend<>trend[1] then close else entryPrice[1];
plot Qt = entryPrice;
qt.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#qt.SetStyle(Curve.MEDIUM_DASH );
qt.AssignValueColor(if useorder and trend < 0 then Color.red else Color.GREEN);
def abuy = trend<>trend[1] and trend == 1;
def asell = trend<>trend[1] and trend == -1;
AddOrder(OrderType.BUY_AUTO,Enable and useorder and ABuy , tickColor = GetColor(1), arrowColor = GetColor(1), name = "B@ " + open[-1]);
AddOrder(OrderType.SELL_AUTO,Enable and useorder and ASell , tickColor = GetColor(4), arrowColor = GetColor(4), name = "S@ " + open[-1]);
input ShowSignals = yes;
input showLabels = yes;
input showBubbles = yes;
input useStops = no;
############################################
## Create Signals - FILL IN THIS SECTION
############################################
def BuySignal = abuy ; # insert condition to create long position
def SellSignal =asell ; # insert condition to create short position
def BuyStop = if !useStops then 0 else 1 ; # insert condition to stop in place of the 0 after else
def SellStop = if !useStops then 0 else 1 ; # insert condition to stop in place of the 0 after else
input AudibleAlerts = no;
Alert(AudibleAlerts and BuySignal, "QQETMT BuySignal", Alert.BAR, Sound.Ding);
Alert(AudibleAlerts and SellSignal, "QQETMT SellSignal", Alert.BAR, Sound.Ding);
#######################################
## Maintain the position of trades
#######################################
def CurrentPosition; # holds whether flat = 0 long = 1 short = -1
if (BarNumber() == 1) or IsNaN(CurrentPosition[1]) {
CurrentPosition = 0;
} else {
if CurrentPosition[1] == 0 { # FLAT
if (BuySignal) {
CurrentPosition = 1;
} else if (SellSignal) {
CurrentPosition = -1;
} else {
CurrentPosition = CurrentPosition[1];
}
} else if CurrentPosition[1] == 1 { # LONG
if (SellSignal) {
CurrentPosition = -1;
} else if (BuyStop) {
CurrentPosition = 0;
} else {
CurrentPosition = CurrentPosition[1];
}
} else if CurrentPosition[1] == -1 { # SHORT
if (BuySignal) {
CurrentPosition = 1;
} else if (SellStop) {
CurrentPosition = 0;
} else {
CurrentPosition = CurrentPosition[1];
}
} else {
CurrentPosition = CurrentPosition[1];
}
}
def isLong = if CurrentPosition == 1 then 1 else 0;
def isShort = if CurrentPosition == -1 then 1 else 0;
def isFlat = if CurrentPosition == 0 then 1 else 0;
#######################################
## Plot the Signals
#######################################
plot BuySig = if (!isLong[1] and BuySignal and ShowSignals) then 1 else 0;
BuySig.AssignValueColor(Color.YELLOW);
BuySig.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BuySig.SetLineWeight(3);
plot SellSig = if (!isShort[1] and SellSignal and ShowSignals) then 1 else 0;
SellSig.AssignValueColor(Color.WHITE);
SellSig.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
SellSig.SetLineWeight(3);
plot BuyStpSig = if (BuyStop and isLong[1] and ShowSignals) then 1 else 0;
BuyStpSig.AssignValueColor(Color.GRAY);
BuyStpSig.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BuyStpSig.SetLineWeight(3);
plot SellStpSig = if (SellStop and isShort[1] and ShowSignals) then 1 else 0;
SellStpSig.AssignValueColor(Color.GRAY);
SellStpSig.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
SellStpSig.SetLineWeight(3);
#######################################
## Orders
#######################################
def isOrder = if CurrentPosition == CurrentPosition[1] then 0 else 1; # Status changed so it's a new order
def orderPrice = if (isOrder and (BuySignal or SellSignal)) then open[-1] else orderPrice[1];
#######################################
## Price and Profit
#######################################
def profitLoss;
if (!isOrder) {
profitLoss = 0;
} else if ((isOrder and isLong[1]) and (SellSig or BuyStpSig)) {
profitLoss = close - orderPrice[1];
} else if ((isOrder and isShort[1]) and (BuySig or SellStpSig)) {
profitLoss = orderPrice[1] - close;
} else {
profitLoss = 0;
}
def profitLossSum = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder then profitLossSum[1] + profitLoss else profitLossSum[1], 0);
def profitWinners = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder and profitLoss > 0 then profitWinners[1] + 1 else profitWinners[1], 0);
def profitLosers = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder and profitLoss < 0 then profitLosers[1] + 1 else profitLosers[1], 0);
def profitPush = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder and profitLoss == 0 then profitPush[1] + 1 else profitPush[1], 0);
def TradePL = if isLong then Round(((close - orderPrice) / TickSize()) * TickValue()) else if isShort then Round(((orderPrice - close) / TickSize()) * TickValue()) else 0; # current trade p/l
def dollarProfitLoss = Round((profitLoss / TickSize()) * TickValue()); # per trade for chart bubbles
def biggestWin = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder and (dollarProfitLoss > 0) and (dollarProfitLoss > biggestWin[1]) then dollarProfitLoss else biggestWin[1], 0);
def biggestLoss = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder and (dollarProfitLoss < 0) and (dollarProfitLoss < biggestLoss[1]) then dollarProfitLoss else biggestLoss[1], 0);
def orderCount = (profitWinners + profitLosers + profitPush);
def PCTWin = Round((profitWinners / orderCount) * 100, 2);
#######################################
## Create Labels
#######################################
AddLabel(yes, GetSymbol() + " Tick Size: " + TickSize() + " Value: " + TickValue(), Color.WHITE);
AddLabel(showSignals and showLabels, "Orders: " + orderCount + " P/L: " + AsDollars(profitLossSum), if profitLossSum > 0 then Color.GREEN else if profitLossSum < 0 then Color.RED else Color.GRAY);
AddLabel(yes, "Winners: " + PCTWin + "%", if PCTWin > 50 then Color.GREEN else if PCTWin > 40 then Color.YELLOW else Color.GRAY);
AddLabel(yes, "MaxUp: " + AsDollars(biggestWin) + " MaxDown: " + AsDollars(biggestLoss), Color.WHITE);
AddLabel(if !IsNaN(CurrentPosition) then 1 else 0, "Current: " + (if isLong then "Bought" else "Sold") + " @ " + orderPrice, Color.WHITE);
AddLabel(if !IsNaN(orderPrice) then 1 else 0, "Trade P/L: " + AsDollars(TradePL), if (TradePL > 0) then Color.GREEN else if (TradePL < 0) then Color.RED else Color.GRAY);
#######################################
## Chart Bubbles for Profit/Loss
#######################################
AddChartBubble(showSignals and showBubbles and isOrder and isLong[1], low, "$" + dollarProfitLoss, if dollarProfitLoss == 0 then Color.LIGHT_GRAY else if dollarProfitLoss > 0 then Color.GREEN else Color.RED, 1);
AddChartBubble(showSignals and showBubbles and isOrder and isShort[1], high, "$" + dollarProfitLoss, if dollarProfitLoss == 0 then Color.LIGHT_GRAY else if dollarProfitLoss > 0 then Color.GREEN else Color.RED, 0);
#End
2023-01-31-TOS_CHARTS - NMQ 1 Hour with stats
Could you share a screenshot with your results?Do you mind doing a chart share link? I am getting different results compared to your screenshots. Thanks in advance!
I got it to work! Thank you!Could you share a screenshot with your results?
The script was removed by the author, after further research it turns out it was meaningless and potentially misleading.I got it to work! Thank you!
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.