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 02-25-2009, 07:35 PM   #1
GreenTrade
Member
 
Join Date: Jan 2008
Posts: 97
Thanks: 0
Thanked 1 time in 1 post
Default CrossAbove

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");
                    }
}
Thanks!

GT
GreenTrade is offline  
Reply With Quote
Old 02-26-2009, 06:56 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

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.

NinjaTrader_Bertrand is online now  
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
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


All times are GMT -6. The time now is 02:10 AM.