![]() |
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
|
|||||||
| Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Member
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
|
I have created a simple strategy that uses Renko bars. The problem is that sometimes my trades are entered exactly where I specified and sometimes they are completely wrong. In history performance everything looks perfect but when testing in reply it's hit and miss. Why is this?
Here's my code: Code:
protected override void Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, ProfitTarget);
SetStopLoss("", CalculationMode.Ticks, StopLoss, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (ToTime(Time[0]) > ToTime(8, 30, 0)
&& ToTime(Time[0]) < ToTime(14, 55, 0)
&& Position.MarketPosition == MarketPosition.Flat
&& CrossAbove(DMplus(ADXPeriod).DiPlus, DMplus(ADXPeriod).DiMinus, 1))
{
EnterLong(DefaultQuantity, "");
}
// Condition set 2
if (CrossBelow(DMplus(ADXPeriod).DiMinus, DMplus(ADXPeriod).DiPlus, 1))
{
ExitLong("", "");
}
}
Last edited by relogical; 06-27-2012 at 06:02 PM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
|
relogical, due the way Renko bars are constructed there can be discrepancies unfortunately experiecenced comparing backtest results to realtime / market replay where the actual intrabar formation would be available. To better understand the issues your script faces, I would suggest adding visual confirmation of an entry, so you know exactly when your programmed in conditions would trigger, this can be done for example with drawing dot / arrow via the NinjaScript methods available.
With more advanced custom coding, a more realistic backtest results could be likely achieved by submitting your orders to a finer granularity (for example a 1 tick series), here's a sample how this would be approached - http://www.ninjatrader.com/support/f...ead.php?t=6652
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
|
I noticed that trades are not executed on target when it's a fast moving security. When I use something less volatile the buy/sell trades are correct. Does this happen because the NT software is just not able to place trades on fast moving securities?
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
|
relogical, the speed should not matter, we have many high frequency traders using our product every day.
To understand why you see the differences, I would really suggest adding better visual confirmations when exactly your trade conditions are triggering, then you could expect an entry on the next bar open > the next possible trade execution location.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
|
I am not sure what you mean by visual confirmation. Isn't the buy and sell confirmation that's printed on the chart good enough? Please explain. Thank you
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
|
Correct, that would be the executions, however this would not be the same timing as the signal generation, as the signal will be processed / executed on bar after triggering. Thus if you add visual confirmation for example via Draw objects you would see both legs happening, the trigger and the execution.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Member
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
|
Quote:
|
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
|
If you use the techninque in the sample referenced and submit your orders to the bid / ask series (instead for the default 'last') this will be aligning better.
We have enhancing and simplifying this area on our feedback list for our next major NT update and I've also added a vote / request on your behalf in.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Feb 2008
Posts: 5
Thanks: 0
Thanked 1 time in 1 post
|
relogical,
found this thread http://www.ninjatrader.com/support/f...822#post293822 where the problem is discussed more deeply. maybe this helps to understand the "Renko" problem better BUT u won't find a solution there (at least at the time being) since you will get unusable backtest results OR have to waste a lot of your time in adding granularity (i. e. 50 to 100 ticks) which will take "undefinite" time for the backtesting which is also not acceptable. I suggested to use the end of the current bar for execution (at least for Renkos) instead of the open of the next bar (which will result in a lot of errors and unusable backtest results). we will see how NT reacts to that. If they don't solve the issue u basically cannot use Renkos with the strategy analyzer imho. firstbrain |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Renko | tonynt | Automated Trading | 8 | 08-25-2011 12:44 PM |
| Renko in 6.5 | shali27 | Charting | 1 | 05-12-2010 09:15 AM |
| Renko Help | kermut | Strategy Analyzer | 5 | 08-15-2009 04:17 PM |
| Connection Problems followed by NT Strategy Problems | GerTrader | Connecting | 21 | 05-20-2009 01:29 PM |
| Log File problems and Live Trade Problems | gygraham | Connecting | 7 | 03-30-2008 05:16 PM |