improving responsiveness on automated strategy - TradeStation | futures io social day trading
futures io futures trading


improving responsiveness on automated strategy
Updated: Views / Replies:694 / 5
Created: by maggtrading Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

improving responsiveness on automated strategy

  #1 (permalink)
Trading Apprentice
méxico df, méxico
 
Futures Experience: Advanced
Platform: ninjatrader, tradestation
Broker/Data: demo so far
Favorite Futures: stocks, fdax, fdxm, fesx, rb, ho, ng, cl, tf, nq, bp, ec, jy
 
Posts: 46 since Mar 2013
Thanks: 115 given, 21 received

improving responsiveness on automated strategy

hello everyone,



i have posted a couple of questions before and have had great response as well as helpful coding advice. i have an automated strategy i have traded live and in the simulator with rather promising results, but i would still like to improve it further. the issue is that being a moving average cross strategy, my code misses a lot of entries it should make, and it also holds positions way past price levels where it should close / reverse them (let's say it holds a short position after price has clearly crossed over the average where it should reverse into a long position).



i adapted the moving average cross that comes with tradestation. the original entries and exits for a long trade look like this:



movavg cross le:


{ Buys if Price crosses over Avg and then stays above Avg for one or more bars }

inputs: Price( Close ), Length( 9 ), ConfirmBars( 1 ) ;
variables: Counter( 0 ) ;

if Price > AverageFC( Price, Length ) then
Counter = Counter + 1
else
Counter = 0 ;

if CurrentBar > ConfirmBars and Counter = ConfirmBars then
{ CB > ConfirmBars check used to avoid spurious cross confirmation
at CB = ConfirmBars }
Buy ( "MACrossLE" ) next bar at market ;


{ ** Copyright (c) 2001 - 2010 TradeStation Technologies, Inc. All rights reserved. **
** TradeStation reserves the right to modify or overwrite this strategy component
with each release. ** }




movavg cross lx:

inputs: Price( Close ), Length( 9 ) ;
variables: Avg( 0 ) ;

Avg = AverageFC( Price, Length ) ;

if CurrentBar > 1 and Price crosses under Avg then
{ CB > 1 check used to avoid spurious cross confirmation at CB = 1 }
Sell ( "MACrossLX" ) next bar at market ;


{ ** Copyright (c) 2001 - 2010 TradeStation Technologies, Inc. All rights reserved. **
** TradeStation reserves the right to modify or overwrite this strategy component
with each release. ** }





mine are practically the same, i just use one moving average length for long and another for short trades:




if Price > AverageFC( Price, Lengthl ) then
Counterl = Counterl + 1
else
Counterl = 0 ;

if CurrentBar > ConfirmBarsl and Counterl = ConfirmBarsl then


Buy PSize Shares next bar at open ;


Avgl = AverageFC( Price, Lengthl ) ;

If MP = 1 and Price < ( Avgl + BarSizelx ) then


Sell all shares next bar at open ;



but, as i mentioned at first, if i optimize the strategy leaving some data out of sample it looks good, but when the strategy is then extended to the out of sample period it just misses a lot of entries and reversals. i include a picture in daily bars to illustrate how the strategy should go short / reverse / exit a long position when price breaks clearly below the lowest simple moving average and go long / reverse / exit a short position when price moves clearly above the highest sma but doesn't. in this amzn trade, the strategy should have dropped the short position as soon as price is above the highest average, yet it stupidly holds it until the second time price crosses over the sma. is there a way to improve the responsiveness of the strategy? either using some other entry / exit code or maybe using several redundant sets of entries / exits (using both - Price crosses under Avg - and - Price < Avg -) ?


Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).



oks, thanks a lot, any help will be enormously appreciated,

Reply With Quote
 
  #2 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,529 since Apr 2013
Thanks: 230 given, 854 received
Forum Reputation: Legendary

maggtrading,

can you post the short entries and exits and the settings you used to come up with the posted chart?

Regards,
ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #3 (permalink)
Trading Apprentice
méxico df, méxico
 
Futures Experience: Advanced
Platform: ninjatrader, tradestation
Broker/Data: demo so far
Favorite Futures: stocks, fdax, fdxm, fesx, rb, ho, ng, cl, tf, nq, bp, ec, jy
 
Posts: 46 since Mar 2013
Thanks: 115 given, 21 received


ABCTG,



danke.



this is the code for the short trades. entries do require a couple additional conditions, but exits are coded just like this, which makes it very frustrating when the strategy is not even close to following this logic:



if Price < AverageFC( Price, Lengths ) then
Counters = Counters + 1
else
Counters = 0 ;

if CurrentBar > ConfirmBarss and Counters = ConfirmBarss then


Sell Short PSize Shares next bar at open;



Avgs = AverageFC( Price, Lengths ) ;

If MP = -1 and Price > Avgs then


Buy To Cover all shares next bar at open ;



i have coded the same concept into an indicator as illustrated in the image, and the crosses can be easily seen graphically but an automated strategy won't act on them.

Reply With Quote
 
  #4 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,529 since Apr 2013
Thanks: 230 given, 854 received
Forum Reputation: Legendary

maggtrading,

you are welcome. Putting your code pieces together into one signal I don't see any issues there.
It closes open trades when the price is above/below the respective average and the entries occur when price
is above/below the average for enough bars.

 
Code
inputs: Price( Close ), Lengthl( 9 ), Lengths( 18 ), ConfirmBarsl( 1 ), ConfirmBarss( 1 ) ;
variables: Counterl( 0 ), Counters( 0 ), PSize ( 1 ), Avgl( 0 ),  Avgs( 0 ), MP ( 0 );

MP = MarketPosition;

if Price > AverageFC( Price, Lengthl ) then
	Counterl = Counterl + 1
else
	Counterl = 0 ;

if CurrentBar > ConfirmBarsl and Counterl = ConfirmBarsl then
	Buy PSize Shares next bar at open ;


Avgl = AverageFC( Price, Lengthl ) ;

If MP = 1 and Price < ( Avgl {+ BarSizelx} ) then
	Sell all shares next bar at open ;


if Price < AverageFC( Price, Lengths ) then
	Counters = Counters + 1
else
	Counters = 0 ;

if CurrentBar > ConfirmBarss and Counters = ConfirmBarss then
	Sell Short PSize Shares next bar at open;

Avgs = AverageFC( Price, Lengths ) ;

If MP = -1 and Price > Avgs then
	Buy To Cover all shares next bar at open ;
Regards,
ABCTG


maggtrading View Post
ABCTG,



danke.



this is the code for the short trades. entries do require a couple additional conditions, but exits are coded just like this, which makes it very frustrating when the strategy is not even close to following this logic:



if Price < AverageFC( Price, Lengths ) then
Counters = Counters + 1
else
Counters = 0 ;

if CurrentBar > ConfirmBarss and Counters = ConfirmBarss then


Sell Short PSize Shares next bar at open;



Avgs = AverageFC( Price, Lengths ) ;

If MP = -1 and Price > Avgs then


Buy To Cover all shares next bar at open ;



i have coded the same concept into an indicator as illustrated in the image, and the crosses can be easily seen graphically but an automated strategy won't act on them.


Reply With Quote
 
  #5 (permalink)
Trading Apprentice
méxico df, méxico
 
Futures Experience: Advanced
Platform: ninjatrader, tradestation
Broker/Data: demo so far
Favorite Futures: stocks, fdax, fdxm, fesx, rb, ho, ng, cl, tf, nq, bp, ec, jy
 
Posts: 46 since Mar 2013
Thanks: 115 given, 21 received

put some work into this and seemingly solved it. i share my conclusions in case it could be of help to someone.


my code initially looked like this:



if Price + alteration > AverageFC( Price, Lengthl ) then
Counterl = Counterl + 1
else
Counterl = 0 ;

if CurrentBar > ConfirmBarsl and Counterl = ConfirmBarsl then


Buy PSize Shares next bar at open ;


Avgl = AverageFC( Price, Lengthl ) ;

If MP = 1 and Price < ( Avgl + alteration ) then


Sell all shares next bar at open ;


i coded the strategy again, going step by step, and i have found that it was better to define a line for long entry, another for long exit, short entry and short exit. seems like execution suffers massively if the strategy calls for additional operations to be performed simultaneously to the comparison between price and simple moving average.

so, it ended like this and the glitches seem solved:

leline = ( AverageFC( Price, Lengthl ) + alteration );
lxline = ( AverageFC( Price, Lengthl ) + alteration );

MP = marketposition;

if Price > leline then
Counterl = Counterl + 1
else
Counterl = 0 ;

if CurrentBar > ConfirmBarsl and Counterl = ConfirmBarsl then


Buy PSize Shares next bar at open ;


If MP = 1 and Price crosses under lxline then


Sell all shares next bar at open ;


short trades follow the same structure reversed.

Reply With Quote
The following user says Thank You to maggtrading for this post:
 
  #6 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,529 since Apr 2013
Thanks: 230 given, 854 received
Forum Reputation: Legendary

maggtrading,

good job. I had to block BarSizelx in the code I did as I had no idea what exactly its purpose was and therefore blocked it. That's why the code worked without an issue.

As you can't plot out of strategies it sometimes helps with the debugging to plot the entry conditions below the chart with an indicator. In your case this could be the counters or the exit condition.

You can do it like this for example:
 
Code
if Price < ( Avgl + alteration ) then
Plot1(+1)
else
Plot1(0);
Regards,
ABCTG


maggtrading View Post
put some work into this and seemingly solved it. i share my conclusions in case it could be of help to someone.


Reply With Quote

Reply



futures io > > > > improving responsiveness on automated strategy

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Call ATM Strategy on an automated strategy to control position jsengxx NinjaTrader Programming 7 May 31st, 2016 05:51 PM
Improving BW Alligator Strategy % profitable Manuel17 NinjaTrader 2 January 4th, 2014 04:35 PM
HugoHurley (automated strategy for MultiCharts) aknip Elite EasyLanguage Automated Trading 56 June 28th, 2013 12:56 AM
Semi Automated strategy kandlekid NinjaTrader Programming 7 June 7th, 2012 06:24 PM
Strategy SEMI AUTOMATED peter88 NinjaTrader Programming 1 January 25th, 2011 01:43 PM


All times are GMT -4. The time now is 04:23 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-14 in 0.12 seconds with 20 queries on phoenix via your IP 54.91.38.173