Closing position after 5 days using intraday data
Author: sarokhatch
Creation Date: 7/2/2013 7:53 PM
profile picture

sarokhatch

#1
I am trying to close a position if it is older than 5 days and it is currently not profitable and it is below 2%
As an example I buy appl at 402, 5 days later if the stock price is below 393.96 (402x0.98) then sell at market.
I tried Sell at stop loss setting that to 2% and "current open position is older than a number of bars" to 2500 ( I have set the scale to one minute).
The problem that I am seeing since I have set to "multiple open positions allowed" it is the most recent position not really the current position.
Any help would be appreciated.
Thanks
profile picture

Eugene

#2
QUOTE:
I tried Sell at stop loss setting that to 2% and "current open position is older than a number of bars" to 2500 ( I have set the scale to one minute).

Hardcoding a number of bars in trading session is not a too robust approach. Nevertheless, it should work for very liquid stocks with trades happening every minute. (BTW, aren't there 390 minutes * 5 = 1950 bars?)
QUOTE:
The problem that I am seeing since I have set to "multiple open positions allowed" it is the most recent position not really the current position.

You're right. The rule indeed acts as per its description saying "most recent open Position is older..." but the title (Current position) is in conflict. Looking at rule wizard's output, I think that it would be more universal if instead of using "LastActivePosition", it would refer to "p".

You can fix it by replacing LastActivePosition by "p" in this segment:

CODE:
Please log in to see this code.


Like this:
CODE:
Please log in to see this code.



If you're familiar with C# then you can follow this design pattern to implement your idea precisely, w/o relying at those shaky 2500 bars:

Wiki > Intraday | Building blocks of Intraday trading strategies > Exiting after N days in an intraday strategy
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).