NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM 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.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 06-06-2010, 01:55 PM   #1
traderT
Member
 
Join Date: Nov 2008
Location: London
Posts: 53
Thanks: 0
Thanked 0 times in 0 posts
Default Exit on same bar

I have written a simple strategy the buys or sells on a pullback to the EMA, providing price has not reached the EMA within the last 15 bars, using EnterLongLimit or EnterShortLimit and am using a 15 minute chart. The problem that I am having is that if the entry bar is large enough then the strategy exits on the same bar even though price movement does not warrant an exit.

protected
overridevoid Initialize()
{
SetProfitTarget(
"", CalculationMode.Ticks, target);
SetStopLoss(
"", CalculationMode.Ticks, stopLoss, false);
CalculateOnBarClose = false;
}

protectedoverridevoid OnBarUpdate()
{
EMAValue = (EMA(MAPeriod)[
0]);
Condition1 = (ToTime(Time[
0]) >= 0400 && ToTime(Time[0]) <= 1200);
if(High[0] > EMA(MAPeriod)[0]) shortCount = 0;
if (High[0] < EMA(MAPeriod)[0])shortCount++;
if((shortCount >= other))
{
EnterShortLimit(EMA(MAPeriod)[
0], "EMAShort");
}

}
protectedoverridevoid OnOrderUpdate(IOrder order)
{

if (order.OrderState == OrderState.Filled)
{
longCount =
0;
shortCount =
0;
}
}
Left chart incorrect, right chart correct
Attached Images
File Type: png EMA Strat.png (13.6 KB, 9 views)
traderT 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
Entry on the Current Bar brooksrimes Strategy Development 5 06-02-2010 10:09 AM
How can I access to data of last bar? 10percent General Programming 2 06-01-2010 02:30 PM
My bar chart saeed Charting 1 05-31-2010 04:48 AM
Today's 9:00 bar Stem1 General Programming 1 05-31-2010 03:58 AM
Backtest using daily bars (same bar signal) tradinghumble Strategy Development 3 05-28-2010 11:30 AM


All times are GMT -6. The time now is 11:47 PM.