The follow code obviously works fine with a single position, what if, though, Id like to apply the same kind of exit to a 'long' Spread Position?
CODE:
Please log in to see this code.
Size:
Color:
CODE:
Please log in to see this code.
Size:
Color:
right, but if I am long one and short the other, how do I specify long and short...
This is the exit I would like to use to exit a short position, but the way it is currently set it doesnt specify a long or short position in the spread right?
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
right, but if I am long one and short the other, how do I specify long and short...
CODE:
Please log in to see this code.
Size:
Color:
Ok, I understand tha part, but I am more worried about the exit rule,
CODE:
Please log in to see this code.
this will exit short positions that have crossed back under the middle oving average as I would like, however 'long spread' positions need to exit after they close above the ma. The current rule would exit every trade where the Close was under the moving average, which I dont wantto happen with 'long Spread ' positions. So I guess I need to somehow differentiate between a long spread and a short spread position. Hope that makes sense
Size:
Color:
Ive been playing around with some exits and would like to add a time based exit to my pairs strategy. I found the following example, but not sure how I could adjust it to a pairs strategy.
CODE:
Please log in to see this code.
Size:
Color:
In theory, you can refer to the penultimate position of a pair as Positions[Positions.Count-2] and, respectively, the last created Position object is Positions[Positions.Count-1]. Maybe Robert have a different idea?
Size:
Color:
Tried the following so that it should hold for 5 bars, but it still closes the very next bar.... I would like it to hold for 5 bars before exiting.
CODE:
Please log in to see this code.
Size:
Color:
It's because the statements following "if (bar+1 - p.EntryBar >= 5)" are not delimited with { }, therefore the only statement that executes for that condition being true is "SetContext( shortSymbol, true );", and, that statement isn't even necessary!
Size:
Color: