I use TradeStation 200i and use daily bars for my strategy and entry is at close of the day.
I have several exits, one is a fixed point exit.
Sometimes the exit should be the day after entry but that does never happen when I run the backtest, the exit is in those cases at best the second day after entryday, never the first day where it should be.
Anyone who knows how to make sure the trade can go to exit also the first day after entry?
Code for entry:
If Close > Open AND Marketposition = 0 AND MA>MA[1] AND Cantrade Then Buy This Bar at Close;
Code for exit:
If Marketposition = 1 then Exitlong at Stoploss or lower;
Can you help answer these questions from other members on futures io?
I think the reason for this is that, on the entry bar, Tradestation doesn't know you are in a position until after the bar closes (and all code is acted upon). So, on the entry bar, marketposition=0, which will then keep your exit statement from being executed. Try this instead, and see if it works:
As you say, market position is 0 at the close of the entry bar, but right after the open of next bar the market position should be 1, I thought. And therefore exit should be possible somewhere on that bar.
I am trading on daily bars and one of my exits is a gliding one: when 2 % profit has been reached, I take my profit if it goes down to 1,5 %. It works, but Tradestation does not take exit if both the target (2 %) and profit (1.5 %) happen on the same bar/day. Instead Tradestation takes exit next day, but that is not what I want.
I have checked intraday that the target is reached first in order, and after that the profit level is triggered - so that is not the problem.
Some ideas how to solve this?
Code for exit:
If MaxPositionProfit >= (Firsttarget * Entryprice/100) Then Exitlong at ("1:st") Entryprice + (Firstprofit * Entryprice/100) or lower ;
I know of no east way offhand. With daily bars, your code is read only at each close, and by then it is too late to do what you want.
You might take a look at Intrabar Order Generation (IBOG), if you haven't already. The problem is this is an advanced topic, and you can easily do things you don't intend to do.
The following user says Thank You to kevinkdog for this post:
Orjan,
you will most definitely have to use intrabar order generation for this and kevinkdog is right with saying that this is a more advanced topic. Without IOG every order will become active on the next bar only (unless it's on the close of the current bar, which in reality will get you a fill not before the next bar, too).
When you enable IOG in your code this will affect all orders, so you need to make sure that your entries will still be executed at the point where they are now etc..
Regards,
ABCTG
The following user says Thank You to ABCTG for this post:
Intrabar order generation is not possible in TradeStation 2001. But maybe I can build the system with intraday bars, lets say 15 min., and write an instruction that takes entry at the close of the day. I also need an daily MACD-indcator But for the moment I don't know how to do that.
Perhaps the soluton is to combine two charts. One for data 1 = 15 min and one for data 2 = daily?
True, I totally forgot about that. Your solution with two datastreams will likely reduce the occurrence of your problem, but it will not fix it. Even if you build everything based on a minute chart and emulate the daily bars, the problem can still happen.
You might want to take a trial for Multicharts or Tradestation 9 and see how much different the performance would be. Maybe the benefits already merit switching completely for you.
Your solution would work, but calculating with 2 datastreams is tricky too. If you go this route, I recommend spending a lot of time making sure that anything you calculate from datastream2 is really what you want, and that it updates every day, not every 15 minutes.