NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


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 01-18-2009, 04:11 PM   #1
Gekko
Junior Member
 
Join Date: Dec 2008
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default Entry after flat position

Hello,

I have a strategy which enters a trade after a few different indicators are triggered within the first condition. I than have set a profit target, if the position reaches the targt it's closes out. However, I would like to reenter the position and I set a very simple entry to do so.

My problem is that I cannot get the second entry to work. I have enclosed the strategy. Obviously, my condition 2 set is not right and I have tried to hunt around in the help forum but with no luck. Can someone tell me what I'm doing wrong? Thank you.

// Condition set 1
if (CrossAbove(EMA(Fast), SMA(Slow), 1)
&& Rising(Momentum(
10)) == true
&& MACD(12, 26, 9).Avg[1] >= 0)
{
EnterLong(
1, "Long 1");
}
// Condition set 2
if (Position.MarketPosition == MarketPosition.Flat
&& Close[
1] > Fast)
{
EnterLong(
1, "Long 2");
Gekko is offline  
Reply With Quote
Old 01-18-2009, 11:15 PM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

I do not see anything wrong with your code. You will need to debug it. This link will help:
http://www.ninjatrader-support2.com/...ead.php?t=3418

Try printing out the Fast variable right before the condition 2: Print("fast " + Fast);
NinjaTrader_Ben 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
Long ? short when flat vs. position ju1234 Strategy Development 1 11-21-2008 07:16 AM
How to return the Position Entry Price?? Ninja in Training Strategy Development 3 08-05-2008 10:06 AM
position flat trading 2 strategies on same instrument ceesvh Automated Trading 3 08-29-2007 01:48 PM
Flat a position on a market Respond SuperDOM and other Order Entry Windows 2 06-27-2007 08:51 AM
Incorrect position entry on SIM EuroFX Miscellaneous Support 12 09-24-2006 01:33 PM


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