rudy seena
New member
Hi, I copied and pasted in TOS but nothing happens? Any suggestions?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
#
# PositionSizingCalculator
#
# Author: Kory Gill, [USER=212]@korygill[/USER]
## thanks to Kory Gill for this
## Jon Yadon added this ATR so you can adjust your atr mutliplier
input RiskUnit = 100;
input multiplier = 2;
input ATRLength = 14;
input averagetype = AverageType.WILDERS;
input BasePeriod = AggregationPeriod.DAY;
input showlabel = yes;
def ATR = MovingAverage (averagetype, TrueRange(high(period = BasePeriod)[1], close(period = BasePeriod)[1], low(period = BasePeriod)[1]), ATRLength);
def Today_High = Highest(high(period = BasePeriod)[0], 1);
def Today_Low = Lowest(low(period = BasePeriod)[0], 1);
def stoploss = ATR * multiplier;
AddLabel(
yes,
AsDollars(RiskUnit) + " risk with " + AsDollars(stoploss) + " stop = " + Floor(Round(RiskUnit / stoploss)) + " shares",
Color.GRAY
);
AddLabel(
yes,
"High: " + Today_High + " Low: " + Today_Low,
Color.GRAY
);
Opinion: Wondering why you aren't using a percentage of the trade with a trail stop,......if you identify a set up, place an anticipation entry using a stop limit, enter the trade early, place .20-.30-.50, whatever trailstop, set it and look for the next set up....This morning I executed a trade with a $.04 stop. Unfortunately, the trade turned against me and I was stopped out. While I was in the position, the stock wasn't volatile at all. No surges and no flash crashes. Despite that, when I was stopped out, my P/L showed a loss that was twice what it should have been based on what I entered into the Active Trader order entry window.
When I went back to review my order, it showed that a $.08 stop loss was submitted. For a moment I thought that I may have made a typo. I knew this was highly unlikely though, because I use a position sizer that automatically calculates my share size, limit offset, stop offset and entry price based on my max risk per trade. All I have to do is type what the tool calculates into the Active Trader Ladder. But even still, it's possible that I could make a typo.
After reviewing the trade execution details under the Monitor tab, I went back to my chart to review the Active Trader Ladder. And what do you know... My stop offset was indeed set to $.04. Since I hadn't taken any additional trades after this loss, it would be impossible for the stop offset to be set to $.04 if that wasn't what I submitted in my order.
After reviewing all of this I got on chat with TD Ameritrade to explain what happened, and of course... The said that there is nothing they can do to credit my account since there's no way for them to verify that an error was made on their behalf.
I'm really concerned about trading with Thinkorswim now, and I am only going to continue trading with them while video recording my screen during all trading sessions. Had I had that proof, I could have gotten them to credit my account for the $.04 difference (slippage) in the Stop loss they executed vs. what I submitted multiplied by the number of shares I purchased.
Thankfully, I was trading with a small risk/trade, so even though my loss was doubled, I didn't blow up my account or have a major setback.
Please, please, please protect yourself. There are several free screen recording programs you can use. I'm using Debut by NCH. They have a 30 day free trial, and then after 30 days it's still free, but it has a watermark on it, which doesn't really matter, since I won't be posting these videos publicly anywhere.
Kory,...whatever is a better fill, I'd prefer limit, but you are right, a market order on the open as early in the trade as possible, you want in early....but it's really a visual entry if identified early with some elbow grease, monitor the candle, place the trail stop........if you're in, fine, you miss it, look for the next set up......but entry as early as possible is secret.@Thomas doesn't a stop order turn into a market order when the condition is hit? you'd have to have the price ladder at that time to see what was on the book at the time for various exchanges. TD sells your orderflow anyway, so quite possible the market makers just pulled some orders off the books, or executed ahead of you (front running). That would be my guess. I've see the bots sweep the book just to run stops, and if your order was not 1st in line, you are executing after others may have been selling/buying current liquidity. ****s for sure...
#Simple_ScaleIn_Label
#Pensar, 6/10/2020
input max_size = 100000.00;
input scale_in = yes;
input times_to_scale_in = 4;
def Size = if !scale_in then (max_size / close) else
(max_size / times_to_scale_in) / close;
AddLabel(1, (if scale_in then "Scale In: " else "") + "Buy " + RoundDown(Size, 0) + " shares" + (if scale_in then " " + times_to_scale_in + " times" else "") + " --- Total Trade Size: " + AsDollars(max_size), color.white);
#End code
HiHey, does the script let you plot entry stop, target and calculate the shares based on dollar risk amount ?
#
# PositionSizingCalculator
#
# Author: RamonDV. AKA Pelonsax
#
#
input Risk_Amount = 100;
input Shares = 1000;
input Stop_Price = 100.00;
input Choose_Size_and_Risk = yes; #can't choose stop
input Choose_Size_and_Stop = yes; #can't choose risk
input Choose_Risk_and_Stop = yes; #can't choose size
def Mark = close(PriceType = PriceType.MARK);
def Size = Risk_Amount / (Mark - Stop_Price);
def Stop = ((Mark * Shares) - Risk_Amount) / Shares;
def Risk = (mark - Stop_Price) * Shares;
#Display current price
AddLabel(yes, "Current Price: " + AsDollars(Mark), color.gray);
#No defined stop
AddLabel(Choose_Size_and_Risk, "No defined stop: " + Shares + " Shares with " + AsDollars(Risk_Amount) + " risk with Stop Loss at " + AsDollars(stop) + " .", color.gray);
#No defined risk
AddLabel(Choose_Size_and_Stop, "No Defined risk: " + Shares + " Shares with " + AsDollars(risk) + " risk with Stop Loss at " + AsDollars(Stop_Price) + " .", color.gray);
#No defined size
AddLabel(Choose_Risk_and_Stop, "No defined size: " + Floor(Round(size)) + " Shares with " + AsDollars(Risk_Amount) + " risk with Stop Loss at " + AsDollars(Stop_Price) + " .", color.gray);
########################################
input capital_size = 25000;
input risk_percent = 1;
def risk_price = close;
def risk_percent_calc = risk_percent / 100;
def entry_stop_bull = (risk_price - bullstop);
def entry_stop_bear = (bearstop - risk_price);
def units_to_buy_bull = (risk_percent_calc * capital_size) / (entry_stop_bull) / risk_price;
def units_to_buy_bull1 = RoundDown(units_to_buy_bull,0);
def total_cost_bull = units_to_buy_bull1 * risk_price;
def units_to_buy_bear = (risk_percent_calc * capital_size) / (entry_stop_bear) / risk_price;
def units_to_buy_bear1 = RoundDown(units_to_buy_bear,0);
########################################
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.