![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Nov 2006
Location: , ,
Posts: 88
Thanks: 2
Thanked 0 times in 0 posts
|
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(); } |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Expected, note the wrong semicolon in your code
if (Close[0] < LLstop);
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Nov 2006
Location: , ,
Posts: 88
Thanks: 2
Thanked 0 times in 0 posts
|
Thank you. I know it was something stupid
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |