Upon entering a trade, I want to set a protective stop if the trade goes opposite my direction and also set a stop or limit order to be executed in future bars if a target I specify is hit. I've tried the code below (for a short) but it results in constant trades for each entry that have nothing to do with the future prices.
if (vLastAlert != 3) Strategy.setStop(high()+stopOffset);
if (vLastAlert != 3) Strategy.setStop(close()-vTarget);
I've also considered setting a limit order at the entry price plus my target, but don't see 1) how to keep it in place for future bars until the original trade is completed and 2) how to cancel the limit order if another condition closes the trade.
Help!
if (vLastAlert != 3) Strategy.setStop(high()+stopOffset);
if (vLastAlert != 3) Strategy.setStop(close()-vTarget);
I've also considered setting a limit order at the entry price plus my target, but don't see 1) how to keep it in place for future bars until the original trade is completed and 2) how to cancel the limit order if another condition closes the trade.
Help!
Comment