• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

TraderGav.com

Gav's trading blog - Perseverance, Consistency, Confidence

  • Home
  • Start Here
    • Back to Basics of Trading
    • Resource For Traders โ€“ The Best Tools for Traders
    • Learn Trading Articles
    • Sierra Chart Resource
  • Blog
    • Blog Posts
    • Other learning resource
    • Dummy Collection
    • Harmonic setups
  • About Me

About programming and trading

by Gav 28 Comments

About Programming and trading
About Programming and Trading

Don’t get me wrong, I am not selling any trading system here. Before I go into the main point, I am thinking of sharing some of my new findings of Tradestation.

I spent most of the past weekend reading some books in my trading library and playing with EasyLanguage programming on Tradestation.

I was preparing the program for backtesting, and to my surprise, I was in fact, automating my dummy trading system.

With the help of some functions in Tradestation, I am able to fire basket orders for execution automatically. Well, good findings, but, now it is not the time for me to utilize it. Anyway, It is useful to Asian traders like me, who trades in the middle of the night. I can always replace the order function with Alert, just to wake me up when an opportunity appears.

Some thoughts from programming.

As you might know, to code a piece of software, you need to have a defined program flow, logic, specific declarations, input, and return values, etc. (I know some readers like ZBS, Eyal, and Richard are far better than me when it comes to these IT stuffs, so please correct me if I sound funny).

You can’t have something which is ambiguous. You gotta tell the program what it should do. I have no problem with coding, but I was stopped a couple of times when programming my trading system. I have realized that I have been making too many assumptions and judgments when I was making dummy trades.

For example, “we want the price pull back to the area near 20-EMA”. Fine. How “near” is considered near? 1 tick, 2 ticks or 5 ticks away from 20-EMA? Another example, “We want to enter the trade above a narrow range bar”. Excellent idea. But how “narrow” is considered as narrow? One more example, “When the price is trending up, I would go long” , Cool.

Hey, What do you mean by trend up?

Dave commented on my system before as “I see there is a lot of “play” in the system, In other words, there are a lot of guidelines, there are very few real rules.” I fully understand his point when I started programming.

Here are some suggestion to evaluate if you really have a set of real trading rules for your system. You don’t have to do the boring coding. Instead, I would suggest trying to write out Pseudocode of your system. For example, a simple moving average crossover system should look like something like this

If 5-EMA crosses above 20-EMA then
  if High-Low <=1.5 points and (low-20-EMA)<=2 ticks then 
    Buy next at high +1 Tick. 
    Stop loss at low - 1 Tick 
  end
end

(The code above is for illustration purpose, you will go burst trading that)

Nothing so technical, but it is one of the ways to think through and stop cheating yourself by thinking you do have rules.

Guidelines are just not enough.

I have found it to be inefficient when I need to make too much judgment and guessing during the trading sessions.

I am not suggesting to have any magic values for narrow range candle or distance from EMA, but you need to be specific in defining your system.

Just a quick note to share something which I find to be useful, nothing fancy. I am still working on backtesting.

If you are interested in learning more about trading, make sure to check out my Back to Basics of Trading series.

Filed Under: Back to Basic, Learn Trading Tagged With: Strategy & tools

Reader Interactions

Comments

  1. Richard says

    at 4:19 am

    I have been programming computers so long, I tend to define my guidelines in ways that could be programmed. ๐Ÿ™‚

    There are methods to deal with fuzzy and inexact concepts and values (like “near” and “narrow”), but the underlying math does eventually turn the decision into a binary yes/no. Though, I should point out, the underlying mechanism in your brain turns the decision into a binary yes/no at some point as well–so the programming is really just a matter of reconstructing the rules that you internally use to define “narrow” in each context.

    Of course that’s a lot harder than it initially sounds to most people, until they sit down and try to program it themselves, of course! That’s why your pseudocode idea is good, as long as people have a good enough concept of what a machine can and can’t do when they try it.

    Reply
  2. Richard says

    at 12:19 pm

    I have been programming computers so long, I tend to define my guidelines in ways that could be programmed. ๐Ÿ™‚

    There are methods to deal with fuzzy and inexact concepts and values (like “near” and “narrow”), but the underlying math does eventually turn the decision into a binary yes/no. Though, I should point out, the underlying mechanism in your brain turns the decision into a binary yes/no at some point as well–so the programming is really just a matter of reconstructing the rules that you internally use to define “narrow” in each context.

    Of course that’s a lot harder than it initially sounds to most people, until they sit down and try to program it themselves, of course! That’s why your pseudocode idea is good, as long as people have a good enough concept of what a machine can and can’t do when they try it.

    Reply
  3. Gav says

    at 5:44 am

    Richard, thanks for your comment.
    I realized how weak is my “system” when I started writing codes. It is also a good way to organize trading ideas into a logical flow and it helps to make a better trading decision.

    Have a great week ahead!

    Gav

    Reply
  4. Gav says

    at 1:44 pm

    Richard, thanks for your comment.
    I realized how weak is my “system” when I started writing codes. It is also a good way to organize trading ideas into a logical flow and it helps to make a better trading decision.

    Have a great week ahead!

    Gav

    Reply
  5. Eyal says

    at 6:36 pm

    I wish I knew something about programming ๐Ÿ™‚ I went a similar route to yours some years back using both TradeStation and WealthLab. I gave up on trying to even backtest the dummy system not to metion automate future trades because of similar difficulties you mentioned. It probably can be done but the effort would be quite significant and the data available has to be to correct. For example measuring the pace a stock trades and not just volume.
    I think the benefit of what you are doing is in at least defining to yourself as much as possible what are your candidate selection/entry/exit criteria etc.

    Reply
  6. john says

    at 1:21 pm

    great post…interesting idea

    Reply
  7. john says

    at 9:21 pm

    great post…interesting idea

    Reply
  8. boots says

    at 1:04 am

    I find it almost impossible to code Tradstation well enough to do all my “thinking”. As you say, it is hard to turn somethings into code. What I have done is write code for the radar screen that looks for those “fuzzy” rules I have. You can have the radar screener look for those instances that would include what you are looking for. Example: you can have the program look for stocks that are “near the 20 RMA” by saying 8 tics is near enough I want to take a look. This way the computer looks over 1,000 stocks every second and brings you the ones that Might meet your needs. So you get a short list of 10 stocks and out of that you find 3. Much better than pouring over 1,000 charts by hand. These searches can get pretty specific and look for a huge combination of “Fuzzy Little Things”. With a little work you can write one that will hand you a small list that will include those needles in the hay stack.

    Reply
  9. Gav says

    at 2:25 pm

    John, thanks!

    Reply
  10. Gav says

    at 10:25 pm

    John, thanks!

    Reply
  11. Born2Code says

    at 11:16 pm

    i just spent the weekend doing the same with tradestation. i have the platform but my funds have not arrived yet from my old broker. Looking visually at the chart shows that i should be doing better than the backtesting results. I cannot yet figure out all the things to make it “think” like i do. Or maybe, my thinking needs to adjust.
    Either way, it is really interesting so far. Once i have more time and figure out more of this stuff i will put it into action with real money and see how it pans out.
    by the way, Teresa Lo has a black-box system on her website for sale. it works with tradestation among others.

    Reply
  12. boots says

    at 5:04 pm

    I find it almost impossible to code Tradstation well enough to do all my “thinking”. As you say, it is hard to turn somethings into code. What I have done is write code for the radar screen that looks for those “fuzzy” rules I have. You can have the radar screener look for those instances that would include what you are looking for. Example: you can have the program look for stocks that are “near the 20 RMA” by saying 8 tics is near enough I want to take a look. This way the computer looks over 1,000 stocks every second and brings you the ones that Might meet your needs. So you get a short list of 10 stocks and out of that you find 3. Much better than pouring over 1,000 charts by hand. These searches can get pretty specific and look for a huge combination of “Fuzzy Little Things”. With a little work you can write one that will hand you a small list that will include those needles in the hay stack.

    Reply
  13. Eyal says

    at 3:31 am

    Good point, Gav. I forgot you’re doing it on futures. Good luck.

    Yes I want to visit Vivocity, looks quite impressive but I haven’t been there yet. I heard the cinema has premium seats, might be worth checking it out. Know any cute lady you can intro me? ๐Ÿ˜›

    Reply
  14. Eyal says

    at 2:36 am

    I wish I knew something about programming ๐Ÿ™‚ I went a similar route to yours some years back using both TradeStation and WealthLab. I gave up on trying to even backtest the dummy system not to metion automate future trades because of similar difficulties you mentioned. It probably can be done but the effort would be quite significant and the data available has to be to correct. For example measuring the pace a stock trades and not just volume.
    I think the benefit of what you are doing is in at least defining to yourself as much as possible what are your candidate selection/entry/exit criteria etc.

    Reply
  15. Eyal says

    at 11:31 am

    Good point, Gav. I forgot you’re doing it on futures. Good luck.

    Yes I want to visit Vivocity, looks quite impressive but I haven’t been there yet. I heard the cinema has premium seats, might be worth checking it out. Know any cute lady you can intro me? ๐Ÿ˜›

    Reply
  16. Gav says

    at 1:34 am

    Hey Eyal,
    I am not trying to backtest Dummy. Instead, I am working on my own version of dummy system. As you know, dummy trading can be very different for every trader.
    I understand it takes a great effort to do that. Though I am not a big fan of backtesting , I decided to give it a try.
    I guess for stocks trader, it might be a little more complicated, at least , you need a bigger database for scanning. I am only focusing on few futures contracts, so hopefully, it is not as complicated.

    So far, I have gained positive results from the progress, like understanding deeper about my own system, rules and fine tune my risk management stuffs.

    Have a great December!

    Btw, maybe you can try out Movie theater at Vivo City, pretty cool ๐Ÿ™‚

    Reply
  17. Gav says

    at 9:34 am

    Hey Eyal,
    I am not trying to backtest Dummy. Instead, I am working on my own version of dummy system. As you know, dummy trading can be very different for every trader.
    I understand it takes a great effort to do that. Though I am not a big fan of backtesting , I decided to give it a try.
    I guess for stocks trader, it might be a little more complicated, at least , you need a bigger database for scanning. I am only focusing on few futures contracts, so hopefully, it is not as complicated.

    So far, I have gained positive results from the progress, like understanding deeper about my own system, rules and fine tune my risk management stuffs.

    Have a great December!

    Btw, maybe you can try out Movie theater at Vivo City, pretty cool ๐Ÿ™‚

    Reply
  18. Gav says

    at 1:56 am

    Boots,
    Absolutely. I agree it is impossible to code your thinking perfectly. As much as I can do, I will put it into code for all the rules I have. This is to eliminate as much guessing as possible during trading session. You know, It is a waste of time to guess something like “is the candle narrow enough”? or “is this considered near EMA”?
    That’s why, I do not go for automated trading system. Like what you’ve mentioned, I need a watchlist or alert. And, for trading, certain degree of human intervention is still needed, just my opinion. ๐Ÿ™‚

    Reply
  19. Gav says

    at 9:56 am

    Boots,
    Absolutely. I agree it is impossible to code your thinking perfectly. As much as I can do, I will put it into code for all the rules I have. This is to eliminate as much guessing as possible during trading session. You know, It is a waste of time to guess something like “is the candle narrow enough”? or “is this considered near EMA”?
    That’s why, I do not go for automated trading system. Like what you’ve mentioned, I need a watchlist or alert. And, for trading, certain degree of human intervention is still needed, just my opinion. ๐Ÿ™‚

    Reply
  20. Gav says

    at 5:09 am

    Sure Eyal,
    I will keep you “informed” if I meet some cute lady.
    ๐Ÿ˜†

    Reply
  21. Gav says

    at 1:09 pm

    Sure Eyal,
    I will keep you “informed” if I meet some cute lady.
    ๐Ÿ˜†

    Reply
  22. Benjamin Boyle says

    at 5:22 am

    Hi,

    http://elitetrader.com/tr/

    Cheers / Ben

    Reply
  23. Benjamin Boyle says

    at 1:22 pm

    Hi,

    http://elitetrader.com/tr/

    Cheers / Ben

    Reply
  24. Gav says

    at 5:35 am

    Hey Ben,
    Thanks for the link!

    Gav

    Reply
  25. Gav says

    at 1:35 pm

    Hey Ben,
    Thanks for the link!

    Gav

    Reply
  26. mc says

    at 2:06 pm

    Gav,

    I also have an automated scanning tool I call MONEYMAKER. It is a crossover system of 3 moving averages.

    Trade Well.

    Reply
  27. mc says

    at 10:06 pm

    Gav,

    I also have an automated scanning tool I call MONEYMAKER. It is a crossover system of 3 moving averages.

    Trade Well.

    Reply
  28. Born2Code says

    at 6:50 pm

    i just spent the weekend doing the same with tradestation. i have the platform but my funds have not arrived yet from my old broker. Looking visually at the chart shows that i should be doing better than the backtesting results. I cannot yet figure out all the things to make it “think” like i do. Or maybe, my thinking needs to adjust.
    Either way, it is really interesting so far. Once i have more time and figure out more of this stuff i will put it into action with real money and see how it pans out.
    by the way, Teresa Lo has a black-box system on her website for sale. it works with tradestation among others.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Best Tools For Traders

My Name is Gav.
I am a Father, Husband, Trader, And Blogger. A serious coffee addict. I started training since 2005, mainly on FX and Futures.

About Me

Footer

Recommend FX Charting

Recommended Training

FXSAnalytics

Copyright © 2023 ยท Affiliate Disclosure ยท Privacy