NexusFi: Find Your Edge


Home Menu

 





Attack of the Robots - An Algo Journal


Discussion in Trading Journals

Updated
      Top Posters
    1. looks_one vmodus with 357 posts (859 thanks)
    2. looks_two SMCJB with 38 posts (84 thanks)
    3. looks_3 kevinkdog with 27 posts (70 thanks)
    4. looks_4 bobwest with 13 posts (53 thanks)
      Best Posters
    1. looks_one bobwest with 4.1 thanks per post
    2. looks_two kevinkdog with 2.6 thanks per post
    3. looks_3 vmodus with 2.4 thanks per post
    4. looks_4 SMCJB with 2.2 thanks per post
    1. trending_up 93,967 views
    2. thumb_up 1,141 thanks given
    3. group 61 followers
    1. forum 478 posts
    2. attach_file 181 attachments




 
Search this Thread

Attack of the Robots - An Algo Journal

  #111 (permalink)
 
vmodus's Avatar
 vmodus 
Somewhere, Delaware, USA
 
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853

Well folks, I think this will be my last entry for the year. I have been up to my hips in upgrades the past few days, as well as preparing for the holidays. I will not be developing any new strategies or testing existing strategies, with the exception of letting my Eurodollar strategy run on the March 2020 contract (60 min timeframe) in simulation.

I have a lot of reading and studying to do in preparation for my Strategy Factory class in January. I want to be ready.

I plan to relax during the holidays, even though we have a lot happening. Anyhow, if I don't check in here until January, never fret, I will be back. If I come across a hilarious picture, I'll post it over on Funny Pic of the Day. The one I posted earlier today was pretty funny.

Happy holidays, peace on earth, and pass the eggnog.


~vmodus (a/k/a Santa Claus)

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
What broker to use for trading palladium futures
Commodities
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #112 (permalink)
 
vmodus's Avatar
 vmodus 
Somewhere, Delaware, USA
 
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853

Happy new year everyone!

I was able to get back to trading work last Friday. I flipped on my ED strategy, but there were no trades. I did not turn it on yesterday, mainly because I was working on other non-trading activities.

Friday:
My wife/business partner needed some help capturing values for a pivot strategy she has developed. I had written a function in Easylanguage to get the high and low session close over the past two trading sessions. It functioned okay, but then she wanted the high and low session close for three trading sessions. She specifically needed the session close from an intraday chart, not the close from the daily chart. We have learned that these values can change. Her strategy requires the session close values to function properly.

My earlier solution to get the value was a brute force method: go bar by bar, backwards (using a FOR loop), and once I get to the session close bar, store the value. There were two limitations to this approach: performance and accuracy.

Issue 1, performance:
The performance issue is not a problem on a live strategy, as it calculates in milliseconds. However, it becomes a problem when optimizing. At every bar, it loops backwards for 2-3 days. Here is what a 60 minute bar would do, in a worst case:
  • 23 bars per day * 1 (to get the value for day 1)
  • 23 * 2 (to get the value for day 2)
  • 23 * 3 (to get the value for day 3)
23 + 46 + 69 = 138 iterations
Again, this is not a problem bar-by-bar. But let's extrapolate: 1 month or 21 trading days * 23 bars per day * 138 = 66,654 iterations.

Now multiply by 12 for a year, and you get 799,848 iterations. Now let's optimize. Minimum optimization, as I understand, should have at least 10,000 scenarios. So now we have 7,998,480,000 iterations. That's 7.9 billion, just for that function. Now imagine what happens when we go to a smaller timeframe, like 5 minutes. Yikes. I will explain my simpler and more elegant solution in a moment.

Issue 2, accuracy:
I don't know why, but at the end of every month, on a continuous chart (e.g. @YM), the function comes back with zero for a session close. I think it is related to how dates are added and subtracted. In simple terms, dates are stored as numbers in TradeStation/EasyLanguage and I didn't account for that. But by this point, I'm not interested in fixing this problem.

A better solution:
I spent some time just thinking of a better way to do this. Really. Just sitting thinking, not doing anything else. To quote Lebowski: "my thinking has been very uptight", regarding this problem. My solution is much better (think elegant and simple) and doesn't require a separate function. Here is the logic, for storing the last three session close values:

Variables:
  • v_last_close
  • v_2_closes_ago
  • v_3_closes_ago
And the logic:
  1. Every day, check the session close time
  2. If we are at the session close, then:
    • move v_2_closes_ago to v_3_closes_ago
    • move v_last_close to v_2_closes_ago
    • store Close in v_last_close
  3. Get the minimum value of the three variables (lowest close)
  4. Get the maximum value of the three variables (highest close)

That is it. It only runs once per day and is 99% accurate, thus solving both issues. Performance for optimization and backtesting improves by about 97% for this section of code. It only has a problem (the 1% inaccuracy) on holidays or other days the market closes at a different time, where we may have an early session close (e.g. 1300 instead of 1700). We usually do not trade around a holiday, thus it doesn't matter for us. I can fix that, too, if I like, but for now it is good enough.

~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~

I did not get any trading work done yesterday, mainly due to other work commitments. Here are my plans for this week:
  • Turn on my ED strategy in sim and let it run. I can only describe this strategy as 'mercurial'. I cannot determine if it is a good strategy, a lucky strategy, or a bad strategy. Some results are breathtaking and other results are head scratching.
  • Revisit my old VX strategy and try to figure out why it was trying to take so many trades. This strategy has a ton of potential.
  • Start to build a process flow for strategy building, using the diagram in chapter 8 of Building Winning Algorithmic Trading Systems as a starting point.
I have some client commitments, so I need to focus on that. I am getting excited for my Strategy Factory course on January 29th. I am also excited to get to live trading in the near future.

~vmodus

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #113 (permalink)
 
vmodus's Avatar
 vmodus 
Somewhere, Delaware, USA
 
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853


I realized yesterday that I did not "show my work" from yesterday, as my teachers might have said. Below is a little EasyLanguage code snippet from my strategy that solved my three day close problem.
 
Code
//  Note: this does not account for markets that close early (e.g. holiday, emergency, etc.)
//      Also, the values are not populated until the fourth trading day
variables: 
   day_of_week(0) ,
   session_end_time(0) ,

   v_last_close(0) ,
   v_2_closes_ago(0) ,
   v_3_closes_ago(0) 
   ;
   
day_of_week = dayofweek(date) ;   // This is probably redundant, but I use day_of_week elsewhere in my strategy
session_end_time = SessionendtimeMS(FirstSessionMS(day_of_week)) ;

if time = session_end_time 
   Then  
      Begin
         v_3_closes_ago = v_2_closes_ago ;
         v_2_closes_ago = v_last_close ; 
         v_last_close = close ; 
      end ;
~vmodus

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #114 (permalink)
userque
Chicago IL
 
Posts: 180 since Apr 2016
Thanks Given: 573
Thanks Received: 130


vmodus View Post
I realized yesterday that I did not "show my work" from yesterday, as my teachers might have said. Below is a little EasyLanguage code snippet from my strategy that solved my three day close problem.
 
Code
//  Note: this does not account for markets that close early (e.g. holiday, emergency, etc.)
//      Also, the values are not populated until the fourth trading day
variables: 
   day_of_week(0) ,
   session_end_time(0) ,

   v_last_close(0) ,
   v_2_closes_ago(0) ,
   v_3_closes_ago(0) 
   ;
   
day_of_week = dayofweek(date) ;   // This is probably redundant, but I use day_of_week elsewhere in my strategy
session_end_time = SessionendtimeMS(FirstSessionMS(day_of_week)) ;

if time = session_end_time 
   Then  
      Begin
         v_3_closes_ago = v_2_closes_ago ;
         v_2_closes_ago = v_last_close ; 
         v_last_close = close ; 
      end ;
~vmodus

Could you use close[1], close[2], close[...], close[n] etc. instead of keeping track of the close values yourself?

Reply With Quote
  #115 (permalink)
 
vmodus's Avatar
 vmodus 
Somewhere, Delaware, USA
 
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853

Well, today was an interesting day. I spent some time researching and learning about ATR, or Average True Range. I explored this last Spring, but I tabled it. There was a specific article in TASC (aka Stocks & Commodities magazine) which featured an alternative calculation for ATR. I foolishly did not bookmark or otherwise save it, so it is lost until I stumble across it again.

Anyhow, I have been looking for a complimentary indicator for the trend-following and cycle indicators I use, specifically a volatility indicator. I read a couple of articles about ATR by Jeff Swanson on easylanguagemastery.com. I spent a little time learning about ATR, including this cool video from Reyner Teo:


It was very informative, though I think it needs several viewings to get a good grasp of how I can utilize it.

At first blush, I can see some value on Eurodollar, (EDH20, 60 minute):


The general idea, at least for me, is to stay out of the market during low volatility. As you can see above, I probably wouldn't trade when ATR is below a certain level. I drew an arbitrary line to give me a reference point in my thinking. I'm not sure ATR is totally useful for my ED strategy (it would have filtered two small but profitable trades), but it definitely has promise on some other futures instruments.

~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~

In trading news, for some reason, I have not been running my ED strategy in sim. I guess I should have, if nothing else than to validate what I think I know (that maybe it works?). I looked at my strategy performance report and I would have had one trade (you can see it above), for a $220 net profit (after commissions and fees).

~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~

Tomorrow:
  • Run my ED strategy in sim (duh)
  • Work on my old VX strategy
  • Catch-up on trading videos and reading that I have piling up

Have a great evening and catch you on the other side of today!


~vmodus

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #116 (permalink)
 
vmodus's Avatar
 vmodus 
Somewhere, Delaware, USA
 
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853


userque View Post
Could you use close[1], close[2], close[...], close[n] etc. instead of keeping track of the close values yourself?

Sadly, no. We tried using a daily chart ( close[1], etc. ) on Data2, but the daily close is not always the same as the session close. Rationally, I would expect that, but it isn't the case. I'm guessing this is due to the settlement after the close and whatever adjustments are happening on the exchange side.

This solution is actually really simple and easy once I figured it out. It is lightweight, as the condition is only met once per day.

~vmodus

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #117 (permalink)
 
vmodus's Avatar
 vmodus 
Somewhere, Delaware, USA
 
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853

So today I tried to work on the things I set as my activities today.

ED Strategy:
I set this up before I went to bed, automated, in my sim account. Trading for this strategy starts at 400. There were no entries triggered until 1400, but my sim order did not get filled until nearly 1430, due to unusually low volume. I have end of day exits setup, so I exited at 1600, with a loss of -$24, which was all commission.

Below is what it looks like:


So if I had applied an ATR filter, this trade may not have happened. It doesn't really matter, as all I lost was commission. A better exit would have been profitable, but it is a hard market order at end of day.

VX Strategy Redux:
I spent some time rewriting my VX strategy to incorporate some of the changes I've made to variants of the strategy. I started testing on the 60 minute chart, with mixed results. I need to dig in and make sure it is taking the entries it should.

~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~

Well, it is late and I am tired. I'll work on this more tomorrow.

~vmodus ... out

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #118 (permalink)
 
vmodus's Avatar
 vmodus 
Somewhere, Delaware, USA
 
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853

Well, today was a pretty interesting day. I'll make it quick because I want to get away from my desk.

ED Strategy
Trading on the Eurodollar (EDH20, 60 minute), my strategy was flat like yesterday, taking one trade. I exited early to break even, rather than take a potential -$125 hit. Again, ATR was low, as seen here:


I like that the strategy is working 100% as expected. Seriously, that is kind of a big deal. The last couple of days have been quiet for Eurodollar, so I'm not going to stress that. I will consider going live with one contract next week, as it is a low risk proposition.

VX Strategy
I feel like Dr. Frankenstein, raising my monster, made from all sorts of odd parts of old strategies, from the dead. I didn't like one thing happening with my strategy on the VX. My exit criteria for a long entry was, in pseudocode:
 
Code
if iTrend > Trigger, sell short
(For those who haven't been following this journal, these are two trendlines....my strategy is a 'simple' [hahaha] crossover strategy). The problem with the criteria above is that, for VX, iTrend = Trigger too often, thus exits were being missed. I hadn't really noticed until I checked the chart against the signals and saw missed or delayed exits.

Anywho....I fixed that today, for both the short and long side.
 
Code
if iTrend >= Trigger, sell short
Yeah, it was simply 'greater than or equal to'. Of course that required a who bunch of retesting and walk-forward optimization, but I expected better results due to code change. Since this is a VX specific strategy, I tested two timeframes:
  • 60 minute: Overall okay, but testing was a mixed bag, in particular walk-forward. Equity curve is upward, but too much like a shark's mouth for my liking.
  • 5 minute: Pretty good, to the point that I wanted to see how it would perform in sim. I turned it on for the last 90 minutes of my trading window (1430 to 1600) and it did fine, make a little money for my sim account, about $193 (I was focused on execution, not).
I would like to test an intermediate timeframe, maybe 15 or 30 minute. Things can move fast on this, so the 60 minute timeframe is not ideal.

Sim Account:
So I started the week somewhere around $16,050 and am closing the week at $16,247, +197 (or so)


~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~

Next Week:
  • I have a bunch of client activities to do next week. So I better work on those things.
  • I will let the Eurodollar strategy continue to run in sim;
  • Decide to go live with one contract of the Eurodollar with my strategy;
  • Sim test VX strategy on 5 minute for a full day.

Okay, that wasn't quick at all. Anyhow, I happily go into the weekend with two potentially profitable strategies. I'm tired of being on the bench and am ready to get back to, you know, trading.

Have a great weekend all! See you Monday!

~vmodus

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #119 (permalink)
 
vmodus's Avatar
 vmodus 
Somewhere, Delaware, USA
 
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853

Happy Monday folks! I was going to post an explanation of the VX that I wrote over the weekend, as a refresher for those who are not familiar. Unfortunately, it got lost in a system crash (thanks again TradeStation), so that will have to wait until I can rewrite it. VX is a funny little instrument.

Today, I enabled both of my strategies in sim:
  • VXF20 5 minute
  • EDH20 60 minute

VXF20 (VIX Futures) 5 minute
This was the boss today. I changed the starting time for this strategy from 800 ET to 900 ET, just to take advantage of trading in the highest volume periods of the day. After a slow start (first entry at 1025 ET), it chugged along slowly until it hit a range and generated more signals. This is an 'always in' strategy, trading between 900 and 1600. Any exit from the long side is an entry to the short side, and vice versa. The only times we are out is at the beginning of the day (until our first signal), if stopped out, and at 1600, when we exit all positions.

We had 12 entries, which is kind of high for this strategy. Between 1430 and 1530, a one hour stretch, we generated 5 entries. We were in a range, so that was about right. This strategy loves a range, since the limit orders are set at the tops and bottoms of the range, for the most part. We got on the right side (short) of the last big move of the day:



Strategy Performance Report versus Sim Trading
  • Strategy Report: Net Profit = $740
  • Sim Trading: Net Profit = $724
  • Win rate = 100% (just one of those days)
  • Sim trading missed one entry ($45 net profit), but that is to be expected (11 trades in sim versus 12 trades in the strategy performance report)
  • Strategy performance report uses a higher commission ($2.50 each way) than the sim engine. I am using a higher commission for my strategy performance report, because that seems to be the total cost of trading this, at least according to my old statement.
The differences between the two is than one trade was not filled and the differences in commissions.

One final note about the VX: I may need to scale back the timescale to 10 or 15 minutes if/when I go live if I am having issues getting orders filled. This strategy works well in several timeframes, including 60 minute.

~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~

Eurodollar (EDH20) 60 Minute
Boring. No trades. There was one signal that occurred right before I start trading (400 bar). From there the market declined slowly, but it was otherwise pretty quiet.

~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~

What I liked:
  • Both strategies required zero intervention
  • I was not freaked out by my lack of understanding the VX orders, as I was last Spring
  • My code executed perfectly (even with the missed order...it was the market's fault)
  • All of the issues I had with VX appear to have been resolved
  • The EOD code for my end of day exit worked (I may push it a couple of bars earlier....TBD)

What I did not like:
  • Nuthin'

This is all sim trading, so these results would probably not match live. I am encouraged that sim is closely following the strategy performance report for both VX and ED. We are one step away from live trading both of these strategies. Unfortunately I cannot trade sim and live at the same time, so I will have to figure out something there.

~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~

Tomorrow:
  • Client work
  • Watch sim for VX and ED

~vmodus

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #120 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,388
Thanks Received: 10,207



userque View Post
Could you use close[1], close[2], close[...], close[n] etc. instead of keeping track of the close values yourself?


vmodus View Post
Sadly, no. We tried using a daily chart ( close[1], etc. ) on Data2, but the daily close is not always the same as the session close. Rationally, I would expect that, but it isn't the case. I'm guessing this is due to the settlement after the close and whatever adjustments are happening on the exchange side.

This solution is actually really simple and easy once I figured it out. It is lightweight, as the condition is only met once per day.

~vmodus

On a daily bar the close is the official settlement price which is different than the last trade. For example with Crude / CL the settlement window where the settlement price is determined is from 1:28pm to 1:30pm Central but the last trade occurs at 4pm when Globex shuts. That 2.5 hour difference can result in some significant differences in close/settlement and last trade. A way round this is to use 1440 min bars. These are effectively daily bars but with the actual last trade of the day rather than the settlement price.

Reply With Quote
Thanked by:




Last Updated on March 31, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts