![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jan 2008
Posts: 97
Thanks: 0
Thanked 1 time in 1 post
|
Does anyone know what is wrong with the code below? I am not sure if the CrossAbove code is used correctly or not. This code is basically locking up NT and when it finally does load there are no orders. HighestHigh (double) and CountBars (int) are variables defined in the variable declaration section. Also, how do you say in NT "close since CrossAbove > HighestHigh." Meaning the close has to stay above HighestHigh for the order to continue working.
Code:
protected override void OnBarUpdate()
{
if((ToTime(Time[0]) >= 070000) && (ToTime(Time[0]) <= 150000) && CrossAbove(Close, HighestHigh, CountBars)) && Close[0] > HighestHigh);
{
entryOrder = EnterLongStop(1, Math.Max(Close[0]+.0005,GetCurrentAsk(0)),"LongEntry");
}
}
GT |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
|
GT,
please try this - there was a brace too much in the code you posted. Code:
if ((ToTime(Time[0]) >= 070000) && (ToTime(Time[0]) <= 150000) && CrossAbove(Close, HighestHigh, CountBars) && Close[0] > HighestHigh);
{
IOrder entryOrder = EnterLongStop(1, Math.Max(Close[0]+.0005,GetCurrentAsk(0)),"LongEntry");
}
You could simply set the order liveUntilCancelled, and then cancel it when the Close falls below the HighestHigh value.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CrossAbove() tick vs bar | junkone | Strategy Development | 3 | 12-02-2008 03:07 PM |
| What does CrossAbove/Below do? | tradefaz | General Programming | 1 | 08-23-2008 12:56 PM |
| CrossAbove/Below donīt work all the time! | Agamenon | Strategy Development | 2 | 11-19-2007 06:28 AM |
| General Question about CrossAbove | moflaherty | Indicator Development | 4 | 08-22-2007 02:54 PM |
| CrossAbove for current bar. | SuzyG | Strategy Development | 1 | 12-28-2006 03:18 AM |