![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,
Does anyone know what the Ninja code would be to do the following... If a trade was exited, then don't allow an entry on the next bar. Thank you. Razor |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Oct 2008
Location: Dallas, TX
Posts: 682
Thanks: 0
Thanked 2 times in 2 posts
|
Razor,
Perhaps this might help: Code:
if (BarsSinceExit() < 1) return; More on BarsSinceExit() is available in the help index. Good luck, Mike |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Mike, I'll give it a try.
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
The "if (BarsSinceExit() < 1) return;" doesn't seem to be working. I still get entries on consecutive bars.
Any ideas? Thank you. |
|
|
|
|
|
#5 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Razor_Trader,
What is your exact code structure looking like right now? Thanks.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
Josh,
An outline of my code is.... protected override void OnBarUpdate() { if (BarsSinceExit() < 1) return; If (Conditon1 && Condition2) { EnterLongLimit(); } If (Condition3 && Condition4) { EnterShortLimit(); } } |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
I moved the "if (BarsSinceExit() < 1) return;" statement into a different place in the code. I can get it to work on long entries only or short entries only but not both long and short entries.
For example it works for long entries only when I put the "if (BarsSinceExit() < 1) return;" statement as follows... protected override void OnBarUpdate() { If (Conditon1 && Condition2) { if (BarsSinceExit() < 1) return; EnterLongLimit(); } If (Condition3 && Condition4) { EnterShortLimit(); } } |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
If I put the "if (BarsSinceExit() < 1) return;" in the code twice, then I get no trades at all. As in the following...
protected override void OnBarUpdate() { If (Conditon1 && Condition2) { if (BarsSinceExit() < 1) return; EnterLongLimit(); } If (Condition3 && Condition4) { if (BarsSinceExit() < 1) return; EnterShortLimit(); } } |
|
|
|
|
|
#9 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Razor_Trader,
I suspect you are running into Internal Order Handling Rules. Please check your Control Center for errors. Please review the bottom of this article for the rules: http://www.ninjatrader-support.com/H...verview36.html
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multi Timeframe Entries | bani789 | General Programming | 1 | 09-02-2008 11:12 AM |
| Multiple entries | SystemTrading | Strategy Development | 3 | 08-29-2008 08:18 AM |
| Coordinate Multiple strategy entries | maninjapan | General Programming | 7 | 06-04-2008 02:04 AM |
| Entries per direction | latkinso | General Programming | 4 | 02-12-2008 09:27 AM |
| EMA Entries and Exits | gygraham | Strategy Development | 3 | 01-25-2008 12:30 PM |