Goingdark365
Member
*correctly
Hey guys I created a strategy trying to exit entryprice() +-3, I’m using this on /es and Range chart
Problem I’m having is it closes the trade on next candle when triggered, or sometimes completely misses
Any work around that you guys can recommend??
I plotted the target with red horizontal and stop with red horizontal sometimes its close but not always
here is one completely missed target and got stopped
Hey guys I created a strategy trying to exit entryprice() +-3, I’m using this on /es and Range chart
Problem I’m having is it closes the trade on next candle when triggered, or sometimes completely misses
Any work around that you guys can recommend??
I plotted the target with red horizontal and stop with red horizontal sometimes its close but not always
here is one completely missed target and got stopped
Code:
def h = high ;
def l = low;
def c = close ;
def o = open ;
def v = volume;
def down = h <= h[1] and l < l[1];
def down_green = down and c > o;
def rvol_Type = AverageType.SIMPLE;
input RVol_length = 10 ;
def AvgVol = MovingAverage(rvol_Type, v, RVol_length);
def CurrentToAvg = Round(v / AvgVol);
def rv1 = 1.6;
def rv2 = 2.0;
def rv3 = 2.6;
def displace = 0;
def length = 20;
def Num_Dev_Dn = -2.0;
def Num_Dev_up = 2.0;
def averageType = AverageType.Simple;
def sDev = stdev(data = c[-displace], length = length);
def MidLine = MovingAverage(averageType, data = c[-displace], length = length);
def LowerBand = MidLine + num_Dev_Dn * sDev;
def UpperBand = MidLine + num_Dev_Up * sDev;
input target = 3;
input stop = 3;
input qty = 1;
def LE = down_green and CurrentToAvg > rv2 and low < lowerband;
def lpt = close crosses entryprice() + target;
def stp = close crosses entryprice() - stop;
def longtargetx = if LE then close + target else 0;
plot longtargetxx = longtargetx;
longtargetxx.SetDefaultColor(Color.green);
longtargetxx.SetPaintingStrategy(PaintingStrategy.hoRIZONTAL);
def longstopx = if LE then close - STOP else 0 ;
plot longstopxx = longstopx;
longstopxx.SetDefaultColor(Color.light_RED);
longstopxx.SetPaintingStrategy(PaintingStrategy.hoRIZONTAL);
addOrder(OrderType.buy_TO_OPEN, le, tickColor = GetColor(0), name = ";LE;", arrowColor = color.cyan);
AddOrder(OrderType.SELL_TO_CLOSE, lpt, tradeSize = qty, name = ";LPT;",arrowColor = color.green);
AddOrder(OrderType.SELL_TO_CLOSE, stp ,tradeSize = qty, name = ";LSTP;",arrowColor = color.red);