ITG Scalper For ThinkOrSwim

check the below

CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0
#// © Complector
#// *** ITG Scalper by Complector
#// *** Thanks to Iain M. Banks for making my life richer :-)
#study(shorttitle="ITG_Scalper", title="ITG Scalper Buy/Sell [Complector]", overlay=true)
# Converted by Sam4Cok@Samer800     - 10/2023

input ShowMovAvgLine = yes;                  # "Plot TEMA?"
input changeTrendColor = yes;                # "Green/redshift on/off?")  // Trend color change?
input showPriceValue = no;                   # "Show buy/sell?")  // Show buy & sell signals?
input showSignals = {Default "Bubbles", "Arrows", "Don't Show Signals"};
input showChangeSinceLastSignal = no;        # "Show % change since last buy/sell"
input enableNoiseFilter = yes;               # "Noise filter on/off?"
input useCurrentTimeframe = yes;             # "Use Current Chart Resolution for filter?"
input resCustom = AggregationPeriod.HOUR;    # "Use Different Timeframe for filter? Uncheck Box Above"
input movingAvgLength  = 14;                 # "TEMA period"
input filterFastLength = 12;                 # "Filter fast length"
input filterSlowLength = 26;                 # "Filter slow length"
input filterSignalLength = 9;                # "Filter signal length"

def na = Double.NaN;
def Arrow = showSignals==showSignals."Arrows";
def bubble = showSignals==showSignals."Bubbles";
def sigChange = showChangeSinceLastSignal;
#//Get real close price
def realC = close(GetSymbol());
def isconfirmed = !isNaN(Close);
#/Truncate function used for rounding variables
Script truncate {
input number = 0;
input decimals = 1;
    def factor = power(10, decimals);
    def truncate = floor(number * factor) / factor;
    plot out = truncate;
}
#//Triple EMA definition
def ema1 = ExpAverage(realC, movingAvgLength);
def ema2 = ExpAverage(ema1, movingAvgLength);
def ema3 = ExpAverage(ema2, movingAvgLength);
#//Triple EMA trend calculation
def avg = 3 * (ema1 - ema2) + ema3;
def out = avg;
def out1 = out;#security(t_id, timeframe.period, out)
def ma_up = out1 >= out1[1];
def ma_down = out1 < out1[1];
def col = if changeTrendColor then if ma_up then 1 else
                                    if ma_down then -1 else 1 else 0;
def t_UP = ma_up;
def t_DOWN = ma_down;
def t_NON = t_UP == t_DOWN;
#//Filter formula
def Fsource =  close(GetSymbol());
def FsourceMTF =  close(GetSymbol(), Period = resCustom);
def macd_colorChange = yes;
def Fres = if useCurrentTimeframe then Fsource else FsourceMTF;
def FfastMA = ExpAverage(Fres, filterFastLength);
def FslowMA = ExpAverage(Fres, filterSlowLength);
def Fmacd = FfastMA - FslowMA;
def Fsignal = Average(Fmacd, filterSignalLength);
def outMacD = Fmacd;
def outSignal = Fsignal;
def Fbuy = (outMacD >= outSignal) or !enableNoiseFilter;
def Fsell = (outMacD < outSignal) or !enableNoiseFilter;

#//Triple EMA plot

plot TEMA = if ShowMovAvgLine then out1 else na;    # "TEMA"
TEMA.AssignValueColor(if col > 0 then Color.GREEN else
                      if col < 0 then Color.RED else Color.CYAN);
#//Entry & exit conditions
def buyprice;def sellprice;def last_tran;

def long  = t_UP and !last_tran[1] and !t_NON and Fbuy and isconfirmed;
def short = t_DOWN and last_tran[1] and !t_NON and Fsell and isconfirmed;

if long {
    buyprice  = realC;
    sellprice = sellprice[1];
    last_tran = yes;
    } else if short {
    buyprice = buyprice[1];
    sellprice = realC;
    last_tran = no;
    } else {
    buyprice = buyprice[1];
    sellprice = sellprice[1];
    last_tran = last_tran[1];
}
def goodlong = long and buyprice <= sellprice;     # // Buying with a profit?
def goodshort = short and sellprice > buyprice;    # // Selling with a profit?
def PercVal = if(last_tran, 100 * (realC - buyprice)/buyprice, 100 * (realC - sellprice)/sellprice);
def PercCol = PercVal >= 0;#, color.lime, color.orange);
#//Plot percent label

AddLabel(sigChange, truncate(PercVal,2) + " %", if PercCol then Color.LIGHT_GREEN else Color.PINK);

#/ Alternative 2: Plot buy/sell signals as plotshape without price indication. No max.
def buytxt  = truncate(buyprice,8);
def selltxt = truncate(sellprice,8);

plot priceUp = if Arrow and long then low else na;
plot priceDn = if Arrow and short then high else na;
priceUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
priceDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);


AddChartBubble(bubble and long, low,if showPriceValue then "B\n$"+buytxt else "B", if goodlong then Color.GREEN else Color.YELLOW, no);
AddChartBubble(bubble and short, high,if showPriceValue then  "S\n$"+selltxt else "S", if goodshort then Color.RED else Color.YELLOW);


#-- END of CODE
 
Last edited by a moderator:
check the below

CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0
#// © Complector
#// *** ITG Scalper by Complector
#// *** Thanks to Iain M. Banks for making my life richer :-)
#study(shorttitle="ITG_Scalper", title="ITG Scalper Buy/Sell [Complector]", overlay=true)
# Converted by Sam4Cok@Samer800     - 10/2023

input ShowMovAvgLine = yes;                  # "Plot TEMA?"
input changeTrendColor = yes;                # "Green/redshift on/off?")  // Trend color change?
input showPriceValue = no;                   # "Show buy/sell?")  // Show buy & sell signals?
input showSignals = {Default "Bubbles", "Arrows", "Don't Show Signals"};
input showChangeSinceLastSignal = no;        # "Show % change since last buy/sell"
input enableNoiseFilter = yes;               # "Noise filter on/off?"
input useCurrentTimeframe = yes;             # "Use Current Chart Resolution for filter?"
input resCustom = AggregationPeriod.HOUR;    # "Use Different Timeframe for filter? Uncheck Box Above"
input movingAvgLength  = 14;                 # "TEMA period"
input filterFastLength = 12;                 # "Filter fast length"
input filterSlowLength = 26;                 # "Filter slow length"
input filterSignalLength = 9;                # "Filter signal length"

def na = Double.NaN;
def Arrow = showSignals==showSignals."Arrows";
def bubble = showSignals==showSignals."Bubbles";
def sigChange = showChangeSinceLastSignal;
#//Get real close price
def realC = close(GetSymbol());
def isconfirmed = !isNaN(Close);
#/Truncate function used for rounding variables
Script truncate {
input number = 0;
input decimals = 1;
    def factor = power(10, decimals);
    def truncate = floor(number * factor) / factor;
    plot out = truncate;
}
#//Triple EMA definition
def ema1 = ExpAverage(realC, movingAvgLength);
def ema2 = ExpAverage(ema1, movingAvgLength);
def ema3 = ExpAverage(ema2, movingAvgLength);
#//Triple EMA trend calculation
def avg = 3 * (ema1 - ema2) + ema3;
def out = avg;
def out1 = out;#security(t_id, timeframe.period, out)
def ma_up = out1 >= out1[1];
def ma_down = out1 < out1[1];
def col = if changeTrendColor then if ma_up then 1 else
                                    if ma_down then -1 else 1 else 0;
def t_UP = ma_up;
def t_DOWN = ma_down;
def t_NON = t_UP == t_DOWN;
#//Filter formula
def Fsource =  close(GetSymbol());
def FsourceMTF =  close(GetSymbol(), Period = resCustom);
def macd_colorChange = yes;
def Fres = if useCurrentTimeframe then Fsource else FsourceMTF;
def FfastMA = ExpAverage(Fres, filterFastLength);
def FslowMA = ExpAverage(Fres, filterSlowLength);
def Fmacd = FfastMA - FslowMA;
def Fsignal = Average(Fmacd, filterSignalLength);
def outMacD = Fmacd;
def outSignal = Fsignal;
def Fbuy = (outMacD >= outSignal) or !enableNoiseFilter;
def Fsell = (outMacD < outSignal) or !enableNoiseFilter;

#//Triple EMA plot

plot TEMA = if ShowMovAvgLine then out1 else na;    # "TEMA"
TEMA.AssignValueColor(if col > 0 then Color.GREEN else
                      if col < 0 then Color.RED else Color.CYAN);
#//Entry & exit conditions
def buyprice;def sellprice;def last_tran;

def long  = t_UP and !last_tran[1] and !t_NON and Fbuy and isconfirmed;
def short = t_DOWN and last_tran[1] and !t_NON and Fsell and isconfirmed;

if long {
    buyprice  = realC;
    sellprice = sellprice[1];
    last_tran = yes;
    } else if short {
    buyprice = buyprice[1];
    sellprice = realC;
    last_tran = no;
    } else {
    buyprice = buyprice[1];
    sellprice = sellprice[1];
    last_tran = last_tran[1];
}
def goodlong = long and buyprice <= sellprice;     # // Buying with a profit?
def goodshort = short and sellprice > buyprice;    # // Selling with a profit?
def PercVal = if(last_tran, 100 * (realC - buyprice)/buyprice, 100 * (realC - sellprice)/sellprice);
def PercCol = PercVal >= 0;#, color.lime, color.orange);
#//Plot percent label

AddLabel(sigChange, truncate(PercVal,2) + " %", if PercCol then Color.LIGHT_GREEN else Color.PINK);

#/ Alternative 2: Plot buy/sell signals as plotshape without price indication. No max.
def buytxt  = truncate(buyprice,8);
def selltxt = truncate(sellprice,8);

plot priceUp = if Arrow and long then low else na;
plot priceDn = if Arrow and short then high else na;
priceUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
priceDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);


AddChartBubble(bubble and long, low,if showPriceValue then "B\n$"+buytxt else "B", if goodlong then Color.GREEN else Color.YELLOW, no);
AddChartBubble(bubble and short, high,if showPriceValue then  "S\n$"+selltxt else "S", if goodshort then Color.RED else Color.YELLOW);


#-- END of CODE
Thanks samer800
 

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