Last edited by a moderator:
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
input amount = 2000;
input risk = 100;
input price = 2.75;
input ratio = 2;
def shares = amount / price;
plot stop = if isnan(close[-1]) then round((amount - risk) / shares) else double.nan;
plot entry = if isnan(close[-1]) then price else double.nan;
plot t1 = if isnan(close[-1]) then price + ratio * (price - stop) else double.nan;
plot t2 = if isnan(close[-1]) then price + (2 * ratio) * (price - stop) else double.nan;
plot t3 = if isnan(close[-1]) then price + (3 * ratio) * (price - stop) else double.nan;
addcloud(price, stop, color.gray, color.gray);
addcloud(t1, t2, color.green, color.green);
addcloud(t2, t3, color.light_green, color.light_green);
addchartbubble(isnan(close[2]) and !isnan(close[3]), price, price, color.white);
addchartbubble(isnan(close[2]) and !isnan(close[3]), t1, "T1 $" + t1, color.green);
addchartbubble(isnan(close[2]) and !isnan(close[3]), t2, "T2 $" + t2, color.green);
addchartbubble(isnan(close[2]) and !isnan(close[3]), t3, "T3 $" + t3, color.green);
addchartbubble(isnan(close[2]) and !isnan(close[3]), stop, "STOP $" + stop, color.red, no);
addchartbubble(isnan(close[10]) and !isnan(close[11]), price, "SHARES:" + floor(shares), color.yellow);
input action = {Default "Long","Short"};
input entry_price = 2.75;
input sl_percent = 2.0;
input rr_ratio = 2;
input position_size = 2000;
def shares = position_size / entry_price;
plot stop;
switch (action) {
case Long:
stop = if isnan(close[-1]) then round((position_size - (sl_percent * position_size / 100)) / shares)
else double.nan;
Case Short:
stop = if isnan(close[-1]) then round((position_size + (sl_percent * position_size / 100)) / shares)
else double.nan;}
plot entry = if isnan(close[-1]) then entry_price else double.nan;
plot t1 = if isnan(close[-1]) then entry_price + rr_ratio * (entry_price - stop) else double.nan;
plot t2 = if isnan(close[-1]) then entry_price + (2 * rr_ratio) * (entry_price - stop) else double.nan;
plot t3 = if isnan(close[-1]) then entry_price + (3 * rr_ratio) * (entry_price - stop) else double.nan;
AddCloud(entry_price, stop, Color.GRAY, Color.GRAY);
AddCloud(t1, t2, Color.GREEN, Color.GREEN);
AddCloud(t2, t3, Color.LIGHT_GREEN, Color.LIGHT_GREEN);
AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), entry_price, entry_price, Color.WHITE);
AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), t1, "T1 $" + t1, Color.GREEN);
AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), t2, "T2 $" + t2, Color.GREEN);
AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), t3, "T3 $" + t3, Color.GREEN);
AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), stop, "STOP $" + stop, Color.RED, no);
AddChartBubble(IsNaN(close[10]) and !IsNaN(close[11]), entry_price, "SHARES:" + Floor(shares), Color.YELLOW);
I thought it was supposed to act as price lines, where you click&drag to move them.
This one I have to manually change entry price if I wanna slide the whole study up / down.
Thank you for this. What is t1, t2, t3??I had modified the codes contributed by "Generic" to allow for Long and Short trade
Code:input action = {Default "Long","Short"}; input price = 2.75; input amount = 2000; input risk = 100; input ratio = 2; def shares = Floor(amount / price); plot stop; switch (action) { case Long: stop = if isnan(close[-1]) then round((amount - risk) / shares) else double.nan; Case Short: stop = if isnan(close[-1]) then round((amount + risk) / shares) else double.nan;} plot entry = if isnan(close[-1]) then price else double.nan; plot t1 = if isnan(close[-1]) then price + ratio * (price - stop) else double.nan; plot t2 = if isnan(close[-1]) then price + (2 * ratio) * (price - stop) else double.nan; plot t3 = if isnan(close[-1]) then price + (3 * ratio) * (price - stop) else double.nan; AddCloud(price, stop, Color.GRAY, Color.GRAY); AddCloud(t1, t2, Color.GREEN, Color.GREEN); AddCloud(t2, t3, Color.LIGHT_GREEN, Color.LIGHT_GREEN); AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), price, price, Color.WHITE); AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), t1, "T1 $" + t1, Color.GREEN); AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), t2, "T2 $" + t2, Color.GREEN); AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), t3, "T3 $" + t3, Color.GREEN); AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), stop, "STOP $" + stop, Color.RED, no); AddChartBubble(IsNaN(close[10]) and !IsNaN(close[11]), price, "SHARES:" + shares, Color.YELLOW);
It's not plotting anything for me except for the entry line, that's why I asked.@stamenski They're targets based on risk to reward ratio.
@otterflips You don't need to be in a trade but you do need to manually input your entry.
Nah please don't take it the wrong way, I love the idea of the indicator and what it can accomplish. It's just on TSLA when I plugged in entry price it only displayed my entry price, and I had to set the "amount" to 20,000 to be able to see the targets, I could completely be doing it wrong. But it's the only way I could find the targets/stop displayed on my chart. Not sure what the issue was. Any idea? + if it's set for Tesla and I flip to another ticker and change the entry price, it's gone again. I was just curious what I was doing wrong.@otterflips What ticker were you looking at? I think the point of this indicator is to have the freedom of manual inputs but I can make some changes when I have time. Lmk know what you're looking for and I'll try to adjust it.
input action = {Default "Long","Short"};
input entry_price = 2.75;
input sl_percent = 2.0;
input rr_ratio = 2;
input position_size = 2000;
def shares = position_size / entry_price;
plot stop;
switch (action) {
case Long:
stop = if isnan(close[-1]) then round((position_size - (sl_percent * position_size / 100)) / shares)
else double.nan;
Case Short:
stop = if isnan(close[-1]) then round((position_size + (sl_percent * position_size / 100)) / shares)
else double.nan;}
plot entry = if isnan(close[-1]) then entry_price else double.nan;
plot t1 = if isnan(close[-1]) then entry_price + rr_ratio * (entry_price - stop) else double.nan;
plot t2 = if isnan(close[-1]) then entry_price + (2 * rr_ratio) * (entry_price - stop) else double.nan;
plot t3 = if isnan(close[-1]) then entry_price + (3 * rr_ratio) * (entry_price - stop) else double.nan;
AddCloud(entry_price, stop, Color.GRAY, Color.GRAY);
AddCloud(t1, t2, Color.GREEN, Color.GREEN);
AddCloud(t2, t3, Color.LIGHT_GREEN, Color.LIGHT_GREEN);
AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), entry_price, entry_price, Color.WHITE);
AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), t1, "T1 $" + t1, Color.GREEN);
AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), t2, "T2 $" + t2, Color.GREEN);
AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), t3, "T3 $" + t3, Color.GREEN);
AddChartBubble(IsNaN(close[2]) and !IsNaN(close[3]), stop, "STOP $" + stop, Color.RED, no);
AddChartBubble(IsNaN(close[10]) and !IsNaN(close[11]), entry_price, "SHARES:" + Floor(shares), Color.YELLOW);
No u don't have to enter the trade. You can keep it in your chart studies and unclick show plot. then when u do have a chart that you want to plot the RR then you click the show plot and enter the info. A floating one would be cool.Do you have to enter a trade to have the targets generated? Can we get one that's "floating" and doesn't require an entry to plot please?
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
ATR Risk Control Indicator for ThinkorSwim | Indicators | 14 | ||
Repaints Cup and Handle Indicator for ThinkorSwim | Indicators | 23 | ||
The Ultimate Buy and Sell Indicator for ThinkOrSwim | Indicators | 5 | ||
S | SharkWaveTrend For ThinkOrSwim | Indicators | 44 | |
Repaints Smart Money Breakouts [ChartPrime] for ThinkOrSwim | Indicators | 15 |
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.