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-13-2008, 06:29 AM   #1
verge
Member
 
Join Date: Nov 2006
Location: , ,
Posts: 88
Thanks: 2
Thanked 0 times in 0 posts
Default ExitLong ignoring condition

Please see my code snipper below. I don't know what I am doing wrong and hope someone sees an obvious mistake because it is driving me up the wall.

The problem is that the ExitLong does not take the condition in to account. The places where the system exits does not even change when I comment the "if (Close[0] < LLstop) condition out. The trades are ALWAYS closed out after 1 bar (i.e. on the second bar) even if the condition is nor true.

I have inserted print statements to check the values of the variables and all looks fine

Any input would be appreciated.

// Buy trigger
if (Position.MarketPosition != MarketPosition.Long)
{
HighestHighforlong = 0;
LLstop = 0;
if (MyDmipp[0] > MyDmimm[0] && MyDmipp[1] > MyDmimm[1])
{
HighestHighforlong = MAX(High,3)[0];
if ((Close[0] + TickSize) > HighestHighforlong)
EnterLong();
}
}

if (Position.MarketPosition == MarketPosition.Long)
{
LLstop = MIN(Low,4)[BarsSinceEntry()];
if (Close[0] < LLstop);
ExitLong();
}
verge is offline  
Reply With Quote
Old 05-13-2008, 06:41 AM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Expected, note the wrong semicolon in your code
if (Close[0] < LLstop);
NinjaTrader_Dierk is offline  
Reply With Quote
Old 05-13-2008, 07:28 AM   #3
verge
Member
 
Join Date: Nov 2006
Location: , ,
Posts: 88
Thanks: 2
Thanked 0 times in 0 posts
Default Thank you

Thank you. I know it was something stupid
verge 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
ExitShort() / ExitLong() andrewbee General Programming 1 02-06-2008 10:57 AM
ExitLong() is being “skipped” CashCache Strategy Development 2 01-28-2008 05:43 PM
Closing a forex position with ExitLong() henry.omd Strategy Development 2 01-05-2008 12:31 PM
Condition Builder OUFan Strategy Development 6 12-19-2007 02:05 PM
ExitLong and ExitShort mazachan Strategy Development 3 07-30-2007 03:15 PM


All times are GMT -6. The time now is 09:04 AM.