Strategy not working with Pricechannel


Category:
0
0

Your video on using the Strategy Wizard was great,  I am trying to apply your technique using the pricechannel study and am having a issue. I am trying to use the upperband to trigger the buy and the lower to trigger the exit. The study part shows shows what appears to be the correct triggers. However the stratedy code seems to apply both to the upper band.

declare lower;

plot signal = high crosses above PriceChannel().”UpperBand”;

plot exit = low crosses below PriceChannel().”LowerBand”;

################################################

input tradeSize = 100;

def signal = high crosses above PriceChannel().”UpperBand”;
addOrder(OrderType.BUY_TO_OPEN, signal, open[-1], tradeSize, color.CYAN, Color.CYAN);

def exit = low crosses below PriceChannel().”LowerBand”;
addOrder(OrderType.SELL_TO_CLOSE, signal, open[-1], tradeSize, color.MAGENTA, Color.MAGENTA);

Any idea on what is wrong?

Attachments:
RESOLVED
Marked as spam
Posted by (Questions: 2, Answers: 2)
Asked on February 18, 2018 1:02 am
285 views
0
Private answer

Very simple. You have what appears to be a copy error. The condition used in your sell order is the ‘signal’ variable. It needs to be changed to the ‘exit’ variable.

Here is your code:

def exit = low crosses below PriceChannel().”LowerBand”; addOrder(OrderType.SELL_TO_CLOSE, signal, open[-1], tradeSize, color.MAGENTA, Color.MAGENTA);

Should be:

def exit = low crosses below PriceChannel().”LowerBand”; addOrder(OrderType.SELL_TO_CLOSE, exit, open[-1], tradeSize, color.MAGENTA, Color.MAGENTA);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 18, 2018 8:21 am
0
Private answer

Thank you so much for the quick reply. So much better.

Marked as spam
Posted by (Questions: 2, Answers: 2)
Answered on February 18, 2018 10:35 am