Jump to content

3 Day SMA/ Down Days Algorithm


Recommended Posts

Hi, I have been experimenting alot with the IG Index API. I find it easy to use. I have recently been toying with ideas for different algo's. I find the idea fascinating.

Anyone got any thoughts on this from a mathematical point of view? Or anyone else interested in this stuff?

  • Three consecutive down days
  • 3 day SMA
  • If the current price is below that 3 Day SMA then sell (There is a reason for the fundamental drop)
  • if the current price is above the 3 Day SMA then Buy (It's held steady, There is support for it)

I've coded this and testing it as we speak. If anyone is interested I will post on Github 

Link to Github Page

Example Output. 

https://pastebin.com/tf26EMG6

  • Like 1
Link to comment
6 minutes ago, TheGuru12 said:

Hi, I have been experimenting alot with the IG Index API. I find it easy to use. I have recently been toying with ideas for different algo's. I find the idea fascinating.

Anyone got any thoughts on this from a mathematical point of view? Or anyone else interested in this stuff?

  • Three consecutive down days
  • 3 day SMA
  • If the current price is below that 3 Day SMA then sell (There is a reason for the fundamental drop)
  • if the current price is above the 3 Day SMA then Buy (It's held steady, There is support for it)

I've coded this and testing it as we speak. If anyone is interested I will post on Github 

Link to Github Page

Example Output. 

https://pastebin.com/tf26EMG6

@jlz 

Link to comment
46 minutes ago, TheGuru12 said:

thanks! I see you use C# I use Python

I am not a big fan of weak typed languages, I don't understand why so many people use Python when there are languages like c++, java and c# available. I do have a python client as well in the repository, but just for the sake of having it , I don't use it.

  • Sad 1
Link to comment
43 minutes ago, jlz said:

I am not a big fan of weak typed languages, I don't understand why so many people use Python when there are languages like c++, java and c# available. I do have a python client as well in the repository, but just for the sake of having it , I don't use it.

 

Python is complex enough to get my head around.  Why do I want to make my life even more difficult by learning a language that requires me to jump through extra hoops to get stuff done?

The Pine editor on TradingView is based on Javascript.  Yet another language to learn to get simple stuff done :(

 

Edited by dmedin
Link to comment
54 minutes ago, dmedin said:

 

Python is complex enough to get my head around.  Why do I want to make my life even more difficult by learning a language that requires me to jump through extra hoops to get stuff done?

The Pine editor on TradingView is based on Javascript.  Yet another language to learn to get simple stuff done :(

 

Python is way more difficult than C#, also slower and error-prone.

Just watch all the messages that are coming in the forum about missing data, function errors, wrong results and so on. You will see that all of them are using Python. Also have a look at the "unofficial" Python repository, it is full of people complaining about its performance. Good luck setting up the streaming API with Python as well.

Python is a language that has been there for so many years and suddenly everyone is using it. Not a single one has compared its performance over multiple systems, they just use it without comparing it with any other language.

Whoever gives C# a chance they never go back to the pain of using Python.

I compare it with people that buy an IPhone and suddenly they want connectivity with other devices. Any shitty android device that cost 50 quid would beat them on that. 


You are free to use it but at least don't say that is easier than C#, because it is not.

Edited by jlz
  • Great! 1
Link to comment
6 minutes ago, jlz said:

Python is way more difficult than C#, also slower and error-prone.

Just watch all the messages that are coming in the forum about missing data, function errors, wrong results and so on. You will see that all of them are using Python. Also have a look at the "unofficial" Python repository, it is full of people complaining about its performance. Good luck setting up the streaming API with Python as well.

Python is a language that has been there for so many years and suddenly everyone is using it. Not a single one has compared its performance over multiple systems, they just use it without comparing it with any other language.

Whoever gives C# a chance they never go back to the pain of using Python.

I compare it with people that buy an IPhone and suddenly they want connectivity with other devices. Any shitty android device that cost 50 quid would beat them on that. 


You are free to use it but at least don't say that is easier than C#, because it is not.

 

How much longer have you got before Microshit 'deprecates' it in favour of the latest and the greatest?

Link to comment
Just now, dmedin said:

 

How much longer have you got before Microshit 'deprecates' it in favour of the latest and the greatest?

C# does not depend on Microsoft, there are many companies developing the framework, simply because it improved their processes over the years so much that they don't want to leave it behind. 

Think about the  c++ can be considered the fastest language out there, c# is now at  a level of optimization that can compete with c++, even at the expense of using a non-native runtime. So I don't think it is going away anytime soon.

  • Great! 1
Link to comment

woah! Easy chaps (I presume) ... I just talked about my algo idea. Each to their own. I agree I have faced issues with a lot of things in Python. Some resolved by the IG Helpdesk but it works for me. Anywho. I will prepare a github repo with my code if anyone Interested. Perhaps people can contribute to the idea. I just wanted to see if anyone though it was a feasible idea 

  • Great! 1
Link to comment
2 minutes ago, TheGuru12 said:

woah! Easy chaps (I presume) ... I just talked about my algo idea. Each to their own. I agree I have faced issues with a lot of things in Python. Some resolved by the IG Helpdesk but it works for me. Anywho. I will prepare a github repo with my code if anyone Interested. Perhaps people can contribute to the idea. I just wanted to see if anyone though it was a feasible idea 

:D it is all part of the usual banter/discussion. There is no harm intended. Just bored folks trying to be clever over a few big words. 

  • Great! 2
Link to comment
On 10/09/2020 at 15:08, jlz said:

I am not a big fan of weak typed languages, I don't understand why so many people use Python when there are languages like c++, java and c# available. I do have a python client as well in the repository, but just for the sake of having it , I don't use it.

I'm a C#, Java developer, but I love doing Python + AWS for my "trading projects" that I have started working (learning) on in the beginning of the quarantine. It's so faster to prototype something and most of the prototypes I can just deploy to production afterwards since speed is not of importance.

Also another reason I started learning Python this year is this:

Stackoverflow 2019 developer survey:

Quote
  • Python, the fastest-growing major programming language, has risen in the ranks of programming languages in our survey yet again, edging out Java this year and standing as the second most loved language (behind Rust).

 

Link to comment
7 hours ago, SonnyCrockett said:

I'm a C#, Java developer, but I love doing Python + AWS for my "trading projects" that I have started working (learning) on in the beginning of the quarantine. It's so faster to prototype something and most of the prototypes I can just deploy to production afterwards since speed is not of importance.

Also another reason I started learning Python this year is this:

Stackoverflow 2019 developer survey:

 

I have a Raspberry Pi 4b and I play with Python constantly. Recently I got this Robot Arm toy and connected it to the Pi:

https://owirobot.com/robotic-arm-edge/

I know Python has become a popular language but that is just because of the power of the open source community. There are so many libraries out there that makes the development a very easy task. But that doesn't make it a reliable language for trading. I don't think it should be used because of its dynamic typing. It is quite slow as well so I don't know how it would work for HFT with streaming services.

One of our problems is that we get bored with what we have and we keep learning new languages. So python is popular now. Then it will be Rust or Go, or any of the 1000 open source languages out there. But trading firms will still deploy their main applications with strong typed languages looking for a reliable execution. C++ and C# are hard to beat at that.

  • Sad 1
Link to comment
3 hours ago, jlz said:

I know Python has become a popular language but that is just because of the power of the open source community. There are so many libraries out there that makes the development a very easy task.

I would add it is because of the popularity of the packages that are used in data science. Comparing the numbers of modules in all package managers Python doesn't stand out. First there is NPM for Javascript way above and then there is everyone else.

I think there is just too much ceremony involved in OO languages to get basic math concepts working. You don't need to know about polymorphism, inheritance, abstract classes, constructors, interfaces static & instance data types...if all you want to do is  crunch some numbers.

I enjoyed learning Python a lot more than I enjoyed learning subtle differences between C# and Java.

Some other stuff I really like in Python:

  • Parsing JSON. It feels so natural. In Java & C# I would spent 1 day to find the best framework, then create all the objects to map JSON data, in Python JSON is just a dictionary data structure. It is 1 line to convert JSON string into a dictionary and then you just use the dictionary syntax to read/write data.
  • It teaches you to write tests. You need tests for everything, knowing that there is no compiler to back you up, your code coverage needs to be a lot higher than when working with strongly typed languages.
  • You just open a file and start writing code, without the need to declare any classes, static main functions, configure the project with what to run etc...
Quote

But trading firms will still deploy their main applications with strong typed languages looking for a reliable execution. C++ and C# are hard to beat at that.

Agree. But we are not trading firms building platforms for thousands of consumers. So to each his own :)

Sorry for hijacking the thread @TheGuru12 :)

Link to comment
29 minutes ago, SonnyCrockett said:
  • Parsing JSON. It feels so natural. In Java & C# I would spent 1 day to find the best framework, then create all the objects to map JSON data, in Python JSON is just a dictionary data structure. It is 1 line to convert JSON string into a dictionary and then you just use the dictionary syntax to read/write data.

It cannot be easier to parse JSON into classes in C#.

Just create a .cs file and use the option "Paste Json as classes in Visual Studio", then a simple line with Newtonsoft will have your object ready. 

var yourClass = JsonConvert.DeserializeObject<T>(json)

image.png.ccdb17963bd11ffc7445d38165b867f1.png

A day to parse a JSON object?, you just have to use the right tools. It takes 5 minutes and you end with a full object with proper nested types in a hierarchy. Not to mention that everything is strong-typed as well as included in the intellisense helper.

And you are going to tell me that you prefer hard-coding strings as keys to get them from a dictionary? Come on...

 

 

 

Edited by jlz
  • Like 1
Link to comment

Auto code generators are so 2000's :). I'm at a point of my career where "no code" wins over "automatically generated code" every time for me. If the price of having 0 mapping objects in contrast to 20 (as you would need for a rest api with 10 endpoints - request, response) is that you loose strong types (what most people are annoyed is that there is no intelli sense or auto complete to help you) then I'm willing to pay that price. I'll cover my **** with tests anyway.

No seriously, as I said I'm a C# developer mainly, but I'm not in denial that popularity of C# and Java have been in decline for the last 10 years. MS has this tendency to screw things up, I love C# as I loved Windows Phones back in the day...

I never used C++ professionally, would love to, but there is only that many hours in a day...

Link to comment
2 hours ago, SonnyCrockett said:

Auto code generators are so 2000's :). I'm at a point of my career where "no code" wins over "automatically generated code" every time for me. If the price of having 0 mapping objects in contrast to 20 (as you would need for a rest api with 10 endpoints - request, response) is that you loose strong types (what most people are annoyed is that there is no intelli sense or auto complete to help you) then I'm willing to pay that price. I'll cover my **** with tests anyway.

No seriously, as I said I'm a C# developer mainly, but I'm not in denial that popularity of C# and Java have been in decline for the last 10 years. MS has this tendency to screw things up, I love C# as I loved Windows Phones back in the day...

I never used C++ professionally, would love to, but there is only that many hours in a day...

I started this morning a c++ repo. Let's see how far I get. I couldn't find any code samples for c++ in order to connect to the IG API so if you guys want to step in and review the code I would love to hear your comments.

I haven't developed in c++ as much as I have in c#, so take it easy on me :D 

https://github.com/oneangrytrader/brokerapiclients

  • Sad 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • image.png

  • Posts

    • MSFT Elliott Wave Analysis Trading Lounge Daily Chart Microsoft Inc., (MSFT) Daily Chart MSFT Elliott Wave Technical Analysis   FUNCTION: Counter Trend MODE: Corrective STRUCTURE: Zigzag POSITION: Intermediate (2) DIRECTION: Bottom in wave A of (2).   DETAILS: We are considering a significant top in place with wave (1), and we are now looking for a three wave move correction into wave (2). We seem to be finding buyers on Medium Levell 400$, looking for 400$ to turn into resistance.         MSFT Elliott Wave Analysis Trading Lounge 4Hr Chart Microsoft Inc., (MSFT) 4Hr Chart MSFT Elliott Wave Technical Analysis   FUNCTION: Counter Trend MODE: Corrective STRUCTURE: Zigzag POSITION: Wave A.   DIRECTION: Bottom in wave {v}. DETAILS: I can count a clear five wave move into wave A, with alternation between {ii} and {iv}. Looking for a pullback in wave B to then fall back lower.       In this comprehensive Elliott Wave analysis for Microsoft Corporation (MSFT), we provide an in-depth review of the stock’s potential movements based on its current wave patterns, as observed in both the daily and 4-hour charts on April 26, 2024. This analysis aims to assist traders and investors in understanding the underlying market dynamics and planning their strategies accordingly.       * MSFT Elliott Wave Technical Analysis – Daily Chart* The daily chart of MSFT shows the stock in a corrective phase with a zigzag structure, identified as Intermediate wave (2). Currently, the stock is witnessing a bottom formation in wave A of (2). After observing a significant top in wave (1), MSFT appears to be undergoing a corrective three-wave movement. The price level around $400, which has been attracting buyers, is anticipated to evolve into a resistance level. Traders should monitor this zone closely for potential reversal signals. * MSFT Elliott Wave Technical Analysis – 4Hr Chart* Moving into the 4-hour chart, the analysis continues to reflect a counter-trend with a zigzag corrective structure, highlighting the end of Wave A. Here, a clear five-wave movement has been identified, with distinct alternations between waves {ii} and {iv}. The current position, at the bottom of wave {v}, suggests that the stock might experience a short-term pullback in wave B before potentially declining further. This provides a strategic point for traders to look for entry and exit points during the unfolding of wave B.
    • Recently, the Australian S&P/ASX 200 index slightly fell by 0.01%, with this fluctuation mainly influenced by the latest release of the Consumer Price Index (CPI) data. This data not only demonstrates current inflationary pressures but also directly impacts the stock market in the short term. Senior analyst Thomas McGee delves into the impact of these economic indicators on the Australian stock market and discusses the economic logic behind this data and its potential effects on future monetary policy by the Reserve Bank of Australia (RBA). Market Impact of Inflation Data The CPI data for the first quarter released today showed an annual growth rate of 3.6%, surpassing the market expectation of 3.4%. This immediate announcement led to a drop of about 0.5% in the S&P/ASX 200 index, and the market failed to recover these losses by the closing bell. Thomas McGee points out that this rapid response highlights the sensitivity of investors to inflation trends and their immediate impact on the stock market. In addition to the direct reaction of the stock market, the yield of Australian 2-year government bonds also significantly rose by 0.12%, breaking the 4.4% level for the first time since December last year. This change not only reflects the response of the bond market to the CPI data but may also indicate a cautious stance by the RBA regarding rate adjustments in the short term. Forward-looking Analysis of Monetary Policy Following the release of inflation data, the expectation on the market of the first rate cut of RBA has been postponed to after 2025. Thomas McGee emphasizes the importance of this change for investment strategies. He suggests that investors consider how changes in monetary policy will affect market dynamics when making long-term investment decisions, especially in a scenario where rates may remain elevated for an extended period. With inflation data showing higher than expected figures, the market predicts that the RBA may not cut rates in the short term, intensifying expectations of rate hikes. Thomas McGee mentions that this shift in expectations requires investors to reassess their investment portfolios, particularly in terms of fixed-income asset allocation. Furthermore, Thomas McGee notes that although the market may face pressure in the short term, this could also present entry opportunities for investors seeking higher yields. Companies that can maintain cash flow in a high-rate environment may become preferred investment targets. Addressing Challenges and Seizing Opportunities Despite the uncertainties and challenges brought by the current inflation data, Thomas McGee believes that investors can still find stable investment opportunities in this complex environment through thorough market analysis and understanding of future economic policy trends. He encourages investors to maintain flexible investment strategies while closely monitoring changes in economic indicators and central bank policies to effectively address potential market fluctuations and achieve value growth in future investments.
×
×
  • Create New...
us