any help with coding something like this would be greatly appreciated
i daytrade, Scalp for most part on the 1m/3m/15m options
i daytrade, Scalp for most part on the 1m/3m/15m options
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
input TakeProfitPct = 15;
input TakeProfitPct2 = 30;
input StopLossPct = 10;
def Qty = GetQuantity();
def Prc = GetAveragePrice();
Plot Trade = If Prc > 0 then Prc else double.Nan;
Trade.SetStyle(Curve.SHORT_DASH);
Trade.AssignValueColor(color.green);
Plot TP = if Qty > 0 then Prc + (Prc * (TakeProfitPct/100)) else double.Nan;
TP.SetStyle(Curve.SHORT_DASH);
TP.AssignValueColor(color.yellow);
Plot TP2 = if Qty > 0 then Prc + (Prc * (TakeProfitPct2/100)) else double.Nan;
TP2.SetStyle(Curve.SHORT_DASH);
TP2.AssignValueColor(color.blue);
Plot SL = if Qty > 0 then Prc - (Prc * (StopLossPct/100)) else double.Nan;
SL.SetStyle(Curve.SHORT_DASH);
SL.AssignValueColor(color.red);
AddLabel(Trade > 0, "Risk: "+ asDollars(round(Qty*Prc)), color.white);
AddLabel(Trade > 0, "Shares: "+Qty, color.gray);
AddLabel(Trade > 0, "Entry: "+Trade, color.green);
AddLabel(Trade > 0, "Stop: "+SL, color.red);
AddLabel(Trade > 0, "Target: "+TP, color.yellow);
AddLabel(Trade > 0, "Target: "+TP2, color.blue);
Hi,
I would like to have the ATR added to my entry price and show as a target in the chart
Any idea how I can do that??
Thank you so much for your help!
#Entries & Targets
#@JoeDV 2/23/22
#edited @merryday 3/20/22 to use ATR as target #requested by wam1234
input profit_mult = 1 ;
def Qty = GetQuantity();
def Prc = GetAveragePrice();
def ATR = reference ATR();
Plot Trade = If Prc > 0 then Prc else double.Nan;
Trade.SetStyle(Curve.SHORT_DASH);
Trade.SetDefaultColor(color.green);
Trade.SetLineWeight(2);
Plot TP = if Qty > 0 then Prc + (ATR* profit_mult) else double.Nan;
TP.SetStyle(Curve.SHORT_DASH);
TP.SetDefaultColor(color.yellow);
TP.SetLineWeight(2);
AddLabel(Trade > 0, "Risk: "+ asDollars(round(Qty*Prc)), color.white);
AddLabel(Trade > 0, "Shares: "+Qty, color.orange);
AddLabel(Trade > 0, "Entry: "+round(Trade,2), color.green);
AddLabel(Trade > 0, "ATR: "+round(ATR,2), color.pink);
AddLabel(Trade > 0, "Target: "+round(TP,2), color.yellow);
This script doesn't take the current stock price into account. Reflects nothing as to profit or loss.Been looking around to find this particular code but unable to find it in the forum.
What I am looking for is a label that shows:
The current price and the distance from the EMA (using the 20ema on 1min). So basically if my entry was lets say $26.00, and the 20EMA is at $25, the label will display it is 1.00 away from the entry price. It will show red. When the EMA is over the entry price, it will turn green on the label once it hits above the avg. entry share price.
#Entries & Targets
#@JoeDV 2/23/22
#edited @merryday 3/23/22 to use EMA as target #requested by pipmonster
input emaLength = 20 ;
def Qty = GetQuantity();
def Prc = GetAveragePrice();
def EMA = MovAvgExponential("length" = emaLength)."AvgExp" ;
Plot Trade = If Prc > 0 then Prc else double.Nan;
Trade.SetStyle(Curve.SHORT_DASH);
Trade.SetDefaultColor(color.blue);
Trade.SetLineWeight(2);
Plot TP = if Qty > 0 then EMA else double.Nan;
TP.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
TP.SetDefaultColor(color.yellow);
TP.SetLineWeight(2);
def distance = TP - Trade ;
AddLabel(Trade > 0, "Risk: "+ asDollars(round(Qty*Prc)), color.white);
AddLabel(Trade > 0, "Shares: "+Qty, color.orange);
AddLabel(Trade > 0, "Entry: "+round(Trade,2), color.green);
AddLabel(Trade > 0, "EMA: "+round(EMA,2), color.pink);
AddLabel(Trade > 0, "Distance from EMA: " +AsDollars(distance),
if distance > 0 then color.green else color.red);
#Entries & Targets
#@JoeDV 2/23/22
#edited @merryday 3/23/22 to use EMA as target #requested by pipmonster
input emaLength = 20 ;
def Qty = GetQuantity();
def Prc = GetAveragePrice();
def EMA = MovAvgExponential("length" = emaLength)."AvgExp" ;
Plot Trade = If Prc > 0 then Prc else double.Nan;
Trade.SetStyle(Curve.SHORT_DASH);
Trade.SetDefaultColor(color.blue);
Trade.SetLineWeight(2);
Plot TP = if Qty > 0 then EMA else double.Nan;
TP.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
TP.SetDefaultColor(color.yellow);
TP.SetLineWeight(2);
def distance = TP - Trade ;
AddLabel(Trade > 0, "Risk: "+ asDollars(round(Qty*Prc)), color.white);
AddLabel(Trade > 0, "Shares: "+Qty, color.orange);
AddLabel(Trade > 0, "Entry: "+round(Trade,2), color.green);
AddLabel(Trade > 0, "EMA: "+round(EMA,2), color.pink);
AddLabel(Trade > 0, "Distance from EMA: " +AsDollars(distance),
if distance > 0 then color.green else color.red);
This script https://usethinkscript.com/threads/entries-and-target-for-thinkorswim.10302/#post-94080 provides you the distance to ema.I also wanted to mention the code didn't work in onDemand function in TOS. Will it only work during the live market?
I guess help me understand what part of the process doesn't make sense? TOS wouldn't be able to tell you the distance from your entry price to the EMA?
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.