@s1111
Code:
input action = {Default "Long","Short"};
input entry_price = 2.75;
input sl_percent =0.3;
input rr_ratio = 2.0;
input position_size = 2000;
input offset = 5;
def line_plot = IsNaN(close[offset]);
def label_plot = IsNaN(close[offset]) and !IsNaN(close[offset + 1]);
def shares = position_size / entry_price;
plot stop;
switch (action) {
case Long:
stop = if line_plot then round((position_size - (sl_percent * position_size / 100)) / shares)
else double.nan;
Case Short:
stop = if line_plot then round((position_size + (sl_percent * position_size / 100)) / shares)
else double.nan;}
plot entry = if line_plot then entry_price else double.nan;
plot t1 = if line_plot then entry_price + rr_ratio * (entry_price - stop) else double.nan;
plot t2 = if line_plot then entry_price + (2 * rr_ratio) * (entry_price - stop) else double.nan;
plot t3 = if line_plot 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(label_plot, entry_price, entry_price, Color.Light_Gray);
AddChartBubble(label_plot, t1, "T1 $" + t1, Color.GREEN);
AddChartBubble(label_plot, t2, "T2 $" + t2, Color.GREEN);
AddChartBubble(label_plot, t3, "T3 $" + t3, Color.GREEN);
AddChartBubble(label_plot, stop, "STOP $" + stop, Color.RED, no);
Last edited: