Daily Single Trade [SMRT Algo] for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
GrKwuyy.png


Author Message:

The Daily Single Trade Indicator by SMRT Algo is a powerful yet simple tool designed for traders who value precision, discipline, and a focus on high-quality trade setups. With a unique approach, this indicator identifies just one signal daily, making it ideal for traders who prefer a structured and stress-free trading routine.

More Details: https://www.tradingview.com/v/wbYd0P34/

CODE:

CSS:
#// Indicator for TOS
#// © SMRTAlgo
#indicator('Daily Single Trade [SMRT Algo]', shorttitle='Daily Single Trade [SMRT Algo]', overlay=true)
# Converted by Sam4Cok@Samer800    - 01/2025

input resetSignalPeriod = AggregationPeriod.DAY;
input startTradingTime = 930;     # "Market Open Time Hour"
input signalShape = {Default "Bubbles", "Arrows", "Don't Show"};
input ShowExitPoints = yes;       # "Show Exit Point"
input showTradingLines = yes;
input RiskRewardRatio = 1.75;     # "Risk-Reward Ratio"
input shareSize = 10;

def na = Double.NaN;
def last = isNaN(close);
def arrow = signalShape==signalShape."Arrows";
def bubble = signalShape==signalShape."Bubbles";
def cap = GetAggregationPeriod();
def restTf = Max(cap, resetSignalPeriod);
def reset = if !last then close(Period = restTf) else reset[1];
def specificTime = SecondsFromTime(startTradingTime);
def newDay = reset - reset[1];

def Pip = atr(300) * 0.35;

def myLong; def myShort;
def candle1High; def candle1Low;
def stop_loss; def take_profit;
def tradeExecuted; def entryPrice;
def tradeExecuted1; def entryPrice1;
def tradeDirection; def tradeDirection1; def tradeDirection2;

if newDay {
    tradeExecuted1 = no;
    tradeDirection2 = 0;
    entryPrice1 = na;
} else {
    tradeExecuted1 = tradeExecuted[1];
    tradeDirection2 = tradeDirection[1];
    entryPrice1 = entryPrice[1];
}

if specificTime <= 0 and !tradeExecuted1 {
    stop_loss = na;
    take_profit = na;
    entryPrice = entryPrice1;
    tradeDirection1 = 0;
    tradeExecuted = no;
    candle1High = high;
    candle1Low = low;
    myLong = no;
    myShort = no;
} else if specificTime > 0 and !tradeExecuted1 {
    candle1High = if isNaN(entryPrice1) then high[1] else candle1High[1];
    candle1Low  = if isNaN(entryPrice1) then low[1] else candle1Low[1];
    if close > candle1High {
        entryPrice = open[-1]; #close;
        stop_loss = candle1Low - Pip;
        take_profit = entryPrice + (entryPrice - stop_loss) * RiskRewardRatio;
        tradeDirection1 = 1;
        tradeExecuted = yes;
        myLong = entryPrice;
        myShort = no;
    } else if close < candle1Low {
        entryPrice = open[-1];
        stop_loss = candle1High + Pip;
        take_profit = entryPrice - (stop_loss - entryPrice) * RiskRewardRatio;
        tradeDirection1 = -1;
        tradeExecuted = yes;
        myLong = no;
        myShort = entryPrice;
    } else {
        entryPrice = entryPrice1;
        stop_loss = stop_loss[1];
        take_profit = take_profit[1];
        tradeDirection1 = tradeDirection2;
        tradeExecuted = tradeExecuted1;
        myLong = no;
        myShort = no;
    }
} else {
    entryPrice = entryPrice1;
    candle1High = candle1High[1];
    candle1Low = candle1Low[1];
    stop_loss = stop_loss[1];
    take_profit = take_profit[1];
    tradeDirection1 = tradeDirection2;
    tradeExecuted = tradeExecuted1;
    myLong = no;
    myShort = no;
}
def win;
def earn;
def ExLong; def ExShort;
if tradeDirection1 == 1 {
    ExShort = no;
    if newDay[-1] {
        ExLong = close;
        tradeDirection = 0;
        win = if ExLong > entryPrice then win[1] + 1 else win[1];
        earn = earn[1] + (ExLong - entryPrice) * shareSize;
    } else if  high > take_profit {
        ExLong = take_profit;
        tradeDirection = 0;
        win = win[1] + 1;
        earn = earn[1] + (ExLong - entryPrice) * shareSize;
    } else if close < stop_loss {
        ExLong = close;
        tradeDirection = 0;
        win = win[1];
        earn = earn[1] + (ExLong - entryPrice) * shareSize;
    } else {
    ExLong = no;
    tradeDirection = tradeDirection1;
    win = win[1];
    earn = earn[1];
    }
} else if tradeDirection1 == -1 {
    ExLong = no;
    if newDay[-1] {
        ExShort = close;
        tradeDirection = 0;
        win = if ExShort < entryPrice then win[1] + 1 else win[1];
        earn = earn[1] + (entryPrice - ExShort) * shareSize;
    } else if low < take_profit {
        ExShort = take_profit;
        tradeDirection = 0;
        win = win[1] + 1;
        earn = earn[1] + (entryPrice - ExShort) * shareSize;
    } else if close > stop_loss {
        ExShort = close;
        tradeDirection = 0;
        win = win[1];
        earn = earn[1] + (entryPrice - ExShort) * shareSize;
    } else {
    ExShort = no;
    tradeDirection = tradeDirection1;
    win = win[1];
    earn = earn[1];
    }
} else {
    ExLong = no;
    ExShort = no;
    tradeDirection = tradeDirection1;
    win = win[1];
    earn = earn[1];
}

plot sl = if !last and showTradingLines and tradeDirection[1] and stop_loss[1] then stop_loss[1] else na;
plot tp = if !last and showTradingLines and tradeDirection[1] and take_profit[1] then take_profit[1] else na;
plot ep = if !last and showTradingLines and tradeDirection[1] and entryPrice[1] then entryPrice[1] else na;

ep.SetDefaultColor(Color.GRAY);
sl.SetDefaultColor(Color.RED);
tp.SetDefaultColor(Color.GREEN);

AddCloud(tp, ep, Color.DARK_GREEN, Color.DARK_GREEN);
AddCloud(sl, ep, Color.DARK_RED, Color.DARK_RED);

#-- Signals

plot exitLong = if ShowExitPoints and ExLong then ExLong else na;
plot exitShort = if ShowExitPoints and ExShort then ExShort else na;
plot enterLong = if Arrow and myLong[1] then low else na;
plot enterShort = if Arrow and myShort[1] then high else na;

exitLong.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
exitShort.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
enterLong.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
enterShort.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
exitLong.AssignValueColor(if win!=win[1] then Color.CYAN else Color.MAGENTA);
exitShort.AssignValueColor(if win!=win[1] then Color.CYAN else Color.MAGENTA);
enterLong.SetDefaultColor(Color.CYAN);
enterShort.SetDefaultColor(Color.MAGENTA);

AddChartBubble(bubble and myLong[1], low, AsDollars(myLong[1]), Color.GREEN, no);
AddChartBubble(bubble and myShort[1], high, AsDollars(myShort[1]), Color.RED);


#--
def trades = if myLong then trades[1] + 1 else
             if myShort then trades[1] + 1 else trades[1];
def winPer = win / trades;
AddLabel(1, "Trade(" + trades + ")", Color.WHITE);
AddLabel(1, "WinRate(" + AsPercent(winPer) + ")", if winPer > 0.5 then Color.GREEN else Color.RED);
AddLabel(1, "P/L(" + AsDollars(earn) + ")", if earn > 0 then Color.GREEN else Color.RED);

#-- END of CODE
 

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