NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 10-24-2008, 08:20 PM   #1
Razor_Trader
Junior Member
 
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Default Multiple entries

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
Razor_Trader is offline  
Reply With Quote
Old 10-25-2008, 01:54 AM   #2
ctrlbrk
Senior Member
 
Join Date: Oct 2008
Location: Dallas, TX
Posts: 682
Thanks: 0
Thanked 2 times in 2 posts
Default

Razor,

Perhaps this might help:

Code:
if (BarsSinceExit() < 1) return;
This would basically say if a trade was exited 1 bar ago, don't do anything until the next bar.

More on BarsSinceExit() is available in the help index.

Good luck,
Mike
ctrlbrk is offline  
Reply With Quote
Old 10-25-2008, 07:56 PM   #3
Razor_Trader
Junior Member
 
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Mike, I'll give it a try.
Razor_Trader is offline  
Reply With Quote
Old 10-25-2008, 10:04 PM   #4
Razor_Trader
Junior Member
 
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Default

The "if (BarsSinceExit() < 1) return;" doesn't seem to be working. I still get entries on consecutive bars.

Any ideas?

Thank you.
Razor_Trader is offline  
Reply With Quote
Old 10-27-2008, 08:20 AM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Razor_Trader,

What is your exact code structure looking like right now? Thanks.
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-27-2008, 10:32 PM   #6
Razor_Trader
Junior Member
 
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Default

Josh,

An outline of my code is....

protected override void OnBarUpdate()
{
if (BarsSinceExit() < 1) return;

If (Conditon1 && Condition2)
{
EnterLongLimit();
}

If (Condition3 && Condition4)
{
EnterShortLimit();
}
}
Razor_Trader is offline  
Reply With Quote
Old 10-28-2008, 07:32 PM   #7
Razor_Trader
Junior Member
 
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Default

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();
}
}
Razor_Trader is offline  
Reply With Quote
Old 10-28-2008, 07:34 PM   #8
Razor_Trader
Junior Member
 
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Default

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();
}
}
Razor_Trader is offline  
Reply With Quote
Old 10-29-2008, 08:27 AM   #9
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

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
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 08:54 AM.