I new to the forum and NinjaTrader. I'm trying to create a strategy that simply buys at the daily open and sells at that same daily bar's close. I'm aware that "EnterLong()" executes a market order that buys at the following day's opening price, but I don't know how to sell at that same bar's closing price. If I use "ExitLong" it exits the long position at the "next" day's open and not at the same day's closing price.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Re: How to buy the open and sell the close
Collapse
X
-
Re: How to buy the open and sell the close
Hello,
I new to the forum and NinjaTrader. I'm trying to create a strategy that simply buys at the daily open and sells at that same daily bar's close. I'm aware that "EnterLong()" executes a market order that buys at the following day's opening price, but I don't know how to sell at that same bar's closing price. If I use "ExitLong" it exits the long position at the "next" day's open and not at the same day's closing price.Tags: None
-
I want to exit at the close of the same day the order was entered. If I entered a long position 2 wks ago with no particular sell conditions "ExitOnClose=true" would liquidate at "today's" close which would be 2 wks later. I want to liquidate the position at the close of the same day the order was executed...Last edited by JayNice; 07-07-2009, 11:39 AM.
Comment
-
I'm running this in Strategy Analyzer. All I want to do is back test a strategy that buys at the open and sells at the close of the "same bar". It makes no difference what the buy and sell conditions are. Again, the only thing I'm interested in is buying at open and selling at the close of the same bar.Last edited by JayNice; 07-07-2009, 12:48 PM.
Comment
-
JayNice, you can try adding detail to your strategy and backtesting it with intraday granularity.Last edited by NinjaTrader_Austin; 07-07-2009, 01:15 PM.AustinNinjaTrader Customer Service
Comment
-
Here's the code that I'm running in Strategy Analzyer. When this code is ran it goes long at the opening price of the first bar that meets the criteria of condition statement, then it exits the long position at the final day of the price series. I want to exit at the close of the same day that the long position was established.
protected override void OnBarUpdate()
{
// NOTE: I'm using daily price when I run this in Strategy Analyzer.
// If today's close > perious days high buy tomorrow at the market.
// I want to exit at the close of the same bar that the trade was entered.
if(Close[0]>High[1])
{
EnterLong();
}
}
ps. I have "ExitOnClose=true" within the Initialize() method...
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
59 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
21 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
10 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Comment