|
suresh
2010-08-30 09:34:22
|
|
I want to code the following trading system.
Buy next bar at current low.
After the purchase, sell next bar at limit of high of purchase bar.
If position open for more than 3 bars, sell at market.
So the positions should be held atleast 1 bar, maximum 4 bars.
The current implementation I have closes the position on same day as purchase
|
|
|
|
QuantShare
2010-08-30 10:50:32
0
|
|
Best Answer
Hi,
Here is the trading system implementation:
Buy next bar at today's low:
Set your buy rule and set the buy limit price to buy at tomorrow "low".
Sell next bar at limit of high of purchase bar:
Set "1" as sell rule and set the sell limit price to sell at tomorrow "high". Because the sell rule is set to 1, it will be executed on the same day the stock was purchased and then will use the high price of the purchase bar.
Set N-Bar Stop to 4 bars.
|
|
|
|
suresh
2010-08-30 11:08:50
0
|
|
I do not want to sell on the day of purchase. This is the code that was generated. Please tell me how to modify this so that I will not sell on the same day as purchase. PS. I want to avoid the situation, when the high price occurs at the open and the low price happens at close.
BuyPrice(low, 0);
SellPrice(high, 5);
// Buy rules
Rule1 = (1) > (0);
buy = (Rule1);
// Sell rules
Rule2 = (1) > (0);
sell = (Rule2);
|
|
|
|
QuantShare
2010-08-30 12:05:44
0
|
|
This system does not sell on the same date as the purchase date.
Make sure you use sell at tomorrow order type.
Please verify your trades.
|
|
|
|
suresh
2010-08-30 12:13:46
0
|
|
OK. It is after 1 day. Now what is Nb Bars. It shows as 0 for trades that are sold the next day. I was ASSuming that it is numbers of bars the trade is held.
|
|
|
|
QuantShare
2010-08-30 12:25:13
0
|
|
We will fix this. Thanks.
|
|
|
|