![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jul 2008
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
|
I am working on a simple piece of code, but am having trouble with Ninja Trader doing the entry signal correctly.
The code is suppose to enter short position at market when on the low of the previous 3 periods is met. When I put the strategy into a daily chart, I have it "calculate on bar close" set to "false" which would allow it to signal within a daily chart time frame is the idea. The strategy is always entering into a position at the open price of a bar for some odd reason and not somewhere within the bar is one of the glaring problems that I see. ![]() I am using the current bid price < low of prior days as you see here is the actual code: if (GetCurrentBid() < Low[1] && GetCurrentBid() < Low[2] && GetCurrentBid() < Low[3]) { EnterShort(Cars, "SE"); I have included the total code as well as an attachment if anyone is interested. Does anyone see what I am doing wrong? Thanks in advance...
|
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Are you backtesting? GetCurrentBid() always returns as the close price of the bar during backtests.
Also in backtesting you will only be able to place trades on the next bar which usually ends up having trades enter at the open of that next bar. You cannot trade on the signal bar despite CalculateOnBarClose = false during backtesting because you always have the Close value of the signal bar. Since the bar is closed it is untradeable.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jul 2008
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
|
ok, that makes sense... but is there a solution?
![]() What I am trying to do sounds simple enough. Any ideas what the logical way to code what I am wishing to accomplish keeping in mind what you state is appreciated... |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
For backtesting you simply cannot trade on the same bar as the signal bar. In real-time this is not the case though.
Solutions could include multi-time framed strategies that include daily and minute bars. You take your daily time frame for signal, but submit to minute time frame. Please see this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=6652 Alternatively you could try and get the Low of the previous three days through the use of PriorDayOHLC(). You will need to pass in a very high barsAgo parameter to get it all the way back at 1 day ago, 2 days ago, and 3 days ago.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Request: Short cut keys for workspaces | pdawg | Suggestions And Feedback | 4 | 03-17-2011 06:51 AM |
| Sell Short and Stop loss on the same bar | julen | Strategy Development | 6 | 09-16-2008 08:38 AM |
| Always start with a long or short | Nu2NT | Automated Trading | 4 | 05-12-2008 12:05 PM |
| Check if last position was long or short!? | whitegun | Automated Trading | 1 | 02-07-2008 03:30 PM |
| Long & short combined in 1 strategy | dtf139 | Automated Trading | 5 | 01-08-2008 08:23 PM |