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.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 11-07-2008, 10:17 AM   #1
stefy
Senior Member
 
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
Default Simple Limit Strategy with CancelOrder

I'm developing a simple strategy based on entering a limit order and then canceling it if not filled in 3 bars. I get no trades at all. That's what I did:

In the Variables region

private IOrder myEntryOrder = null;

OnBarUpdate():

// Entry Long Condition

if (myEntryOrder == null)
{
myEntryOrder = EnterLongLimit(1, true, DefaultQuantity, MaxRange, "LongLimit");
}

// Cancel LimitOrders condition
if (BarsSinceEntry() >= 3)
CancelOrder(myEntryOrder);

// Exit Condition Long
if (conditions
&& Position.MarketPosition == MarketPosition.Long)

{
ExitLong("Take Profit Long", "LongStopLimit");
myEntryOrder = null;
}

// Stop Loss Long
if (conditions
&& Position.MarketPosition == MarketPosition.Long)
{
ExitLong("LongStopLoss", "LongStopLimit");
myEntryOrder = null;
}

Thank you
stefy is offline  
Reply With Quote
 

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
CancelOrder() problem John833 Strategy Development 41 10-31-2008 03:15 PM
Simple strategy rnr123 Strategy Analyzer 1 10-17-2008 07:04 AM
need help with simple strategy mike8943 Strategy Development 1 07-17-2008 08:21 AM
RFE: ability to type in limit price in the simple order window and the FX Pro window henry.omd ATM Strategies (Discretionary Trading) 6 12-24-2007 04:05 PM
Simple Strategy Oli Automated Trading 2 03-05-2007 11:42 PM


All times are GMT -6. The time now is 07:54 AM.