Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Like Tree2Likes

Reply
Old 10-26-2011, 11:48 PM   #1

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Object-Oriented Programming OOP

This thread is dedicated to understanding and discussing the basics of Object-Oriented Programming.

Tutorial from Java

What is an object? Oracle.com

__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
Old 10-26-2011, 11:51 PM   #2



Join Date: Apr 2010
Posts: 1,103
Ignore this user

Thanks: 125
Thanked 392 Times in 224 Posts

Re: Object-Oriented Programming OOP

Great idea ... I'm a programmer by trade so I will be more than happy to help and answer questions ... bring them on!

MMS
__________________
Traders Laboratory is 100% Free due to our generous ad sponsors.
Be sure to support them - they support Traders Laboratory!

Featured Brokers include:
Alpari | Mirus Futures

Featured Services:
NinjaTrader | Kinetic | INO Trading Course
MadMarketScientist is offline  
Reply With Quote
Old 10-27-2011, 11:49 AM   #3

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: Object-Oriented Programming OOP

Quote:
Originally Posted by MadMarketScientist »
Great idea ... I'm a programmer by trade so I will be more than happy to help and answer questions ... bring them on!

MMS
When you first learned OOP basics, can you recall anything that didn't make sense to you? Did you learn it quickly? Are there things that quickly made sense to you? Was there anything about OOP that took a while for you to understand? Did you need to develop a different way of thinking? Is there anything about OOP that you confuse with procedural programing? Is there anything about OOP that you still make a mistake on? These are the kinds of things that I'd be interested in hearing about; from you or anyone else.
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
Old 10-27-2011, 02:32 PM   #4



Join Date: Apr 2010
Posts: 1,103
Ignore this user

Thanks: 125
Thanked 392 Times in 224 Posts

Re: Object-Oriented Programming OOP

Quote:
Originally Posted by Tradewinds »
When you first learned OOP basics, can you recall anything that didn't make sense to you?
This applies to programming in general but understanding and being able to program something using recursion. Once you understand this, OO becomes much easier as you are now able to think about objects\reuse\etc in an abstract way.

Quote:
Originally Posted by Tradewinds »
Did you learn it quickly? Are there things that quickly made sense to you?
Too me, basic OO is just a way to organize data\code into useful, self-contained things - called objects. So instead of having 10 variables and 50 procedures\functions in a file, instead you have 5 objects each with 2 variables with 10 functions\properties each. So coding and understanding this is easier as you are breaking the problem down into something smaller and more manageable.

Quote:
Originally Posted by Tradewinds »
Was there anything about OOP that took a while for you to understand? Did you need to develop a different way of thinking?
Now there are advanced features of OO that took some more practice, like Inheritance and Polymorphism. These features are there to help reuse code. Summary:
1. Objects - used to organize code\functionality
2. Inheritence\Polymorphism - ways to reuse code and reduce copy\paste

Quote:
Originally Posted by Tradewinds »
Is there anything about OOP that you confuse with procedural programing? Is there anything about OOP that you still make a mistake on? These are the kinds of things that I'd be interested in hearing about; from you or anyone else.
I would say a common mistake is for people to 'over-engineer' their object hierarchies and incorrectly implement Inheritance and Polymorphism. I've seen OO programs much more damn confusing than a procedural programs. It all depends on using the tools correctly. OO gives plenty of rope for people to hang themselves with.

But given the complexity of software today, some applications would be nearly impossible without OO.

thx
MMS
__________________
Traders Laboratory is 100% Free due to our generous ad sponsors.
Be sure to support them - they support Traders Laboratory!

Featured Brokers include:
Alpari | Mirus Futures

Featured Services:
NinjaTrader | Kinetic | INO Trading Course
MadMarketScientist is offline  
Reply With Quote
Old 10-27-2011, 03:43 PM   #5

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: Object-Oriented Programming OOP

When OO came on the popular computing scene ~25 yr ago (largely due to the availability of personal computer to the general public), it was all hype and hoopla, it was the best thing invented since sliced bread. It was the "future" of programming.

25 years later, I am surprised to see TS taking it on as a trading language.

My personal take (only personal 2 cents' worth) -- it is a waste of otherwise useful and productive time for the non-programmers (especially traders) trying to learn and implement any serious and extensive OO programming project.

OO programming is a craft, not a skill.
It requires dedication and discipline to learn.
It requires total immersion to learn it well. (object thinking is a paradigm shift)
It requires practice practice and practice
(ie. getting paid to do it professionally on the boss' dime).

If you have not touched a piece of EasyLanguage code for 3 months,
you can pick it up and understand the operation immediately.

If you have not touched a piece of OO code for 3 months,
it might take you a day(s) to understand the heads and tails of things
(unless it is a very short code).

OO is great for big and complicated projects. (eg. a comprehensive autotrade)
EasyLanguage is good for small to medium sized indicators and simple autotrades.

For the full time trader and amateur programmer,
my advice is to stick to EasyLanguage and spend your precious time trading and making money, and if you have extra time, go and have fun doing things with the money you earned.

Again, don't mean to discourage anybody taking it on... this is only my 2 cents' worth of gut feelings. YMMV.
MadMarketScientist likes this.
__________________



Only an idiot would reply to a stupid post

Last edited by Tams; 10-27-2011 at 03:58 PM.
Tams is offline  
Reply With Quote
Old 10-27-2011, 03:48 PM   #6

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: Object-Oriented Programming OOP

Quote:
Originally Posted by MadMarketScientist »
Too me, basic OO is just a way to organize data\code into useful, self-contained things - called objects. So instead of having 10 variables and 50 procedures\functions in a file, instead you have 5 objects each with 2 variables with 10 functions\properties each. So coding and understanding this is easier as you are breaking the problem down into something smaller and more manageable.
thx
MMS
This sound interesting, and thank you for the feedback. What I'd be interested in seeing is two sets of very simple code, one procedural, one OO. For example, the price breaks the last high. Don't show all the code for how to determine the last high, just assume that we already have that. What would be the object? How would you program the condition of the current close going over the last high? I don't know if you could do it in pseudo code?

Code:
var: LastHigh(0), NewHigh(False);

NewHigh = Close > LastHigh;  // NewHigh is assigned a value of 'True' when condition met
How would OO code be different?
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
Old 10-27-2011, 05:35 PM   #7



Join Date: Apr 2010
Posts: 1,103
Ignore this user

Thanks: 125
Thanked 392 Times in 224 Posts

Re: Object-Oriented Programming OOP

Quote:
Originally Posted by Tradewinds »
What would be the object? How would you program the condition of the current close going over the last high? I don't know if you could do it in pseudo code?

Code:
var: LastHigh(0), NewHigh(False);

NewHigh = Close > LastHigh;  // NewHigh is assigned a value of 'True' when condition met
How would OO code be different?
I could see a vendor building the code this way - where the instrument (stock, etc) is the object and things like volume, price, etc. are its properties. e.g.

Code:
class Stock()
{
  // variables to hold data
  int LastHigh;
  int Close;
  int Price;
  int Volume:

  // properties to return calculated data values
  bool NewHigh {
    return Close > LastHigh;
  }
}
Then someone would use this object like so:

Code:
Stock s = new Stock("AAPL");
if (s.NewHigh == true) BUY!!
So it all depends on the framework provided by the vendor. I know NinjaTrader is built with C# so if you program against it, essentially you are using OO. But like Tams said earlier, if the main goal is Trading, it doesn't matter whether it is OO or not, the tool doesn't matter. You just want it to work.

thx
MMS
__________________
Traders Laboratory is 100% Free due to our generous ad sponsors.
Be sure to support them - they support Traders Laboratory!

Featured Brokers include:
Alpari | Mirus Futures

Featured Services:
NinjaTrader | Kinetic | INO Trading Course
MadMarketScientist is offline  
Reply With Quote
Old 10-27-2011, 06:17 PM   #8

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: Object-Oriented Programming OOP

Quote:
Originally Posted by Tams »
25 years later, I am surprised to see TS taking it on as a trading language.

My personal take (only personal 2 cents' worth) -- it is a waste of otherwise useful and productive time for the non-programmers (especially traders) trying to learn and implement any serious and extensive OO programming project.
I wouldn't care about OO, but I have this code that was created as an example by tradestation, and it's the only code that I know of that will do what I want. I don't know of any other options. It has to do with running the code, and therefore a clock, independent from having the code calculate dependent upon data ticks.

Plus I'm not sure if there is functionality, options available in OO in EasyLanguage not available otherwise. So, in a sense, I feel that I'm being forced to learn two programing languages, and I may need to use both of them in the same indicator.
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming: Where to Start? Soultrader Coding Forum 40 02-22-2012 10:13 AM
EasyLanguage Going Object Oriented ! Tams Tools of the Trade 24 07-03-2010 09:49 AM
Text Object PeterBrazel Coding Forum 0 01-28-2010 09:51 PM
Truncate EL Text Object PeterBrazel Coding Forum 3 08-01-2009 10:38 AM
Programming Your System brownsfan019 Tools of the Trade 17 04-22-2008 09:49 AM

All times are GMT -4. The time now is 11:05 AM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.