How To Fine Tune Scalper's Strategy

Peppermshrimp

New member
VIP
I made over $1,500 today using a Strategy I found here, started on November 25, 2020 by @Learnbot...so I decided that I needed to join the VIP group. Now, I am overwhelmed with the amount of data available. Instead of getting lost in all of the information on the forum, I'd like to continue to work on the strategy @Learnbot and @generic worked out in link I provided above. The problem is that once they figured out the best thinkscript for the strategy, the new code was never posted. I've tried to follow the changes they implemented, but get lost.

My question:
1 - Is the strategy that Learnbot and generic worked out posted somewhere in it's entirety on the forum somewhere?
2 - Is there a list of highest ranked strategies, along with the completed code, somewhere on this site?

Thank you for your help. I look forward to learning more about thinkscript!

Here is the code I used, that I got from the AddOrder thinkScript - Backtest Buy & Sell in ThinkorSwim thread. On November 25, 2020,
https://usethinkscript.com/threads/...buy-sell-in-thinkorswim.741/page-4#post-42428
Learnbot said he/she started with a VIP indicator and made some changes.

Code:
input length = 20;
input trendSetup = 3;

def BodyMax = Max(open, close);
def BodyMin = Min(open, close);
def IsEngulfing = BodyMax > BodyMax[1] and
    BodyMin < BodyMin[1];
def IsWhite = open < close;
def IsBlack = open > close;
def IsPrevDoji = IsDoji(length)[1];

def Bullish = IsDescending(close, trendSetup)[1] and
    (IsBlack[1] or IsPrevDoji) and
    IsWhite and
    IsEngulfing;

def sell_condition = if Bullish then close else sell_condition[1];
def sell_location = (2/100) * sell_condition;

input tradeSize = 100;

def IN = Bullish;
def OUT = sell_condition - sell_location;

AddOrder(OrderType.BUY_TO_OPEN, IN, open[-1], tradeSize, Color.CYAN, Color.CYAN);
AddOrder(OrderType.Sell_TO_CLOSE, OUT, open[-1], tradeSize, Color.CYAN, Color.CYAN);

plot data = OUT;
data.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
data.SetDefaultColor(Color.YELLOW);


mod note:
AddOrder scripts posted to the forum are required to use the open of the NEXT bar: open[-1] for the trade entry and exits. Therefore, the above script has been edited
 
Last edited by a moderator:
Solution
Here is the code I used, that I got from the AddOrder thinkScript - Backtest Buy & Sell in ThinkorSwim thread. On November 25, 2020, Learnbot said he/she started with a VIP indicator and made some changes.

Candle Patterns such as this are favored by scalpers on aggregations of 5min or less.
As a scalper, here are some helpful suggestions of what you might want to add to your chart setup:
https://usethinkscript.com/threads/price-action-toolbox-for-thinkorswim.10747/
REPAINTING ADDORDER SCRIPTS :
Make sure your AddOrder statements are not set to enter or exit on the current candle.
This causes the AddOrder statement to go back to that candle and repaint your entry after the candle closes.
But you can't do that. You can't wait until the horse ran the race and then go back in time and bet on him.

AddOrder scripts must utilize the open of the next candle open[-1] to get accurate P/L results.
As shown here:
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/AddOrder#:~:text=price-,open[-1],-Defines price at

Here is why:
A short-coming of the ToS strategy is that the calculation of P&L results can only be computed after the candle is closed. ToS does not provide the ability to capture inter-candle activity.

The sole method for ToS strategies to accurately compute P&L results is to wait for the current candle to complete its close. There are no alternative approaches! Any other method leads to repainting and misleadingly optimistic outcomes. Despite their appealing appearance, these outcomes are inaccurate.
 
Last edited:
Here is the code I used, that I got from the AddOrder thinkScript - Backtest Buy & Sell in ThinkorSwim thread. On November 25, 2020, Learnbot said he/she started with a VIP indicator and made some changes.

Candle Patterns such as this are favored by scalpers on aggregations of 5min or less.
As a scalper, here are some helpful suggestions of what you might want to add to your chart setup:
https://usethinkscript.com/threads/price-action-toolbox-for-thinkorswim.10747/
 
Last edited:
Solution
IF you're scalping, lagging indicators dont help you much. Tape(including Volume) and more specifically the supply/demand imbalances is the BEST indicator. Most professional scalpers read tape...Yes you can scalp just based on price action on the charts - but is no substitute for tape reading!
 
I really appreciate everyone's comments and willingness to teach me how to trade, however, I am not new to trading, just new to this site and using backtesting on ToS. I've been trading for 45 years, long before internet and charting was available. I don't read tape anymore, T2 data works for me. But thank you for your advice, I am always open to suggestions. I am here to learn more about ToS, and appreciate everyone's expertise and willingness to help in this area.
 
I ran some reports with the code I posted above and realized it wasn't the strategy I had used, but it has taken me this long to figure out exactly which strategy I had used. Following is the correct strategy:

Code:
# MACD Strategy

# V.01.07.2012

#hint: The MACD Strategy uses a MACD to generate Buy and Sell signals.
#          \n In the dafault mode it is always in the #market either Long or Short.
#          \n A Fractal Choppiness Indicator is used to #disable the Buy signal when
#              the equity is in a Choppy Zone.
#          \n Hints are at each variable click on the ? #icon.
#wizard input: n_f
#wizard text: n_f:
#hint n_f: Periods for the Fast EMA.
#wizard input: n_s
#wizard text: n_s:
#hint n_s: Periods for the Slow EMA.
#wizard input: n_n
#wizard text: n_n:
#hint n_n: Period for the Slow EMA Smoothing Function.
#wizard input: SellEndOfDay
#wizard text: SellEndOfDay:
#hint SellEndOfDay: Yes = Postion closed at the end of the day.
#           \n The signal is sent on the opening of the #next bar so make
#              sure to leave enough time for the close to #be carried out.
#wizard input: CloseTime
#wizard text: CloseTime:
#hint CloseTime: Time is Eastern Standard Time.
#wizard input: MinBeforeClose
#wizard text: MinBeforeClose:
#hint MinBeforeClose: Minutes before 1600 when the signal #is assigned.
#         \n The close will actually happen  at the open #of the following bar.
#wizard input: nC
#wizard text: nC:
#hint nC: Periods for the calculation of the Fractal Choppiness Indicator.
#wizard input: nCA
#wizard text: nCA:
#hint nCA: Periods to calculate the Average value for the Fractal Choppiness Indicator.
#wizard input: Choppy
#wizard text: Choppy:
#hint Choppy: Value indicating the beginning of the Choppy #Zone.
#               \n (Usually a value between 50 and 61.8)
#               \n Buy Signals will not be generated in #the Choppy Zone.
#               \n To disable this feature set the Value #at 100.
#wizard input: CIx
#wizard text: CIx:
#hint CIx: CIB uses the Choppiness Indicators (B)ase line #as the signal line.
#                \n CIA uses the (A)verage of the #Choppiness Indicator.

input n_f = 13;
input n_s = 21;
input n_n =  8;
input SellEndOfDay = yes;
input CloseTime = 1600;
input MinBeforeClose = 10;
input nC       = 34;
input nCA      =  8;
input Choppy   = 61.8;
input CIx = {default CIB, CIA};

def o = open;
def h = high;
def l = low;
def c = close;
def Seconds = MinBeforeClose * 60;
def secondsRemained = SecondsTillTime(CloseTime);
def F = (c * .15) +  (.85  * ExpAverage(c, n_f)[1]);
def SS = (c * .075) + (.925 * ExpAverage(c, n_s)[1]);
def MACD   = F - SS;
def MACDSL = ExpAverage(MACD, n_n);
def zero   = 0;

# Fractal Choppiness Indicator

def CIA = 100 * Log( Sum( TrueRange(h, c, l), nC))
               / ( Highest(c[1], nC) - Lowest(c[1], nC))
               / Log(nC);

def CIB = ((Log(Sum(TrueRange(h, c, l), nC) /
              (Highest(if h >= c[1]
                       then h
                       else c[1], nC) - Lowest( if l <= c[1]
                                                then l
                                                else c[1], nC))) / Log(10)) / (Log(nC) / Log(10))) * 100;
def CI = if CIx == CIx.CIB
            then CIB
            else CIA;
def CIavg = Average(CI, nCA);
def ex    = if CIavg > Choppy
               then 1
               else 0;

# Chart Management
AssignPriceColor(if ex == 1
                    then Color.YELLOW
                    else if MACD > 0 and
                            MACD > MACD[1] and
                            MACD[1] > MACD[2]
                         then Color.GREEN
                         else if MACD < 0 and
                                 MACD > MACDSL
                         then Color.GRAY
                         else if MACD crosses above 0
                         then Color.WHITE
                         else if MACD crosses below 0
                         then Color.BLUE
                         else Color.RED);

# Order Management

def buy = ex != 1 and
               ( MACD > MACDSL and
                 MACD > 0 or
                 MACD crosses Lowest(MACD, n_s));
def sell = if SellEndOfDay == yes
              then
                ( secondsRemained >= 0 and
                  secondsRemained <= Seconds
                ) or
                 ( MACD < MACDSL and
                   MACDSL < MACDSL[1] and
                   MACDSL[1] > MACDSL[2]
                 ) or
                   MACD crosses below 0
                   or
                   MACD crosses Highest(MACD, n_s)
             else
                 ( MACD < MACDSL and
                   MACDSL < MACDSL[1] and
                   MACDSL[1] > MACDSL[2]) or
                   MACD crosses below 0 or
                   MACD crosses Highest(MACD, n_s)
              ;

AddOrder(OrderType.BUY_AUTO, condition = buy,
                             price = open[-1],
                             tickcolor = Color. GREEN,
                             arrowcolor = Color.GREEN,
                             name = "BUY");

AddOrder(OrderType.SELL_AUTO, condition = sell,
                              price = open[-1],
                              tickcolor = Color.RED,
                              arrowcolor = Color.RED,
                              name = "SELL");

# End Code


I apologize for any confusion.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Thread starter Similar threads Forum Replies Date
S Lazy Bear - Scalper's Channel Indicator Questions 3
T WRFT Scalper Questions 4
S Scalper's Helper w/ Squeeze For ThinkOrSwim Questions 3

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
405 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