I'm not sure what i'm doing wrong here I've tried everything, in this code if i have going long and short it looks ok but if i just want to have it short and covering but not going long it doesn't recognize going short, could anybody tell me what i'm doing wrong?
Announcement
Collapse
No announcement yet.
Buying and selling in a backtest?
Collapse
X
-
actually does something look wrong with this code ?
if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
hi = high();
if ((hi - nTradeEntryPrice) > .005){
nStopLevel = hi;
Strategy.doCover("Loss stop out", Strategy.STOP, Strategy.THISBAR, nStopLevel);
}
}
Comment
-
You will probably figure this out ... the only thing that I see that you could add is a Strategy.ALL flag. Otherwise, all looks well... your command structure is similar to working code I have.
One other implementation of the strategy that I use is Strategy.doCover(sAction,Strategy.CLOSE, Strategy.THISBAR,Strategy.ALL) where sAction is my text message. I use this to exit at the end of trading hours.
btw, unusual avatar
Comment
-
That Avatar is just what I needed to break the ice this morning.
LOL
To funny
Comment
-
thanks for the compliments on the avatar, it was either that one or the fat kid going crazy...anyways i thought it looked good too but if i comment out that stop the code works fine, but if i leave it in the indicator doesn't show up...any ideas?Attached Files
Comment
Comment