NinjaTrader Support Forum  

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 05-19-2012, 07:39 PM   #1
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default What overload to use?

Hi,

I'm using a primary bar series which is a Range bar, and a secondary series which is 1 minute bars. I've added this code:

Code:
if(BarsInProgress == 1)
				{
					if(ToTime(Time[0])>=eodExitTime)
										{
										ExitShort();
										ExitLong();
										Print("forced exit on bars series 2");
										}	
				}
The output window is showing the print statement, so I'm guessing there is some other overload for the ExitShort and ExitLong's; as the output window shows this:

"5/10/2012 11:09:00 PM Entered internal PlaceOrder() method at 5/10/2012 11:09:00 PM: BarsInProgress=1 Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
5/10/2012 11:09:00 PM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'"

Yet, a position was actually held at the time.
coolmoss is offline  
Reply With Quote
Old 05-20-2012, 12:04 PM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

coolmoss,

If you call both exit orders here it will ignore at least one of them. You could eliminate this if you check if you are in a long or short position before calling either method.

if (Position.MarketPosition == MarketPosition.Short)
{
ExitShort();
}
NinjaTrader_AdamP is offline  
Reply With Quote
Old 05-20-2012, 04:27 PM   #3
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default

Thanks Adam,

I found out that ToTime is a bit different for multi bars scripts. I changed it to ToTime(Times[1][0]) and things seem to work now.

Just sharing this to complete the thread if anyone else comes across this thread with similar problem.
coolmoss 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
GetBar() missing an overload saltminer Indicator Development 1 01-05-2012 06:22 AM
No overload for method kenb2004 Strategy Development 9 09-23-2010 05:01 AM
Overload problem advs108 General Programming 2 06-07-2010 04:33 AM
Fast Tick and Overload conditions Turtle Trader Strategy Development 1 03-11-2010 01:46 PM
No Overload error aaron1281 General Programming 2 09-18-2007 11:51 PM


All times are GMT -6. The time now is 12:58 AM.