Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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 NexusFi?
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.
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..