Croatian0522
New member
Hello,
I'm trying to code and backtest multiple exits for a futures strategy however what I did is not working out. Below is a code for a simple profit target, I just added at the very top (input shares=1). The code works but when I backtest it's calculating that I am selling my position @$1 price per share not selling one share. It's probably a simple fix but I'm not sure what exactly I am doing wrong. Any help would be appreciated. TIA.
input shares=1;
input offsetType = {default percent, value, tick};
input target = 0.75;
def entryPrice = entryPrice();
def mult;
switch (offsetType) {
case percent:
mult = entryPrice / 100;
case value:
mult = 1;
case tick:
mult = tickSize();
}
def targetPrice = entryPrice + target * mult;
addOrder(OrderType.SELL_TO_CLOSE, high >= targetPrice,shares, tickColor = GetColor(6), arrowColor = GetColor(6));
I'm trying to code and backtest multiple exits for a futures strategy however what I did is not working out. Below is a code for a simple profit target, I just added at the very top (input shares=1). The code works but when I backtest it's calculating that I am selling my position @$1 price per share not selling one share. It's probably a simple fix but I'm not sure what exactly I am doing wrong. Any help would be appreciated. TIA.
input shares=1;
input offsetType = {default percent, value, tick};
input target = 0.75;
def entryPrice = entryPrice();
def mult;
switch (offsetType) {
case percent:
mult = entryPrice / 100;
case value:
mult = 1;
case tick:
mult = tickSize();
}
def targetPrice = entryPrice + target * mult;
addOrder(OrderType.SELL_TO_CLOSE, high >= targetPrice,shares, tickColor = GetColor(6), arrowColor = GetColor(6));