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 > Application Technical Support > Automated Trading

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.

Reply
 
Thread Tools Display Modes
Old 06-27-2012, 05:10 PM   #1
relogical
Member
 
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
Default Renko problems

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("", "");
            }
        }
Attached Images
File Type: jpg renko.jpg (376.7 KB, 32 views)
Last edited by relogical; 06-27-2012 at 06:02 PM.
relogical is offline  
Reply With Quote
Old 06-28-2012, 04:12 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
Default

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
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-28-2012, 07:44 AM   #3
relogical
Member
 
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
Default

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?
relogical is offline  
Reply With Quote
Old 06-28-2012, 07:50 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
Default

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.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-28-2012, 08:06 AM   #5
relogical
Member
 
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
Default

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
relogical is offline  
Reply With Quote
Old 06-28-2012, 09:19 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
Default

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.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-28-2012, 09:27 AM   #7
relogical
Member
 
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
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
When I build a strategy and run in live or in replay the long entries are always made at the top of the bar and exits are always at the bottom of the bar. But in backtesting everything is good. Will the code from the link you posted correct this?
relogical is offline  
Reply With Quote
Old 06-28-2012, 10:24 AM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
Default

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.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 07-02-2012, 08:28 PM   #9
firstbrain
Junior Member
 
Join Date: Feb 2008
Posts: 5
Thanks: 0
Thanked 1 time in 1 post
Default

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
firstbrain 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
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


All times are GMT -6. The time now is 09:13 PM.