Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 02-12-2018, 06:37 PM   #1
AlgoJason
Member
 
Join Date: Jan 2018
Posts: 32
Thanks: 18
Thanked 2 times in 2 posts
Default Avg. Trade values for a viable trading strategy

How high would the "Avg. trade" in the Strategy Analyser have to be in order to be a viable after-costs trading system?

I know that there are many other factors to consider and that even an Avg. Trade of $100 does not mean that you definitely have a viable system. E.g. it might be from a single trade. Etc....

But let's focus on this particular number for now, despite the fact that there are many other factors to consider.

E.g. if the number is negative then this would not be a viable trading strategy.

It would have to be high enough to cover the "All In Costs", which through NT are $0.53 per contract.

But, there are other costs. E.g. the spread cost. If it costs 1 tick for each execution then in ES this is $25 per round trip. So does that mean that a viable ES strategy would have to have an "Avg. Trade" value of at least $25.53?

Hope you can see what I am getting at here. What I want to know, especially from those of you who are actually trading live with real money, is what range of numbers for "Avg. Trade" do you have in your back tests? Are they higher than $25.53?

Am I on the right track in looking for strategies that have Avg. Trade greater than $25.53 and rejecting those that only have, say, $7?

Any input/discussion greatly appreciated!
AlgoJason is offline  
Reply With Quote
Old 02-12-2018, 10:32 PM   #2
calhawk01
Senior Member
 
Join Date: May 2013
Posts: 443
Thanks: 10
Thanked 26 times in 21 posts
Default

Quote:
Originally Posted by AlgoJason View Post
How high would the "Avg. trade" in the Strategy Analyser have to be in order to be a viable after-costs trading system?

I know that there are many other factors to consider and that even an Avg. Trade of $100 does not mean that you definitely have a viable system. E.g. it might be from a single trade. Etc....

But let's focus on this particular number for now, despite the fact that there are many other factors to consider.

E.g. if the number is negative then this would not be a viable trading strategy.

It would have to be high enough to cover the "All In Costs", which through NT are $0.53 per contract.

But, there are other costs. E.g. the spread cost. If it costs 1 tick for each execution then in ES this is $25 per round trip. So does that mean that a viable ES strategy would have to have an "Avg. Trade" value of at least $25.53?

Hope you can see what I am getting at here. What I want to know, especially from those of you who are actually trading live with real money, is what range of numbers for "Avg. Trade" do you have in your back tests? Are they higher than $25.53?

Am I on the right track in looking for strategies that have Avg. Trade greater than $25.53 and rejecting those that only have, say, $7?

Any input/discussion greatly appreciated!
Strategies that trade fat tail events, will always have low avg trade. For example, you can have a strategy that's wrong 99.99% of the time but still be profitable. If the strategy trade 2000 times and netted -25 each trade except 1 trade and made 30k; you'd still net 5k overall but your "average trade" would be 4.9$!

But you're right, obviously we want strategies that have a high avg trade because of slippage and commission. In my above example, I am assuming those numbers were post commission.

Ninjatrader allows you to enter commission information per trade for futures. I wouldn't test strategies without having the option enabled for future markets. I trade forex, so for me, I worry about slippage rather than commission cost.

The other thing that I have done to reduce slippage (because I don't really like the NT build-in slippage option) is that I only execute trades when price has drifted away from my entry at least 15 pips.Because the problem I was facing (esp during optimization) was that, I was realizing computers are extremely good at "over fitting." In other words, computers during optimization don't take slippage under account and will execute trades between bid/ask spread, and in simulation it will show you made tons of money. But in reality those trades would never have executed. Below is the code that I incorporate for all my strategies:

Code:
			if(Position.MarketPosition==MarketPosition.Long 
				&& (Close[0] - Position.AveragePrice > 0.0015 
				|| Close[0] - Position.AveragePrice < -0.0015))
				
			{
			
			if(Position.MarketPosition==MarketPosition.Long 
				&& Close[0] > Position.AveragePrice+(ATR1[0]*Target))
				
			{
				ExitLong(2,Position.Quantity,  @"PT",@"Target1");	
			}							
			}
For example, above code is for a profit target, but it will only execute if price has drifted apart from my entry. Then to further reduce slippage, I am sending my execution to appropriate bid tick data to simulate a "market order."

I'm working on building a strategy for futures at the moment, and my modification of the above code for future market (Nasdaq futures) is:

Code:
			if(Position.MarketPosition==MarketPosition.Long 
				&& (Close[0] - Position.AveragePrice >10
				|| Close[0] - Position.AveragePrice < -10))
				
			{
			
			if(Position.MarketPosition==MarketPosition.Long 
				&& Close[0] > Position.AveragePrice+(ATR1[0]*Target))
				
			{
				ExitLong(2,Position.Quantity,  @"PT",@"Target1");	
			}							
			}
This way, my exits will only occur when the market has drifted 10$ away from my entry. You can do the same for Stops. This way, you'll reduce slippage. The only slippage I have to worry about is real time, but I've done everything I can possibly do to reduce my slippage in simulation mode. Now in the real market, the distribution of positive/negative slippage 50/50. In other words, you can theoretically get a better fill in live trading or a negative fill, and the odds of that are 50/50.
calhawk01 is offline  
Reply With Quote
The following user says thank you to calhawk01 for this post:
Old 02-12-2018, 11:31 PM   #3
AlgoJason
Member
 
Join Date: Jan 2018
Posts: 32
Thanks: 18
Thanked 2 times in 2 posts
Default

Thanks for your reply and for posting your code to manage the stops and profit targets. At the moment I am using the SetTrailStop and SetProfitTarget functions of NT with minute bars.

I am facing exactly the issue that you mention too. I have tick data for every trade going through the exchange but do not have the order book data (Bid, Ask). So the prices flick in horizontal channels between the Bid and Ask as traders take the bid or ask.

NT simulation will allow buy and sell at the price it sees, which is unrealistic here because obviously the price is not changing at all, it is just flicking between the bid and ask and all buys should be at the ask and all sells at the bid. Not a criticism of NT, it just is what it is.

I have built in some precautions (like not reacting unless the price moves by at least 4 ticks and setting the stop and profit target to at least 4 ticks), but I do like your code which manages the stop and profit targets manually.

I am not comfortable with the way that NT handles bars TBH. Not a criticism of NT, just that I like to see the data inside the bar to become convinced of what is going on.

I have been thinking about revamping my code to run on 1 second bars (the indicator does not have to speed up though, it physically will be doing the same thing at the same speed but the resolution will be 1 second instead of 1 minute) so that the charts will execute orders inside the 1 second bar and I can manage the target and stop loss as you posted.

I am getting around $5-$9 per trade average profit in my back-testing, but I am worried that in reality the cost of trading including spread, slippage and commission would be around $25 on average and therefore would result in losses in the long run.
AlgoJason is offline  
Reply With Quote
Old 02-13-2018, 07:26 AM   #4
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,549
Thanks: 780
Thanked 1,994 times in 1,921 posts
Default

Hello AlgoJason,

Thank you for your post.

Concerning fills I can forward this as a feature request. Concerning the bars building, have you looked into Tick Replay for this purpose?
I will respond when I have an ID for the feature request for custom fill engine.
NinjaTrader_PatrickH is offline  
Reply With Quote
The following user says thank you to NinjaTrader_PatrickH for this post:
Old 02-13-2018, 03:41 PM   #5
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,549
Thanks: 780
Thanked 1,994 times in 1,921 posts
Default

Hello AlgoJason,

Thank you for your patience.

The feature request for a custom fill engine in simulation has been assigned the internal tracking id of SFT-1137.

Please let me know if you have any questions.
NinjaTrader_PatrickH is offline  
Reply With Quote
The following user says thank you to NinjaTrader_PatrickH for this post:
Old 02-13-2018, 06:35 PM   #6
AlgoJason
Member
 
Join Date: Jan 2018
Posts: 32
Thanks: 18
Thanked 2 times in 2 posts
Default

Thanks Patrick.

I have attached a picture to illustrate part of the issue. In the picture which is of a simple moving average crossover (the one shipped as an example in NT) run on 1 second bars.

In it you can see that the price is not changing. The ASK is at 946.75 and the BID is at 947.50 (2 tick spread in this case) and the Trade/Last price is bouncing between them as traders hit either side.

But NT has filled both longs and shorts at the ASK in this case. In reality this series of trades would have cost at least 6 ticks ($75) to execute as market orders, but NT backtest will put them through at no cost because it does not do anything about the spread.

I am not suggesting to trade at 1 second speed, just using this example to illustrate the issue.

In a previous discussion it was established that NT essentially fills order with a 1 tick (timewise) delay between sample and fill and it was suggested somewhere that this may alleviate the need to worry about the spread. I am not convinced about that.

One way to deal with this may be to wait for an uptick before filling a BUY and wait for a down tick before filling a SELL.

In this case people may need to have at least 1 Second data to accurately backtest systems based on 1 Minute bar indicators.
Attached Images
File Type: png buyandsellatsameprice.PNG (44.3 KB, 3 views)
AlgoJason is offline  
Reply With Quote
Old 02-14-2018, 10:06 AM   #7
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,549
Thanks: 780
Thanked 1,994 times in 1,921 posts
Default

Hello AlgoJason,

Thank you for your response.

NinjaTrader backtesting would only run over one series, whether that is the Last, Bid, or Ask. This can be selected in the Data Series settings of the Chart or Strategy Analyzer under the 'Price Based On' option.

You can run with Tick Replay to have the bars build based on the tick by tick information. Please visit the following links on Tick Replay:
Please let me know if you have any questions.
NinjaTrader_PatrickH is offline  
Reply With Quote
The following user says thank you to NinjaTrader_PatrickH for this post:
Old 02-14-2018, 02:21 PM   #8
AlgoJason
Member
 
Join Date: Jan 2018
Posts: 32
Thanks: 18
Thanked 2 times in 2 posts
Default

Quote:
Originally Posted by NinjaTrader_PatrickH View Post
Hello AlgoJason,

Thank you for your response.

NinjaTrader backtesting would only run over one series, whether that is the Last, Bid, or Ask. This can be selected in the Data Series settings of the Chart or Strategy Analyzer under the 'Price Based On' option.

You can run with Tick Replay to have the bars build based on the tick by tick information. Please visit the following links on Tick Replay:
Please let me know if you have any questions.
I agree that NT only runs over a single data series. But if you have Trade/last data then that series inherently contains embedded within it some bid and some ask data.

Trade/Last data flicks between the bid and the ask rapidly. The image I posted illustrates this and that NT sometimes (probably 50% of the time) fills longs at the bid and sells at the ask which leads to unrealistic backtest results in some cases, especially with faster systems.

I think we are discussing this in this thread now...
https://ninjatrader.com/support/foru...d.php?t=107827
AlgoJason is offline  
Reply With Quote
Old 02-15-2018, 11:07 AM   #9
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,549
Thanks: 780
Thanked 1,994 times in 1,921 posts
Default

Quote:
Originally Posted by AlgoJason View Post
I think we are discussing this in this thread now...
https://ninjatrader.com/support/foru...d.php?t=107827
Agreed, I will follow up with you there.
NinjaTrader_PatrickH 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
Not ordering correctly by Avg. Trade marticora Platform Technical Support 3 11-21-2016 10:05 AM
Explain POINT VALUE in calculation of Cumulative Profit or Avg Trade Steven Gold Platform Technical Support 3 04-14-2015 08:54 AM
Calculate moving avg on time values different than session times dancorcal Indicator Development 1 02-09-2010 04:36 PM
Strategy: Resetting values at the beginning of new trading sessions NinjaTrader_JoshP Reference Samples 0 07-29-2009 01:49 PM


All times are GMT -6. The time now is 02:04 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.