Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
entry and exit
Collapse
X
-
entry and exit
I am trying to have my strategy enter the market at the open of the market and exit the market at the close of the the market for the day. I am using yahoo data. I've tried using exitonclose but whenever I backtest it only exits on the last day i have set it up to trade on, rather than closing everyday throughout the range of days I have set up. I also thought about using BarsSinceEntry() > 1 to exit my strategy but that doesn't seem to work either.Tags: None
-
Hi Wes, in order to both enter and exit a trade on the same day you'll need to add detail and backtest with intrabar granularity. Unfortunately, that requires minute/tick data.AustinNinjaTrader Customer Service
-
Ok well how would I enter one day and exit the next day.
Also if I have three indexes and format a code like so:
if (Closes[1][0] < Closes[1][1] && Closes[2][0] < Closes[2][1] && Closes[3][0] < Closes[3][1])
Exit long
Comment
-
To enter one day and exit the next, you'd program it just as usual. In OnBarUpdate:
Code:if (Close[0] > Close[1]) EnterLong(); //this would enter long at the open of the day after the bar that the conditions were true if (Close[0] < Close[1]) ExitLong() //this would exit the long at the open of the day after the conditions were true
In C# (and many other languages) && is the logical operator AND and || is the logical operator OR.
If, for example, you'd like to exit when any of the three were down, you could do this:
Code:if (Closes[1][0] < Closes[1][1] || Closes[2][0] < Closes[2][1] || Closes[3][0] < Closes[3][1])
Code:if ((Closes[1][0] < Closes[1][1] && Closes[2][0] < Closes[2][1]) && (Closes[3][0] < Closes[3][1] && someOtherCondition))
AustinNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by warreng86, 11-10-2020, 02:04 PM
|
5 responses
1,357 views
0 likes
|
Last Post Today, 09:26 PM | ||
Started by Perr0Grande, Today, 08:16 PM
|
0 responses
3 views
0 likes
|
Last Post
by Perr0Grande
Today, 08:16 PM
|
||
Started by elderan, Today, 08:03 PM
|
0 responses
5 views
0 likes
|
Last Post
by elderan
Today, 08:03 PM
|
||
Started by algospoke, Today, 06:40 PM
|
0 responses
10 views
0 likes
|
Last Post
by algospoke
Today, 06:40 PM
|
||
Started by maybeimnotrader, Today, 05:46 PM
|
0 responses
12 views
0 likes
|
Last Post Today, 05:46 PM |
Comment