Couldn't find a working dynamic Risk Reward Ratio study so I decided to make one. This will plot a stop and profit cloud dynamically based on number of shares and entry price. I just used simple percentages and it's only for Long positions but I commented and I'm sure you can adjust the study as you see fit. This uses the portfolio functions and you'll need to have TD turn on "Advanced Features" for it to work for you. Also make sure to turn off "Fit Studies".
Never really contributed to the forums but have gotten so much help and great stuff here, so thank you everyone!
Never really contributed to the forums but have gotten so much help and great stuff here, so thank you everyone!
Rich (BB code):
#digitalml 10/27/2021 v1
input sl_percent = 2.0;
input rr_ratio = 3;
input showClouds = yes;
input showBubbles = yes;
#number of shares of your position
def shares = GetQuantity();
#the price you bought in at
plot entry_price = GetAveragePrice();
#plot the stop price
plot stop = entry_price - (entry_price * (sl_percent / 100));
stop.setdefaultcolor(Color.RED);
stop.setlineweight(1);
#plot the entry price
plot profit = entry_price + ((entry_price * (sl_percent * rr_ratio)) / 100);
profit.setdefaultcolor(Color.GREEN);
profit.setlineweight(1);
#add the clouds
AddCloud(if showClouds then entry_price else Double.NaN, stop, Color.RED, Color.RED);
AddCloud(if showClouds then entry_price else Double.NaN, profit, Color.GREEN, Color.GREEN);