![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Nov 2008
Location: London
Posts: 53
Thanks: 0
Thanked 0 times in 0 posts
|
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.
protectedoverridevoid 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 |
|
|
|
| Thread Tools | |
| Display Modes | |
|
|
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 |