The only system that will work is one designed by and for yourself.
Similar Threads
can anyone guide me how to profit from footprint chart 8 replies
100% fool proof, can't possibly go wrong system 100 replies
Proof of concept to make good pips 12 replies
Can anyone modify this indicator for me - display profit 1 reply
- Joined May 2011 | Status: Member | 1,406 Posts
Yes. Anyone can make a thread about: 'how to make profit' + proof?
Ecclesiastes 1:9
1
- Joined Dec 2013 | Status: Member | 727 Posts
"I have been asked what other linear methods I find useful. The answer is: Not
many. If there is a secret to the markets (and I think there is) then it is almost certainly in
a non-linear approach; mostly likely an application of cellular automata or catastrophe
theory."
Read from page 5 until 20.
Linear methods are useful, especially as filters or as broader system
‘checks’. I believe Contrary Opinion, Point and Figure and CommTools’ own Mercury Charts may be very useful to the trader.
You can read about the return RULE, 50% RULE and recursion.
many. If there is a secret to the markets (and I think there is) then it is almost certainly in
a non-linear approach; mostly likely an application of cellular automata or catastrophe
theory."
Read from page 5 until 20.
Linear methods are useful, especially as filters or as broader system
‘checks’. I believe Contrary Opinion, Point and Figure and CommTools’ own Mercury Charts may be very useful to the trader.
You can read about the return RULE, 50% RULE and recursion.
Attached File(s)
GoodmanIntroReturnPDF.pdf
1.4 MB
|
602 downloads
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
DislikedThe market dosn't always work on logic... thats rule #1 Thats why you need 10,000 hours + of watching the market to even have a chance. You can read all the books you want and logic about playing a guitar... But till you actually practice for a few years your not gonna be very good. Same goes with trading.. You can't put all the years of experience down into a few simple rules.Ignored
It's true, one trader could end up looking for good strategies for many years. In this case analysing is key. For example, MAE & MFE analysis is a powerful tool for potential measurement, validation of entries and is also helpful as a first step for a simple money management setup. But is not a tool which can solve all problems. You need to be aware this analysis is only a mathematical concept and is not very smart to using this without basic logic. You need to make a huge statistical sample. Another thing is that for different trading styles you are looking for a different entry quality and potential. You need to have an e-ratio higher than 1. E ratio over 1.5 means that you have a powerful and robust trading strategy.
If you want to learn more about analyses, specifically MFE/MAE, read up on https://www.dukascopy.com/fxcomm/fx-...61&language=en
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
Scriptable data sources that professional traders use for historical to near-live data:
- IG Index.
- histdata.com provides some of its datasets for free but for free access you have to download every single year that you want individually.
- Free: IEX
- Paid: Polygon.io
- IEX is only 3-4% of the market, but the data is great and fast. APIs are modern and dev friendly. Stock data is highly regulated and licensed. If you want full market coverage and from a legit source, you'll have to pay.
- quandl
- alphavantage
What's the easiest way to find alpha factors in quant trading?
My approach is to write models taking strong fundamentals into account. A platform that has access to S&P Global Database or CapitalIQ data can scan for high quality metrics that generates alpha, such as high cash flow, upgraded earnings guidance, earnings surprise results and low valuation. These metrics produce even better results on small caps. So one example to achieve that is to build a ranking system where weights are assigned for each of these factors, and define a score scale for each metric. The stocks that rank highest overall would have the best combination of high cash flow, earnings growth and low valuation, for example. Fundamentals take time to reflect on stock price, so as valuation gets higher or earnings deteriorate, the rank would decline, generating a sell signal - hence the buy signal is for high ranked stocks only.
The key, in my opinion, is to have sound financial idea that drives alpha, and not data mine / curve fit to what worked in the past. Data mining/curve fitting has nothing at all to do with process. It has to do with your intention. If your intention is to build a model based solely on what worked over your sample period(s), then you are curve fitting/data mining. If you build a model based on what you expect, based on logic and common sense, to work in the future, then you are not curve fitting/data mining.
Here is a very simple example, start with Rule 1: PE<20
Add Rule 2: ROE%>15
I don’t need to test Rule 2 before adding it. In fact, I’m better off not testing it separately.
If I test Rule 2 separately, there’s a good chance it will fail. There is no logical reason why shares of companies with strong ROE should do well. Perhaps they are overvalued. Perhaps ROE is going to fall off a cliff. Perhaps they are taking on more debt than they can comfortably afford in order to leverage up a rotten ROA.
If I pair Rule 2 with Rule 1 right off the bat, everything has changed and both rules gain strength. That’s a more robust combination to drive alpha.
Rule 1 becomes stronger because I’m not limiting my search to low P/E stocks but low P/E on shares of better-quality companies. Rule 2 becomes stronger because I’m following Greenblatt principles; limiting my consideration of better quality companies to those whose shares are reasonably priced.
Therefore:
Rule 1 is one investment idea.
Rule 2 is a completely different investment idea.
Rule 1 + Rule 2 is a completely different idea that has nothing in common with the other two.
I expect rule 1 and 2 combined to generate alpha, as I take quality and valuation factors into account, which are known factors to drive superior return.
Example with all rules for free: https://boostyourincome.ca/trading-s...on-graham-tsx/
Market research module:
It serves the trading strategy and fund management. Aside from this point, any market judgment has no target, no standard can be set, and there is no practical significance. The research contains predictions, but not only the pre-opening forecast, but also the tracking evaluation after the opening of the position.
Market research needs to answer two questions:
1. when to enter
The answer must be clear, it can be an exact price, or a clear interval. In general, regardless of the analysis method used by investors, the types of incoming signals can be roughly divided into two types:
1) Homeopathic trading type: Take advantage of the trend.
2) Contrarian trading type: low suction and high throw.
This is two completely different analysis ideas, and both of them can be used, but it is better not to switch ideas in the transaction!
2. when to leave
Leaving contains three layers of meaning:
1) because the development of the market does not meet the investor's position standards;
2) for stop loss and take profit;
3) it should be proactive.
The market research must clearly answer this question. Compared to the first question, this question is easily overlooked, so this issue is more important. When to enter is determined by when to leave.
Fund management module
The purpose of futures trading fund management:
1. It is to survive in the market and survive for a long time.
In order to survive, losses must be limited as small. This "small" is a relative concept. Although everyone understands differently, it should be our absolute pursuit in the transaction process, because we can't predict that there will be how many times of losses in succession. We can only control that every loss is small.
2. Profit is the ultimate pursuit of futures trading. Only profit can make up for the loss and finally leads to profits.
Apply the words of the investment master: limit the loss to a small amount and let the profit run. It is this requirement that determines the third question that needs to be answered in the market research: the market research must be able to measure the ratio of profit and loss, otherwise it will be proved to be flawed.
It should be emphasized that since we do not know how many times we will lose money in a row, we must actively hold the positions once we start to make a profit.
This has two implications:
(1). We can't know if the profit has already been maximized. Only when profit starts to retrace, can we know which position the biggest profit point is, even if you are an investor who is good at measuring the amount.
Because some market changes will cross the time level, for example, the daily-level market has evolved into a weekly-level market, so there is profit. As long as our position standards are still there, we may wish to hold positions more firmly, and we must not "chase profit" without any principle.
2. Many market trends will be repeated at the beginning. We may fail to attack once, twice or even several times. In order to maintain the ability to "attack", profits must be able to make up for multiple attacks. If you can't do this, it means that the market research may have something wrong.
In short, "gain after you know how to stop", "do what your strength allows." No matter how to stress the fund management, it is not enough. It’s the most personal aspect of all trading process, reflecting all aspects of the investor's personality. There is no good or bad, and suitable is good.
With the above quantification, it is easy for investors to clarify the “lossy resources” that can be used in each transaction or in each period. Many people compare all investment margins to "bullets". I think it should be more appropriate to compare their losses to "bullets". Bullets can't be back when they are shot, but in order to get "prey" we must fire "bullets". If the loss amount is running out, you should stop trading.
The combination of the market research module and the fund management module can measure a reasonable and clear loss limit, which helps to improve execution.
Trading strategy module
This is the most flexible part and it most needs effort. In this session, many investors have overlooked a problem: the rhythm of the market trend. Formulating an appropriate trading strategy is to accurately follow the rhythm of the market trend. The trading strategy needs to finish off the following three issues:
(1)
Time to enter
After determining the time level of your trade, what do you think of your entry signal? For example, wether enter or not when a daily-level trader who want a breakthrough face the opening gap during the entire trading day; wether to leave or not when it retreats within the key point?
In order to avoid these problems, the daily-level trader should probably enter according to the signal when it’s about to close, filtering out the day's signal. This may miss some profit margins, but you can avoid unnecessary stop-loss actions caused by intraday fluctuations and avoid disadvantages.
As a futures investor, you should put avoiding disadvantages first. It is just an example. It is not to say that this is the only or best way. Investors should have a clear standard for the timing of their trading.
2. How to deal with market emergencies
This is a very important issue. For emergencies, there must be a positive response, regardless of whether the emergency is beneficial or not. Many investors believe that although unexpected events can cause abnormal fluctuations in the market, accelerate a wave of trend, or slow down a wave of trend, but most of events cannot change the trend of the market.
Since it is a "burst", there is no prediction, and you might as well not to consider it. Obviously this view is a bit negative. The government has been actively calling on all walks of life to establish an "early warning mechanism", and futures investors should also establish an "early warning mechanism" to ensure the smooth implementation of trading strategies to the greatest extent. Otherwise, the rhythm will be disrupted by unexpected events, and blindly entering or passively leaving will occur.
3. Adding and subtracting positions, smoothing the mind
I have never believed that some investors can be calm as still water when they face the ups and downs of the market, the profits and losses of the funds. It’s known that the two weaknesses of human nature - greed and fear - have been magnified many times in futures trading, causing a lot of trouble for traders, and all investors are trying to overcome these weaknesses.
I believe that overcoming weaknesses should start with respect for weaknesses. Weaknesses are born, and they all play a role at all times, and we cannot get rid of them. But we can formulate a clear trading strategy, through the addition and subtraction of positions, to smooth or offset the test from profit and loss fluctuations on human weakness.
The general principle of adding and subtracting positions: when you lose, don’t add position; when you gain profits, you only add according to the pre-set measured ratio. It should be noted that this is a general principle, not the only standard.
The maximum risk of the account will be controlled at 25%. Usually 1/3 of the investment amount will be closed when the signal is unclear, and this profit will be used to guarantee another 1/3 of the investment, so that only 1/3 of the investment amount is risky, while at the same time there is 2/3 of potential to gain profit. So that investors are in an invincible position, while not affecting the mood due to the big fish slip away, maintaining a calm state of mind.
The trading system is a whole, each module is an organic combination, not a simple superposition. A good trading system does not highlight a certain module but is considered and synchronized in whole. Every detail of a good trading system is holographic, reflecting all the information, goals, principles, skills and so on.
The hardest thing for people to do is to understand themselves and evaluate themselves correctly. The trading method can be learned, but while learning it is necessary to combine the analysis and understanding of yourself. The method that suits you is likely to be the best method.
Finding alpha factors in trading is EXTREMELY difficult. If you manage to find what you think is an alpha factor that can be systematically exploited, just remember the legions of teams of really smart people at all manner of quant shops all looking for the same thing and ask yourself if you really believe that you are the only one that has spotted it. That should give you a more realistic perspective on things. Chances are anything you find either can't actually be exploited in real time or will be arbitraged away in fairly short order. Focus on things that can't be arbitraged away. Things like weather and realised volatility.
The best way to find them, I think anyway, is by spending hundreds of hours watching, analysing and thinking about price action. Once you think you've found something, it should have a solid, logical reason for existing in the first place. Then translate what you think you've found to code and test it on actual market data until your eyes bleed. Don't forget to include realistic costs. If it's profitable in markets other than the one you found it in (unless its solid logical reason for existing is specific to that particular market), you MIGHT be onto something.
Teams work better, especially if well organized. Be ready to give up to unsuccessful ideas and to go in depth of the ideas you/your team has. Collaboration is the key, although there is no easy way. You can try using a ‘standard’ quantitative trading framework but there is a lot of work in filling in the details.
Check out this paper: https://papers.ssrn.com/sol3/papers....act_id=1753788
Listen to this expert: https://soundcloud.com/chat-with-tra...ef=producthunt
Which rare patterns are high percentage gainers?
Generally speaking, if you build a model that puts out a continuous signal (rather than a boolean trade/don't trade), you can trade only those outputs which fall outside of a certain confidence interval (i.e. outliers). The wider the confidence interval, the 'rarer' the event. This supposes that your model has reasonable predictive ability, especially in the tails. It also doesn't mean that you wouldn't need to run it every period in order to identify what the model output is.
- IG Index.
- histdata.com provides some of its datasets for free but for free access you have to download every single year that you want individually.
- Free: IEX
- Paid: Polygon.io
- IEX is only 3-4% of the market, but the data is great and fast. APIs are modern and dev friendly. Stock data is highly regulated and licensed. If you want full market coverage and from a legit source, you'll have to pay.
- quandl
- alphavantage
What's the easiest way to find alpha factors in quant trading?
My approach is to write models taking strong fundamentals into account. A platform that has access to S&P Global Database or CapitalIQ data can scan for high quality metrics that generates alpha, such as high cash flow, upgraded earnings guidance, earnings surprise results and low valuation. These metrics produce even better results on small caps. So one example to achieve that is to build a ranking system where weights are assigned for each of these factors, and define a score scale for each metric. The stocks that rank highest overall would have the best combination of high cash flow, earnings growth and low valuation, for example. Fundamentals take time to reflect on stock price, so as valuation gets higher or earnings deteriorate, the rank would decline, generating a sell signal - hence the buy signal is for high ranked stocks only.
The key, in my opinion, is to have sound financial idea that drives alpha, and not data mine / curve fit to what worked in the past. Data mining/curve fitting has nothing at all to do with process. It has to do with your intention. If your intention is to build a model based solely on what worked over your sample period(s), then you are curve fitting/data mining. If you build a model based on what you expect, based on logic and common sense, to work in the future, then you are not curve fitting/data mining.
Here is a very simple example, start with Rule 1: PE<20
Add Rule 2: ROE%>15
I don’t need to test Rule 2 before adding it. In fact, I’m better off not testing it separately.
If I test Rule 2 separately, there’s a good chance it will fail. There is no logical reason why shares of companies with strong ROE should do well. Perhaps they are overvalued. Perhaps ROE is going to fall off a cliff. Perhaps they are taking on more debt than they can comfortably afford in order to leverage up a rotten ROA.
If I pair Rule 2 with Rule 1 right off the bat, everything has changed and both rules gain strength. That’s a more robust combination to drive alpha.
Rule 1 becomes stronger because I’m not limiting my search to low P/E stocks but low P/E on shares of better-quality companies. Rule 2 becomes stronger because I’m following Greenblatt principles; limiting my consideration of better quality companies to those whose shares are reasonably priced.
Therefore:
Rule 1 is one investment idea.
Rule 2 is a completely different investment idea.
Rule 1 + Rule 2 is a completely different idea that has nothing in common with the other two.
I expect rule 1 and 2 combined to generate alpha, as I take quality and valuation factors into account, which are known factors to drive superior return.
Example with all rules for free: https://boostyourincome.ca/trading-s...on-graham-tsx/
Market research module:
It serves the trading strategy and fund management. Aside from this point, any market judgment has no target, no standard can be set, and there is no practical significance. The research contains predictions, but not only the pre-opening forecast, but also the tracking evaluation after the opening of the position.
Market research needs to answer two questions:
1. when to enter
The answer must be clear, it can be an exact price, or a clear interval. In general, regardless of the analysis method used by investors, the types of incoming signals can be roughly divided into two types:
1) Homeopathic trading type: Take advantage of the trend.
2) Contrarian trading type: low suction and high throw.
This is two completely different analysis ideas, and both of them can be used, but it is better not to switch ideas in the transaction!
2. when to leave
Leaving contains three layers of meaning:
1) because the development of the market does not meet the investor's position standards;
2) for stop loss and take profit;
3) it should be proactive.
The market research must clearly answer this question. Compared to the first question, this question is easily overlooked, so this issue is more important. When to enter is determined by when to leave.
Fund management module
The purpose of futures trading fund management:
1. It is to survive in the market and survive for a long time.
In order to survive, losses must be limited as small. This "small" is a relative concept. Although everyone understands differently, it should be our absolute pursuit in the transaction process, because we can't predict that there will be how many times of losses in succession. We can only control that every loss is small.
2. Profit is the ultimate pursuit of futures trading. Only profit can make up for the loss and finally leads to profits.
Apply the words of the investment master: limit the loss to a small amount and let the profit run. It is this requirement that determines the third question that needs to be answered in the market research: the market research must be able to measure the ratio of profit and loss, otherwise it will be proved to be flawed.
It should be emphasized that since we do not know how many times we will lose money in a row, we must actively hold the positions once we start to make a profit.
This has two implications:
(1). We can't know if the profit has already been maximized. Only when profit starts to retrace, can we know which position the biggest profit point is, even if you are an investor who is good at measuring the amount.
Because some market changes will cross the time level, for example, the daily-level market has evolved into a weekly-level market, so there is profit. As long as our position standards are still there, we may wish to hold positions more firmly, and we must not "chase profit" without any principle.
2. Many market trends will be repeated at the beginning. We may fail to attack once, twice or even several times. In order to maintain the ability to "attack", profits must be able to make up for multiple attacks. If you can't do this, it means that the market research may have something wrong.
In short, "gain after you know how to stop", "do what your strength allows." No matter how to stress the fund management, it is not enough. It’s the most personal aspect of all trading process, reflecting all aspects of the investor's personality. There is no good or bad, and suitable is good.
With the above quantification, it is easy for investors to clarify the “lossy resources” that can be used in each transaction or in each period. Many people compare all investment margins to "bullets". I think it should be more appropriate to compare their losses to "bullets". Bullets can't be back when they are shot, but in order to get "prey" we must fire "bullets". If the loss amount is running out, you should stop trading.
The combination of the market research module and the fund management module can measure a reasonable and clear loss limit, which helps to improve execution.
Trading strategy module
This is the most flexible part and it most needs effort. In this session, many investors have overlooked a problem: the rhythm of the market trend. Formulating an appropriate trading strategy is to accurately follow the rhythm of the market trend. The trading strategy needs to finish off the following three issues:
(1)
Time to enter
After determining the time level of your trade, what do you think of your entry signal? For example, wether enter or not when a daily-level trader who want a breakthrough face the opening gap during the entire trading day; wether to leave or not when it retreats within the key point?
In order to avoid these problems, the daily-level trader should probably enter according to the signal when it’s about to close, filtering out the day's signal. This may miss some profit margins, but you can avoid unnecessary stop-loss actions caused by intraday fluctuations and avoid disadvantages.
As a futures investor, you should put avoiding disadvantages first. It is just an example. It is not to say that this is the only or best way. Investors should have a clear standard for the timing of their trading.
2. How to deal with market emergencies
This is a very important issue. For emergencies, there must be a positive response, regardless of whether the emergency is beneficial or not. Many investors believe that although unexpected events can cause abnormal fluctuations in the market, accelerate a wave of trend, or slow down a wave of trend, but most of events cannot change the trend of the market.
Since it is a "burst", there is no prediction, and you might as well not to consider it. Obviously this view is a bit negative. The government has been actively calling on all walks of life to establish an "early warning mechanism", and futures investors should also establish an "early warning mechanism" to ensure the smooth implementation of trading strategies to the greatest extent. Otherwise, the rhythm will be disrupted by unexpected events, and blindly entering or passively leaving will occur.
3. Adding and subtracting positions, smoothing the mind
I have never believed that some investors can be calm as still water when they face the ups and downs of the market, the profits and losses of the funds. It’s known that the two weaknesses of human nature - greed and fear - have been magnified many times in futures trading, causing a lot of trouble for traders, and all investors are trying to overcome these weaknesses.
I believe that overcoming weaknesses should start with respect for weaknesses. Weaknesses are born, and they all play a role at all times, and we cannot get rid of them. But we can formulate a clear trading strategy, through the addition and subtraction of positions, to smooth or offset the test from profit and loss fluctuations on human weakness.
The general principle of adding and subtracting positions: when you lose, don’t add position; when you gain profits, you only add according to the pre-set measured ratio. It should be noted that this is a general principle, not the only standard.
The maximum risk of the account will be controlled at 25%. Usually 1/3 of the investment amount will be closed when the signal is unclear, and this profit will be used to guarantee another 1/3 of the investment, so that only 1/3 of the investment amount is risky, while at the same time there is 2/3 of potential to gain profit. So that investors are in an invincible position, while not affecting the mood due to the big fish slip away, maintaining a calm state of mind.
The trading system is a whole, each module is an organic combination, not a simple superposition. A good trading system does not highlight a certain module but is considered and synchronized in whole. Every detail of a good trading system is holographic, reflecting all the information, goals, principles, skills and so on.
The hardest thing for people to do is to understand themselves and evaluate themselves correctly. The trading method can be learned, but while learning it is necessary to combine the analysis and understanding of yourself. The method that suits you is likely to be the best method.
Finding alpha factors in trading is EXTREMELY difficult. If you manage to find what you think is an alpha factor that can be systematically exploited, just remember the legions of teams of really smart people at all manner of quant shops all looking for the same thing and ask yourself if you really believe that you are the only one that has spotted it. That should give you a more realistic perspective on things. Chances are anything you find either can't actually be exploited in real time or will be arbitraged away in fairly short order. Focus on things that can't be arbitraged away. Things like weather and realised volatility.
The best way to find them, I think anyway, is by spending hundreds of hours watching, analysing and thinking about price action. Once you think you've found something, it should have a solid, logical reason for existing in the first place. Then translate what you think you've found to code and test it on actual market data until your eyes bleed. Don't forget to include realistic costs. If it's profitable in markets other than the one you found it in (unless its solid logical reason for existing is specific to that particular market), you MIGHT be onto something.
Teams work better, especially if well organized. Be ready to give up to unsuccessful ideas and to go in depth of the ideas you/your team has. Collaboration is the key, although there is no easy way. You can try using a ‘standard’ quantitative trading framework but there is a lot of work in filling in the details.
Check out this paper: https://papers.ssrn.com/sol3/papers....act_id=1753788
Listen to this expert: https://soundcloud.com/chat-with-tra...ef=producthunt
Which rare patterns are high percentage gainers?
Generally speaking, if you build a model that puts out a continuous signal (rather than a boolean trade/don't trade), you can trade only those outputs which fall outside of a certain confidence interval (i.e. outliers). The wider the confidence interval, the 'rarer' the event. This supposes that your model has reasonable predictive ability, especially in the tails. It also doesn't mean that you wouldn't need to run it every period in order to identify what the model output is.
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
Learning MQL4: must-do or just for fun?
MQL isn't the way forward. Learn Python or Rust instead. Rust is quicker and easier to program. Rust may be technically better, but the goal of a tool is to complete a task. Python libraries, books, etc. make creating financial and trading apps much, much faster. Basically, it's a better ecosystem than Rust's.
MQL isn't the way forward. Learn Python or Rust instead. Rust is quicker and easier to program. Rust may be technically better, but the goal of a tool is to complete a task. Python libraries, books, etc. make creating financial and trading apps much, much faster. Basically, it's a better ecosystem than Rust's.
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
How can a beginner with little mathematical/no prior trading experience break into quantitative analysis and algorithmic trading? Is it possible to teach yourself? How? Which books should one read?
Answer:
Yes. One can absolutely get into Algorithmic trading even if they don’t have experience in Trading. Get as much leverage for as low as possible interest rate from street with flexible margin conditions. You can exploit unstructured market data by learning Natural language Processing models and opportunities to do semantic analysis of news and press releases. Resources to learn quantitive analysis and algo trading:
1. Absorb (almost) all publicly available information
You need to know three areas: Finance/Trading, Math (especially statistics) and Programming.
Recommended Readings:
Evaluation and Optimization of Trading Strategies – Pardo (Great insights on methods on building and testing trading strategies)
Trade your way to Financial Freedom – Van K Tharp (Ridiculous-Click bait title aside, this book is a great overview to mechanical trading systems)
Quantitative Trading – Ernest Chan (Great introduction to algo trading on a retail level.)
Trading and Exchanges: Market Microstructure for Practitioners – Larry Harris (Market microstructure is the science of how exchanges function and what actually happens when a trade is placed. It is important to know this information even though you are just starting out)
Algorithmic Trading & DMA – Barry Johnson (Shed light on banks’ execution algorithms. This is not directly applicable your algo trading but it is good to know)
The Quants – Scott Patterson (War stories of some top quants. Good as a bedtime read)
Beat the Market: A Scientific Stock Market System - Edward O. Thorp (Provides a good foundation of how to think about inefficiencies in the markets. Edward Thorp one of the pioneers of Quantitative Finance/Trading, I suggest reading up on all his works)
Recommended Courses/Sites:
Quantopian https://www.quantopian.com/ (Code, research, and discuss ideas with the community. Uses Python)
AlgoTrading101 http://algotrading101.com/ (Disclaimer: I own this site/course. Learn robot design theories, market theories and coding. Uses MQL4)
http://asirikuy.com (Learn trading concepts and backtesting theories. They recently developed their own backtesting and trading platform so this part is still new to me. But their knowledge base on trading concepts are good.)
Recommended Blogs/Forums (these includes finance, trading and algo trading forums):
https://www.quantnet.com
http://mechanicalforex.com/
http://www.forexfactory.com/
http://www.stevehopwoodforex.com/
https://www.quantstart.com/
Recommended Programming Languages:
1. If you know what products you want to trade, find suitable trading platforms for these products. Then learn the programming language API of this platform/backtesters.
If you starting out, I would recommend Quantopian (stocks only), Quantconnect (stocks and FX) or Metatrader 4 (FX and CFDs on equity indices, stocks and commodities). The programming languages used are Python, C# and MQL4 respectively.
2. Test and apply your knowledge – Develop your own understanding
Try and try again! Test and apply your knowledge. Build robots. Backtest them and run them live (on small amounts of money). The aim here is to understand what works and doesn’t, and to know why.
3. Meet and partner with others
1+1=3. There is definitely synergy when working with or discussing ideas with others in the same field. Meet and partner up with others (preferably experienced ones). You learn exponentially when you have people to bounce ideas with.
4. Get a job at a trading firm and get a mentor
You don’t say! Alright this part may be tricky if you don’t have strong academic qualifications.
Let me first lay down the bad news: It is incredibly difficult to get into top quant trading firms without Masters or Ph.D. in a quantitative subject (Computational Finance, Physics, Engineering, Statistics etc). It is almost impossible if you want to get into a HFT role without these qualifications (unless your dad owns the firm!).
Good news: There are 2 ways in which you can get into a decent hedge fund.
A) Build a strong track record using algo trading. If you have a strong record (on a decent amount of money) over a few years and can convince the guys at the fund that you have some sort of trading edge. They may give you a chance (although they may just want your strategies and kick you out later).
B) Have something to offer. Sometimes, manual traders want to build an algo trading team and don’t mind taking on fresh guys with some quantitative skills. Other times, firms need "number crunchers" and will take on someone who exhibit decent programming skills.
These should be enough to get you started. Some ending notes, the trading/investment space is getting incredibly competitive. Many strategies that used to work don’t any more. Personally, I think profitable trading systems/ideas have about a 2-3 years lifespan before others catch on to it. You need to innovate to stay ahead of the game, but innovation takes experience, wits, time, infrastructure and money.
Platforms:
Quantiacs https://www.youtube.com/channel/UCS8...JLIaA91s5uQzQw - Market Place For Algorithmic Trading Systems provide an algo-building-toolbox and backtesting data. Here are a few links with books, online courses, videos....:
Videos:
Quantiacs LLC
Page on coursera.org
Paper:
Page on decal.org
Books:
Quantitative Trading: How to Build Your Own Algorithmic Trading Business: Ernie Chan: 9780470284889: Amazon.com: Books
Quantitative Trading and Money Management, Revised Edition: Fred Gehm: 9781557385857: Amazon.com: Books
Inside the Black Box: The Simple Truth About Quantitative Trading (Wiley Finance): Rishi K. Narang: 9780470432068: Amazon.com: Books
How I Became a Quant: Insights from 25 of Wall Street's Elite: Richard R. Lindsey, Barry Schachter: 9780470452578: Amazon.com: Books
One of the most well known course on algo trading is EPAT by QuantInsti. https://www.quantinsti.com/epat/
If you do spend some time discretionary trading and still feel you'd like to deploy an algorithm to encapsulate your trading genius, consult Michael Halls-Moore's QuantStart.com for some highly structured information.
You need math for quantitative analyses. Go and build/improve your math skills. Learn calculus, linear algebra, statistics as best as you can. After that it's a good idea to read some books about modern investment theory (Robert A. Haugen). Next you should read books about Portfolio Theory, although most of them aren't much “quantitative”, i.e. they don't use matrix algebra etc (Modern Portfolio Theory and Investment Analysis - Elton, Gruber). After having some knowledge about that stuff you should consider the books of Carol Alexander (Market Risk Analysis I - IV). The first book of the series will introduce you to how calculus, linear algebra, statistics, numerical methods etc is used in quantitative finance. These books are really important. After that you can go on with Paul Wilmott on Quantitative Finance. In addition consider reading John Hull.
The biggest problem for beginners is that there aren't many books out there which explain both math and finance together. But the books I mentioned above are a good starting point after some introductory courses in calculus, linear algebra and statistics. For these you can look at Khan Academy, Michael van Biezen (has great playlists about the topics on YouTube), Prof. Leonard (also on YouTube. Has calc 1-3 and statistics course).
But again, don't start without enough math skills. You will lose motivation. Quantitative Finance is MATH. Nothing else.
Last but not least - learn a programming language like Julia, Python or R. Start with Python. You can also develop your own Algo system here http://tradingtuitions.com/build-you...utorial-part-1 and https://www.quora.com/I-want-to-know...ere-do-I-start
Answer:
Yes. One can absolutely get into Algorithmic trading even if they don’t have experience in Trading. Get as much leverage for as low as possible interest rate from street with flexible margin conditions. You can exploit unstructured market data by learning Natural language Processing models and opportunities to do semantic analysis of news and press releases. Resources to learn quantitive analysis and algo trading:
1. Absorb (almost) all publicly available information
You need to know three areas: Finance/Trading, Math (especially statistics) and Programming.
Recommended Readings:
Evaluation and Optimization of Trading Strategies – Pardo (Great insights on methods on building and testing trading strategies)
Trade your way to Financial Freedom – Van K Tharp (Ridiculous-Click bait title aside, this book is a great overview to mechanical trading systems)
Quantitative Trading – Ernest Chan (Great introduction to algo trading on a retail level.)
Trading and Exchanges: Market Microstructure for Practitioners – Larry Harris (Market microstructure is the science of how exchanges function and what actually happens when a trade is placed. It is important to know this information even though you are just starting out)
Algorithmic Trading & DMA – Barry Johnson (Shed light on banks’ execution algorithms. This is not directly applicable your algo trading but it is good to know)
The Quants – Scott Patterson (War stories of some top quants. Good as a bedtime read)
Beat the Market: A Scientific Stock Market System - Edward O. Thorp (Provides a good foundation of how to think about inefficiencies in the markets. Edward Thorp one of the pioneers of Quantitative Finance/Trading, I suggest reading up on all his works)
Recommended Courses/Sites:
Quantopian https://www.quantopian.com/ (Code, research, and discuss ideas with the community. Uses Python)
AlgoTrading101 http://algotrading101.com/ (Disclaimer: I own this site/course. Learn robot design theories, market theories and coding. Uses MQL4)
http://asirikuy.com (Learn trading concepts and backtesting theories. They recently developed their own backtesting and trading platform so this part is still new to me. But their knowledge base on trading concepts are good.)
Recommended Blogs/Forums (these includes finance, trading and algo trading forums):
https://www.quantnet.com
http://mechanicalforex.com/
http://www.forexfactory.com/
http://www.stevehopwoodforex.com/
https://www.quantstart.com/
Recommended Programming Languages:
1. If you know what products you want to trade, find suitable trading platforms for these products. Then learn the programming language API of this platform/backtesters.
If you starting out, I would recommend Quantopian (stocks only), Quantconnect (stocks and FX) or Metatrader 4 (FX and CFDs on equity indices, stocks and commodities). The programming languages used are Python, C# and MQL4 respectively.
2. Test and apply your knowledge – Develop your own understanding
Try and try again! Test and apply your knowledge. Build robots. Backtest them and run them live (on small amounts of money). The aim here is to understand what works and doesn’t, and to know why.
3. Meet and partner with others
1+1=3. There is definitely synergy when working with or discussing ideas with others in the same field. Meet and partner up with others (preferably experienced ones). You learn exponentially when you have people to bounce ideas with.
4. Get a job at a trading firm and get a mentor
You don’t say! Alright this part may be tricky if you don’t have strong academic qualifications.
Let me first lay down the bad news: It is incredibly difficult to get into top quant trading firms without Masters or Ph.D. in a quantitative subject (Computational Finance, Physics, Engineering, Statistics etc). It is almost impossible if you want to get into a HFT role without these qualifications (unless your dad owns the firm!).
Good news: There are 2 ways in which you can get into a decent hedge fund.
A) Build a strong track record using algo trading. If you have a strong record (on a decent amount of money) over a few years and can convince the guys at the fund that you have some sort of trading edge. They may give you a chance (although they may just want your strategies and kick you out later).
B) Have something to offer. Sometimes, manual traders want to build an algo trading team and don’t mind taking on fresh guys with some quantitative skills. Other times, firms need "number crunchers" and will take on someone who exhibit decent programming skills.
These should be enough to get you started. Some ending notes, the trading/investment space is getting incredibly competitive. Many strategies that used to work don’t any more. Personally, I think profitable trading systems/ideas have about a 2-3 years lifespan before others catch on to it. You need to innovate to stay ahead of the game, but innovation takes experience, wits, time, infrastructure and money.
Platforms:
Quantiacs https://www.youtube.com/channel/UCS8...JLIaA91s5uQzQw - Market Place For Algorithmic Trading Systems provide an algo-building-toolbox and backtesting data. Here are a few links with books, online courses, videos....:
Videos:
Quantiacs LLC
Page on coursera.org
Paper:
Page on decal.org
Books:
Quantitative Trading: How to Build Your Own Algorithmic Trading Business: Ernie Chan: 9780470284889: Amazon.com: Books
Quantitative Trading and Money Management, Revised Edition: Fred Gehm: 9781557385857: Amazon.com: Books
Inside the Black Box: The Simple Truth About Quantitative Trading (Wiley Finance): Rishi K. Narang: 9780470432068: Amazon.com: Books
How I Became a Quant: Insights from 25 of Wall Street's Elite: Richard R. Lindsey, Barry Schachter: 9780470452578: Amazon.com: Books
One of the most well known course on algo trading is EPAT by QuantInsti. https://www.quantinsti.com/epat/
If you do spend some time discretionary trading and still feel you'd like to deploy an algorithm to encapsulate your trading genius, consult Michael Halls-Moore's QuantStart.com for some highly structured information.
You need math for quantitative analyses. Go and build/improve your math skills. Learn calculus, linear algebra, statistics as best as you can. After that it's a good idea to read some books about modern investment theory (Robert A. Haugen). Next you should read books about Portfolio Theory, although most of them aren't much “quantitative”, i.e. they don't use matrix algebra etc (Modern Portfolio Theory and Investment Analysis - Elton, Gruber). After having some knowledge about that stuff you should consider the books of Carol Alexander (Market Risk Analysis I - IV). The first book of the series will introduce you to how calculus, linear algebra, statistics, numerical methods etc is used in quantitative finance. These books are really important. After that you can go on with Paul Wilmott on Quantitative Finance. In addition consider reading John Hull.
The biggest problem for beginners is that there aren't many books out there which explain both math and finance together. But the books I mentioned above are a good starting point after some introductory courses in calculus, linear algebra and statistics. For these you can look at Khan Academy, Michael van Biezen (has great playlists about the topics on YouTube), Prof. Leonard (also on YouTube. Has calc 1-3 and statistics course).
But again, don't start without enough math skills. You will lose motivation. Quantitative Finance is MATH. Nothing else.
Last but not least - learn a programming language like Julia, Python or R. Start with Python. You can also develop your own Algo system here http://tradingtuitions.com/build-you...utorial-part-1 and https://www.quora.com/I-want-to-know...ere-do-I-start
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
How can I use machine learning to be successful at forex trading?
Answer:
Machine learning will help you a great way in building predictive models to enhance your Forex trading. Regression and Classification models can help increase profitability. ML course: https://quantra.quantinsti.com/cours...ng-for-trading
Machine learning includes many concepts such as supervised learning, unsupervised learning and deep and reinforcement learning. The purpose of supervised learning is to establish a relationship between two datasets and to use one dataset to forecast the other. The purpose of unsupervised learning is to train an artificial intelligence algorithm using information that is neither classified nor labelled and allowing the algorithm to act on that information without guidance. The purpose of deep learning is to use multi-layered neural networks to analyze a trend, while reinforcement learning uses algorithms to explore and find the most profitable trading strategies.
As a result, the skills required for a data scientist is actually the same as for any other quantitative researchers. Existing buy side and sell side quants with backgrounds in computer science, statistics, maths, financial engineering, econometrics and natural sciences are continuously moving into this new field of expertise.
Apart from Machine Learning skills, expertise in software development is also a useful asset. Most of the Machine Learning methods and libraries are already there (e.g. in Python): you just need to know how to apply the existing models and be confident to modify them if required.
In general, the use of ML-based trading systems has started to make trading easier and more profitable. While these systems are common among both large hedge funds and smaller startups, third party trading software developers have also provided a new way for individual traders to get in the game.
All the above have changed the way traders are doing their every day jobs. We are living in an era where making money in the stock market is not only a question of how experienced you are, but also of how powerful your trading tool is.
A good introduction to strategy development, as well as machine learning is Quantitative Technical Analysis by Howard Bandy, which I can highly recommend.
This blog gives you a brief on the following segments: (https://www.quantinsti.com/blog/over...rning-trading/)
Getting the data and making it usable.
Creating Hyper-parameters.
Splitting the data into test and train sets.
Getting the best-fit parameters to create a new function.
Making the predictions and checking the performance.
Finally, some food for thought.
You can read the complete article here: https://www.quantinsti.com/blog/trad...arning-python/
Answer:
Machine learning will help you a great way in building predictive models to enhance your Forex trading. Regression and Classification models can help increase profitability. ML course: https://quantra.quantinsti.com/cours...ng-for-trading
Machine learning includes many concepts such as supervised learning, unsupervised learning and deep and reinforcement learning. The purpose of supervised learning is to establish a relationship between two datasets and to use one dataset to forecast the other. The purpose of unsupervised learning is to train an artificial intelligence algorithm using information that is neither classified nor labelled and allowing the algorithm to act on that information without guidance. The purpose of deep learning is to use multi-layered neural networks to analyze a trend, while reinforcement learning uses algorithms to explore and find the most profitable trading strategies.
As a result, the skills required for a data scientist is actually the same as for any other quantitative researchers. Existing buy side and sell side quants with backgrounds in computer science, statistics, maths, financial engineering, econometrics and natural sciences are continuously moving into this new field of expertise.
Apart from Machine Learning skills, expertise in software development is also a useful asset. Most of the Machine Learning methods and libraries are already there (e.g. in Python): you just need to know how to apply the existing models and be confident to modify them if required.
In general, the use of ML-based trading systems has started to make trading easier and more profitable. While these systems are common among both large hedge funds and smaller startups, third party trading software developers have also provided a new way for individual traders to get in the game.
All the above have changed the way traders are doing their every day jobs. We are living in an era where making money in the stock market is not only a question of how experienced you are, but also of how powerful your trading tool is.
A good introduction to strategy development, as well as machine learning is Quantitative Technical Analysis by Howard Bandy, which I can highly recommend.
This blog gives you a brief on the following segments: (https://www.quantinsti.com/blog/over...rning-trading/)
Getting the data and making it usable.
Creating Hyper-parameters.
Splitting the data into test and train sets.
Getting the best-fit parameters to create a new function.
Making the predictions and checking the performance.
Finally, some food for thought.
You can read the complete article here: https://www.quantinsti.com/blog/trad...arning-python/
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
Should I use C++ (posix), Java, or Python for algorithmic trading?
Answer:
If you are not really into HFT, which includes capturing those fleeting opportunities of arbitrage, then C++ is not really required. You can go for python (eg, Quantopian platform, Kite platform), C# ( Eg. Ninjatrader ). Most trading platforms provide python APIs.
I would avoid Java as it not only can be slow, it can also do thing the you may not want. If you are looking for speed C++ as it is closest to the hardware. I would also look as C++ 11 or later as this version has the least among of hackish code.
Answer:
If you are not really into HFT, which includes capturing those fleeting opportunities of arbitrage, then C++ is not really required. You can go for python (eg, Quantopian platform, Kite platform), C# ( Eg. Ninjatrader ). Most trading platforms provide python APIs.
I would avoid Java as it not only can be slow, it can also do thing the you may not want. If you are looking for speed C++ as it is closest to the hardware. I would also look as C++ 11 or later as this version has the least among of hackish code.
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
Global FX Insights pdf of 4 October 2018 and 25 September 2018. See attachment. This is a comprehensive daily market research and analytics, with insightful commentary and charts. (downloaded from https://www.lmax.com/blog/global-fx-insights/)
"EURUSD – fundamental overview The Euro has come under additional pressure this week, with the latest round of setbacks driven off rising US treasury yields that have opened up a bigger advantage for the Buck on the rate differential front. Ongoing solid US economic data and a wave of hawkish comments have been inspiring the move, particularly after Wednesday’s hawkish speak from the Fed Chair. Still, looking out, adjustments in the Fed’s projections have not reflected a major acceleration in the rate hike process and this coupled with soft Dollar implications from US trade policy, could once again invite demand into the dip. Absence of first tier data in Europe, leaves only US initial jobless claims and factory orders as the notable standouts."
"EURUSD – fundamental overview The Euro has come under additional pressure this week, with the latest round of setbacks driven off rising US treasury yields that have opened up a bigger advantage for the Buck on the rate differential front. Ongoing solid US economic data and a wave of hawkish comments have been inspiring the move, particularly after Wednesday’s hawkish speak from the Fed Chair. Still, looking out, adjustments in the Fed’s projections have not reflected a major acceleration in the rate hike process and this coupled with soft Dollar implications from US trade policy, could once again invite demand into the dip. Absence of first tier data in Europe, leaves only US initial jobless claims and factory orders as the notable standouts."
Attached File(s)
Global FX Insights - 25 September 2018.pdf
490 KB
|
264 downloads
FX-TCA-Transaction-Cost-Analysis-white-paper.pdf
2.5 MB
|
444 downloads
Global FX Insights - 4 October 2018.pdf
471 KB
|
234 downloads
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
Does anyone have experience in building poker bots? If so, could you tell us about it, any problems you had etc?
Answer:
"Yes. There is a good literature out of Alberta on various game-theory approaches to limit heads up etc. Names that come to mind are billings, lanctot, you can gogle from there. The main hassle is interfacing the strategy to the actual poker room. I treated it as an academic exercise and did not follow through with that part." https://www.deepstack.ai/
Answer:
"Yes. There is a good literature out of Alberta on various game-theory approaches to limit heads up etc. Names that come to mind are billings, lanctot, you can gogle from there. The main hassle is interfacing the strategy to the actual poker room. I treated it as an academic exercise and did not follow through with that part." https://www.deepstack.ai/
Attached File(s)
DeepStack.pdf
320 KB
|
241 downloads
DeepStackSupplement.pdf
366 KB
|
218 downloads
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
Anyone used Physics/engineering strategy? My professor said that a few advanced techniques he uses in algo Trading are Kalman Filters, Fourier Transformation, pairs trading (using cointegration), state space models, hidden Markov model, particle filtering and VAR (vector auto regression).
Does anyone have experience with any of these?
Answer:
Yes. They are all just mathematical tools. Cointegration and VAR are concepts that come up absolutely everywhere when dealing with time series. Kalman filters are commonly used in stat arb, here is a very basic overview. http://jonathankinlay.com/2015/02/st...kalman-filter/
Your professor is talking about r/DSP and yes. Well, Hidden Markov is more data science though. Though, I find custom filters work better. The most simple momentum strategy works significantly better than most LSTM or MCMC techniques. In my experience inaccuracy increases proportionally to complexity. But it’s good to be aware of the advanced techniques because they do have their use cases.
I saw lots of math PhDs work in the derivatives pricing areas at big banks doing heavy duty modeling, yet the traders who made the big dollars in theses areas were often the MBA types. Sure most of them couldn't write the code for the pricing models but they had a much better understanding of risk and the big picture. Absolutely zero need to know any measure theory. Similar thing with ML. The right MBA (or other background) can manage a team of ML scientists/engineers.
Examples of the said advanced techniques: Kalman filters for computing hedge ratios, HMMs for regime detection, particle filtering for sequential learning of say stochastic vol models or inflation models, Fourier transforms for doing spectral analysis of variance/covariance, VARs for all sorts of macro modeling, etc.
Does anyone have experience with any of these?
Answer:
Yes. They are all just mathematical tools. Cointegration and VAR are concepts that come up absolutely everywhere when dealing with time series. Kalman filters are commonly used in stat arb, here is a very basic overview. http://jonathankinlay.com/2015/02/st...kalman-filter/
Your professor is talking about r/DSP and yes. Well, Hidden Markov is more data science though. Though, I find custom filters work better. The most simple momentum strategy works significantly better than most LSTM or MCMC techniques. In my experience inaccuracy increases proportionally to complexity. But it’s good to be aware of the advanced techniques because they do have their use cases.
I saw lots of math PhDs work in the derivatives pricing areas at big banks doing heavy duty modeling, yet the traders who made the big dollars in theses areas were often the MBA types. Sure most of them couldn't write the code for the pricing models but they had a much better understanding of risk and the big picture. Absolutely zero need to know any measure theory. Similar thing with ML. The right MBA (or other background) can manage a team of ML scientists/engineers.
Examples of the said advanced techniques: Kalman filters for computing hedge ratios, HMMs for regime detection, particle filtering for sequential learning of say stochastic vol models or inflation models, Fourier transforms for doing spectral analysis of variance/covariance, VARs for all sorts of macro modeling, etc.
Attached Images
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
Is technical analyses (TA and PA) a joke? Technical Analysis is just survivorship bias, and overfitting to backtests. Price action is truest chaotic.
Positive answer:
I disagree. TA is just an additional signal that you may choose to implement into your model. And a model at the end of the day is just a something that helps you trade, they are never 100% correct and all of them fail constantly. The exception is HFT which is not really trading and risk management but technology optimization. I use various TA as just one of my signals to trade.
Why does it work? Because other people use it. A lot of trading is human psychology and people are frightened by certain levels in securities and greedy with others. TA can be used as a successful symbol to help you understand momentum and mean reversion and what other traders and algos look at. Arbitrage, is very much the real deal. There is also quite a bit of real mathematical theory out there if you can handle it--eg: https://www.amazon.com/Algorithmic-H.../dp/1107091144
The equity risk premium is time-varying and you can't necessarily rely on the unconditional mean (i.e. historical average) to estimate it.
Check the actual research: https://papers.ssrn.com/sol3/papers....act_id=2202060
Historically, there has been a dearth of real academic research supporting TA. That’s in part because it was easy to write off for the very same anecdotal reasons that it can offer confirmation bias to amateur traders who get lucky. Guys like Andy Lo at MIT have done a lot to change that in recent years. If you’re interested in an evidence-based discussion of TA, I’d recommend reading his work as well as the paper above.
Furthermore, Renaissance Technologies https://en.wikipedia.org/wiki/Renaissance_Technologies. Averaged 71.8% annual return from 1994 to 2014. Bases all their trading on big data and mathematical analysis, no fundamentals.
Negative answer:
I agree. The efficient market hypothesis / theory (EMT) postulated by Fama is out there for almost 50 years now. It even won a Nobel prize in 2013! It states that capital markets (already back in the 70's) are so efficient that any piece of information is priced into an entity's stock price, making technical analysis, fundamental research and even insider trading obsolete. This does not mean that you can't get lucky by using whatever indicator. However, the consistency of you outperforming the market is simply not given. Stating that, people (as posted above) will always bring examples as counter argument. Even an outperformance over twenty years is possible for single agents in the market due to the law of large numbers: With millions of market participants, there will be someone that outperforms the market considerably longer than the average. Research, however, shows that this comes down to pure luck.
Even being widely accepted and honored by prestigious prices, why is the EMT not mainstream you might ask. There are several reasons:
"Unscientificness" of poorly educated traders leads to malpractice that examples are used to seemingly debilitate EMT >> remedy: look into law of large numbers and Standard and Poor's outperformance consistency report stating that only 1% of traders outperform the benchmark over 5 years. This goes down dramatically with every year added.
Greed and the wish for a 'quick win': Banks, brokers, stock markets, and managers make somewhat over $ 750 bn a year in trading. Additionally, newspapers, investment advisors, gurus, and authors make a living through repeated advice. To all of them, active trading is a vital income stream and they make ends meet spreading misinformation and, how I would call it, "stock pornography".
It is counter intuitive that passive investment strategies would outperform active ones. Why? Because everywhere in life, hard work tends to pay off. Not so much in financial markets though. This confuses a lot of agents. It is hard to understand that the market is so very efficient already and that you are only a small gear in a big box. Here, behavioral finance argues with overestimation of agents' own capabilities. Furthermore, who doesn't like the excitement and good story behind a successful year participating in the market. >> Remedy: look into the plethora of studies that, by comparing huge amounts of actively managed portfolios to passive ones that the latter consistently outperformed the first.
The very definition of social markets makes active trading strategies obsolete: once agents realize that there is an active strategy (market anomalies, which do exist and are in line with EMT), than people want to capitalize on that. This leads to demand exceeding supply, prices rise, and the formerly known winner strategy is exploited. Here, algorithm trading and AI trading might be a superior strategy for a while but the very law of one price makes arbitrage less and less likely to exploit because other agents beef up their tools. A fitting analogy: bitcoin farming was of interest for private people only until corps saw the potential and exploited it. Once it is harnested, it will never emerge again. This is in line with EMT because a piece of information got public and is now priced in. There were people that got rich on it but the distribution of wealth in this case comes solely down to luck and former success is not imitable. Here, supporters of active trading often argue with prophets and hail bringers that have forecasted an event/crisis. Two things: 1) selection bias, people capitalize on their lucky observation whereas the millions of wrongful statements are kept in secret 2) studies again show that these gurus were lucky once and did not consistently outperform markets after that.
There are many more reasons why buy and hold is superior strategy as a private investor. However, there exists a cult of people that very zealously and in a frenzy would always stick to their indicators, TA, and investment gurus. However, if you want to really be on top of the market, don't listen to sales people, listen to researchers, Akademia, retired finance VIPs, and, as it might be sensible, research what Nobel prize winning individuals have to say.
If you’ve ever read the EMH, you will see that one of the base assumptions is that investors are rational. And we have both agreed that fact is untrue. So therefore, logically, you are believing in something that is based on a false assumption, and therefore, you MIGHT be wrong because you are definitely not right.
Put quite simply: P1: The EMH requires all investors to be rational. P2: Not all investors are rational C: Therefore, a basic assumption of the EMH is not met.
And yes, you can reliably exploit it over decades. Renaissance Technologies, George Soros, Berkshire Hathaway, the list goes on and on. But aren’t they simply outliers? But hey, they have super computers and other informational advantages that give them a leg up. Well, then IT IS POSSIBLE to exploit the market inefficiencies over decades. I certainly go with an index strategy.
Positive answer:
I disagree. TA is just an additional signal that you may choose to implement into your model. And a model at the end of the day is just a something that helps you trade, they are never 100% correct and all of them fail constantly. The exception is HFT which is not really trading and risk management but technology optimization. I use various TA as just one of my signals to trade.
Why does it work? Because other people use it. A lot of trading is human psychology and people are frightened by certain levels in securities and greedy with others. TA can be used as a successful symbol to help you understand momentum and mean reversion and what other traders and algos look at. Arbitrage, is very much the real deal. There is also quite a bit of real mathematical theory out there if you can handle it--eg: https://www.amazon.com/Algorithmic-H.../dp/1107091144
The equity risk premium is time-varying and you can't necessarily rely on the unconditional mean (i.e. historical average) to estimate it.
Check the actual research: https://papers.ssrn.com/sol3/papers....act_id=2202060
Historically, there has been a dearth of real academic research supporting TA. That’s in part because it was easy to write off for the very same anecdotal reasons that it can offer confirmation bias to amateur traders who get lucky. Guys like Andy Lo at MIT have done a lot to change that in recent years. If you’re interested in an evidence-based discussion of TA, I’d recommend reading his work as well as the paper above.
Furthermore, Renaissance Technologies https://en.wikipedia.org/wiki/Renaissance_Technologies. Averaged 71.8% annual return from 1994 to 2014. Bases all their trading on big data and mathematical analysis, no fundamentals.
Negative answer:
I agree. The efficient market hypothesis / theory (EMT) postulated by Fama is out there for almost 50 years now. It even won a Nobel prize in 2013! It states that capital markets (already back in the 70's) are so efficient that any piece of information is priced into an entity's stock price, making technical analysis, fundamental research and even insider trading obsolete. This does not mean that you can't get lucky by using whatever indicator. However, the consistency of you outperforming the market is simply not given. Stating that, people (as posted above) will always bring examples as counter argument. Even an outperformance over twenty years is possible for single agents in the market due to the law of large numbers: With millions of market participants, there will be someone that outperforms the market considerably longer than the average. Research, however, shows that this comes down to pure luck.
Even being widely accepted and honored by prestigious prices, why is the EMT not mainstream you might ask. There are several reasons:
"Unscientificness" of poorly educated traders leads to malpractice that examples are used to seemingly debilitate EMT >> remedy: look into law of large numbers and Standard and Poor's outperformance consistency report stating that only 1% of traders outperform the benchmark over 5 years. This goes down dramatically with every year added.
Greed and the wish for a 'quick win': Banks, brokers, stock markets, and managers make somewhat over $ 750 bn a year in trading. Additionally, newspapers, investment advisors, gurus, and authors make a living through repeated advice. To all of them, active trading is a vital income stream and they make ends meet spreading misinformation and, how I would call it, "stock pornography".
It is counter intuitive that passive investment strategies would outperform active ones. Why? Because everywhere in life, hard work tends to pay off. Not so much in financial markets though. This confuses a lot of agents. It is hard to understand that the market is so very efficient already and that you are only a small gear in a big box. Here, behavioral finance argues with overestimation of agents' own capabilities. Furthermore, who doesn't like the excitement and good story behind a successful year participating in the market. >> Remedy: look into the plethora of studies that, by comparing huge amounts of actively managed portfolios to passive ones that the latter consistently outperformed the first.
The very definition of social markets makes active trading strategies obsolete: once agents realize that there is an active strategy (market anomalies, which do exist and are in line with EMT), than people want to capitalize on that. This leads to demand exceeding supply, prices rise, and the formerly known winner strategy is exploited. Here, algorithm trading and AI trading might be a superior strategy for a while but the very law of one price makes arbitrage less and less likely to exploit because other agents beef up their tools. A fitting analogy: bitcoin farming was of interest for private people only until corps saw the potential and exploited it. Once it is harnested, it will never emerge again. This is in line with EMT because a piece of information got public and is now priced in. There were people that got rich on it but the distribution of wealth in this case comes solely down to luck and former success is not imitable. Here, supporters of active trading often argue with prophets and hail bringers that have forecasted an event/crisis. Two things: 1) selection bias, people capitalize on their lucky observation whereas the millions of wrongful statements are kept in secret 2) studies again show that these gurus were lucky once and did not consistently outperform markets after that.
There are many more reasons why buy and hold is superior strategy as a private investor. However, there exists a cult of people that very zealously and in a frenzy would always stick to their indicators, TA, and investment gurus. However, if you want to really be on top of the market, don't listen to sales people, listen to researchers, Akademia, retired finance VIPs, and, as it might be sensible, research what Nobel prize winning individuals have to say.
If you’ve ever read the EMH, you will see that one of the base assumptions is that investors are rational. And we have both agreed that fact is untrue. So therefore, logically, you are believing in something that is based on a false assumption, and therefore, you MIGHT be wrong because you are definitely not right.
Put quite simply: P1: The EMH requires all investors to be rational. P2: Not all investors are rational C: Therefore, a basic assumption of the EMH is not met.
And yes, you can reliably exploit it over decades. Renaissance Technologies, George Soros, Berkshire Hathaway, the list goes on and on. But aren’t they simply outliers? But hey, they have super computers and other informational advantages that give them a leg up. Well, then IT IS POSSIBLE to exploit the market inefficiencies over decades. I certainly go with an index strategy.
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
"Over the past months, I have spent some time working on our alternative data. There is a lot more to come soon.
However, I did take some time to put together a backtest that shows some of the power of this alternative data.
Alternative datasets are improving our trading strategies at CloudQuant. In the following example, we added an easy check of social sentiment. Before going long, check to see if social sentiment was favorable. Instead of following the original algo, simply add this additional check. If sentiment was positive, go ahead and go long. Otherwise, don’t trade. This social sentiment provided an insurance policy essentially for the underlying strategy, and it improves the performance. One can easily see the results in the following diagrams where the first trading strategy lost money and the second made over $170,000."
The source code to the BreakOut Strategy with Social Sentiment is on the overall link.
Backtesting from January 2, 2018 to September 12, 2018 produced the following results:
However, I did take some time to put together a backtest that shows some of the power of this alternative data.
Alternative datasets are improving our trading strategies at CloudQuant. In the following example, we added an easy check of social sentiment. Before going long, check to see if social sentiment was favorable. Instead of following the original algo, simply add this additional check. If sentiment was positive, go ahead and go long. Otherwise, don’t trade. This social sentiment provided an insurance policy essentially for the underlying strategy, and it improves the performance. One can easily see the results in the following diagrams where the first trading strategy lost money and the second made over $170,000."
The source code to the BreakOut Strategy with Social Sentiment is on the overall link.
Backtesting from January 2, 2018 to September 12, 2018 produced the following results:
- Sharpe Ratio 0.73
- Calmar Ratio 1.40
- Trade Kelly Edge: 2.20%
- Daily Kelly Edge: 7.46%
- Total Profit: $8,822.55
- Total Return: 1.70%
- Total Net Profit: $8,262.76
- Total Commission: $559.79
- Avg Dollar Risk: $120,019.59
- Avg Trade Duration: 2 hr 38 min
- Compound Annual ROR: 2.41%
- Max Drawdown: -1.72%
- Avg of Roll 20 Day Win: 42.13%
- Monthly Win Percentage: 44.44%
- Net Edge/Share2.15¢
- Number of Trades: 1855
- Number of Years: 0.70
- Trade Win: 52.61%
- Daily Win: 50.41%
Source: https://forum.cloudquant.com/discuss...egy-profitable
Inserted Code
[list=1][*][color=#880000]# Created by Tayloe Draughon - Product Manager, CloudQuant[/color][*][color=#880000]# This is a strategy designed to follow major market movements (up or down). [/color][*][color=#880000]# It enters orders to put on a position when a given stocks is trading[/color][*][color=#880000]# well outside their average from previous days.[/color][*][*][color=#880000]# This version of the script uses SMA to validate that we should[/color][*][color=#880000]# enter into a position.[/color][*][*][color=#0000DD]from[/color][color=#000000] cloudquant[/color][color=#666600].[/color][color=#000000]interfaces [/color][color=#0000DD]import[/color][color=#000000] [/color][color=#660066]Strategy[/color][*][color=#0000DD]from[/color][color=#000000] cloudquant[/color][color=#666600].[/color][color=#000000]util [/color][color=#0000DD]import[/color][color=#000000] dt_from_muts[/color][*][color=#0000DD]import[/color][color=#000000] numpy [/color][color=#0000DD]as[/color][color=#000000] np[/color][*][color=#880000]##########################################[/color][*][color=#880000]# Global Variables for the script[/color][*][color=#0000DD]from[/color][color=#000000] cloudquant[/color][color=#666600].[/color][color=#000000]interfaces [/color][color=#0000DD]import[/color][color=#000000] [/color][color=#660066]Strategy[/color][*][color=#0000DD]from[/color][color=#000000] cloudquant[/color][color=#666600].[/color][color=#000000]util [/color][color=#0000DD]import[/color][color=#000000] dt_from_muts[/color][*][color=#0000DD]import[/color][color=#000000] numpy [/color][color=#0000DD]as[/color][color=#000000] np[/color][*][*][*][color=#000000]end_delay [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]5[/color][color=#000000] [/color][color=#880000]# in minutes, how long before the end of the day to stop trading.[/color][*][color=#000000]start_delay [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]10[/color][color=#000000] [/color][color=#880000]# in minutes, how long after market open before we start trading[/color][*][color=#000000]index[/color][color=#666600]=[/color][color=#006666]5[/color][color=#000000] [/color][color=#880000]# how many days of highs to average over[/color][*][color=#000000]purchase_atr_ratio[/color][color=#666600]=[/color][color=#006666]3.0[/color][color=#000000] [/color][color=#880000]# what fraction of the atr for a stock to be bought/shorted[/color][*][color=#000000]sell_atr_ratio[/color][color=#666600]=[/color][color=#006666]3.0[/color][color=#000000] [/color][color=#880000]# what fraction of the atr for a stock to be exited from[/color][*][color=#000000]filename [/color][color=#666600]=[/color][color=#000000] [/color][color=#008800]"breakout_sma.csv"[/color][color=#000000] [/color][color=#880000]#user file where data is collected.[/color][*][*][*][color=#000000]allow_shorts [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]False[/color][color=#000000] [/color][color=#880000]# if set to True, we will allow short sales on downward breakouts[/color][*][color=#000000]MAX_PNL_PER_SHARE [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]1.75[/color][color=#000000] [/color][color=#880000]# Target profit or loss for the strategy[/color][*][color=#000000]MAX_PARTICIPATION [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]0.03[/color][color=#000000] [/color][color=#880000]#Maximum percentage of the previous minuteBar volume that we will trade.[/color][*][color=#000000]MIN_ORD_QTY [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]10[/color][color=#000000] [/color][color=#880000]# fewest number of shares that we will order when entering into a position.[/color][*][color=#000000]MAX_ORD_QTY [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]800[/color][color=#000000] [/color][color=#880000]#maximum number of shares that we will order when entering into a position.[/color][*][*][*][color=#0000DD]class[/color][color=#000000] breakout_withSMA[/color][color=#666600]([/color][color=#660066]Strategy[/color][color=#666600]):[/color][*][color=#006666]@classmethod[/color][*][color=#0000DD]def[/color][color=#000000] is_symbol_qualified[/color][color=#666600]([/color][color=#000000]cls[/color][color=#666600],[/color][color=#000000] symbol[/color][color=#666600],[/color][color=#000000] md[/color][color=#666600],[/color][color=#000000] service[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600]):[/color][*][color=#000000]handle_list [/color][color=#666600]=[/color][color=#000000] service[/color][color=#666600].[/color][color=#000000]symbol_list[/color][color=#666600].[/color][color=#000000]get_handle[/color][color=#666600]([/color][color=#008800]'9a802d98-a2d7-4326-af64-cea18f8b5d61'[/color][color=#666600])[/color][color=#000000] [/color][color=#880000]#this is all stocks on S&P500[/color][*][color=#0000DD]return[/color][color=#000000] service[/color][color=#666600].[/color][color=#000000]symbol_list[/color][color=#666600].[/color][color=#000000]in_list[/color][color=#666600]([/color][color=#000000]handle_list[/color][color=#666600],[/color][color=#000000]symbol[/color][color=#666600])[/color][*][color=#880000]#return symbol in ['AAPL', 'EBAY', 'AMZN', 'ORCL', 'WMT'][/color][*][*][color=#880000]#############################################################################[/color][*][color=#880000]# Setting up to get information from SMA for our s-score on social sentiment[/color][*][color=#880000]#############################################################################[/color][*][color=#006666]@classmethod[/color][*][color=#0000DD]def[/color][color=#000000] register_event_streams[/color][color=#666600]([/color][color=#000000]cls[/color][color=#666600],[/color][color=#000000] md[/color][color=#666600],[/color][color=#000000] service[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600]):[/color][*][color=#880000]#return {'!sentiment/sma/tw/15min': 'on_event_sma_tw', '!sentiment/sma/st/15min':'on_event_sma_tw'}[/color][*][color=#0000DD]return[/color][color=#000000] [/color][color=#666600]{[/color][color=#008800]'!sentiment/sma/st/15min'[/color][color=#666600]:[/color][color=#000000] [/color][color=#008800]'on_event_sma_st'[/color][color=#666600],[/color][color=#000000] [/color][color=#008800]'!sentiment/sma/st/15min'[/color][color=#666600]:[/color][color=#008800]'on_event_sma_st'[/color][color=#666600]}[/color][*][*][color=#0000DD]def[/color][color=#000000] on_event_sma_st[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]event[/color][color=#666600],[/color][color=#000000] md[/color][color=#666600],[/color][color=#000000] order[/color][color=#666600],[/color][color=#000000] service[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600]):[/color][*][color=#880000]#print service.time_to_string(event.timestamp),"sma_st",event.field['s-score'][/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]event[/color][color=#666600].[/color][color=#000000]field[/color][color=#666600][[/color][color=#008800]'s-score'[/color][color=#666600]][/color][*][color=#880000]#print event[/color][*][*][color=#0000DD]def[/color][color=#000000] on_event_sma_tw[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]event[/color][color=#666600],[/color][color=#000000] md[/color][color=#666600],[/color][color=#000000] order[/color][color=#666600],[/color][color=#000000] service[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600]):[/color][*][color=#880000]#print service.time_to_string(event.timestamp),"sma_tw",event.field['s-score'][/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]event[/color][color=#666600].[/color][color=#000000]field[/color][color=#666600][[/color][color=#008800]'s-score'[/color][color=#666600]][/color][*][color=#880000]#print event [/color][*][*][*][color=#006666]@classmethod[/color][*][color=#0000DD]def[/color][color=#000000] on_strategy_start[/color][color=#666600]([/color][color=#000000]cls[/color][color=#666600],[/color][color=#000000]md[/color][color=#666600],[/color][color=#000000] service[/color][color=#666600],[/color][color=#000000]account[/color][color=#666600]):[/color][*][color=#000000]title_row [/color][color=#666600]=[/color][color=#008800]"Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] title_row [/color][color=#666600])[/color][*][*][color=#0000DD]def[/color][color=#000000] __init__[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600]):[/color][color=#000000] [/color][*][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]0[/color][color=#000000] [/color][color=#880000]# estimated price of our position[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]model_start [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]0[/color][color=#000000] [/color][color=#880000]# time to start, set in on_start[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]IsPurchasable[/color][color=#666600]=[/color][color=#0000DD]True[/color][color=#000000] [/color][color=#880000]# OK to purchase? (not repurchasing what we already sold)[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] MAX_ORD_QTY [/color][color=#880000]# This variable will change with the volume of the previous bar * MAX_PARTICIPATION[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]0[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]0[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]IsInClose[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]False[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]PosToday[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]False[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]ClosingOrder[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] [/color][color=#666600]-[/color][color=#006666]1[/color][*][*][color=#880000]############################################################[/color][*][color=#880000]# daily bar statistics populated properly in strategy start[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_daily[/color][color=#666600]=[/color][color=#006666]0[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600]=[/color][color=#006666]0[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600]=[/color][color=#006666]0[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600]=[/color][color=#006666]0[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600]=[/color][color=#006666]0[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]1.0[/color][*][*][*][color=#0000DD]def[/color][color=#000000] on_finish[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600],[/color][color=#000000] md[/color][color=#666600],[/color][color=#000000] order[/color][color=#666600],[/color][color=#000000] service[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600]):[/color][*][color=#0000DD]pass[/color][*][*][color=#0000DD]def[/color][color=#000000] on_minute_bar[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]event[/color][color=#666600],[/color][color=#000000] md[/color][color=#666600],[/color][color=#000000] order[/color][color=#666600],[/color][color=#000000] service[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600],[/color][color=#000000] bar[/color][color=#666600]):[/color][color=#000000] [/color][*][color=#000000]bar_1 [/color][color=#666600]=[/color][color=#000000] bar[/color][color=#666600].[/color][color=#000000]minute[/color][color=#666600]()[/color][*][color=#000000]bar_close [/color][color=#666600]=[/color][color=#000000] bar_1[/color][color=#666600].[/color][color=#000000]close[/color][*][color=#0000DD]try[/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]int[/color][color=#666600]([/color][color=#000000]bar_1[/color][color=#666600].[/color][color=#000000]volume[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]]*[/color][color=#000000] MAX_PARTICIPATION[/color][color=#666600])[/color][*][color=#0000DD]if[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#000000] [/color][color=#666600]>[/color][color=#000000] MAX_ORD_QTY[/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] MAX_ORD_QTY[/color][*][color=#0000DD]if[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#000000] [/color][color=#666600]<=[/color][color=#000000] [/color][color=#006666]0[/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] MIN_ORD_QTY[/color][*][color=#0000DD]except[/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] MIN_ORD_QTY[/color][*][color=#880000]###############################################################[/color][*][color=#880000]# make sure it's not too late in the day - We don't want to open[/color][*][color=#880000]# a position in the closing period of the day.[/color][*][color=#0000DD]if[/color][color=#000000] service[/color][color=#666600].[/color][color=#000000]system_time [/color][color=#666600]<[/color][color=#000000] md[/color][color=#666600].[/color][color=#000000]market_close_time [/color][color=#666600]-[/color][color=#000000] service[/color][color=#666600].[/color][color=#000000]time_interval[/color][color=#666600]([/color][color=#000000]minutes[/color][color=#666600]=[/color][color=#000000]end_delay[/color][color=#666600],[/color][color=#000000] seconds[/color][color=#666600]=[/color][color=#006666]1[/color][color=#666600]):[/color][*][color=#000000]bar_1 [/color][color=#666600]=[/color][color=#000000] bar[/color][color=#666600].[/color][color=#000000]minute[/color][color=#666600]()[/color][*][color=#000000]bar_close [/color][color=#666600]=[/color][color=#000000] bar_1[/color][color=#666600].[/color][color=#000000]close[/color][*][*][color=#880000]# no need to calc alpha signal if there is a position on already[/color][*][color=#0000DD]if[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares [/color][color=#666600]==[/color][color=#000000] [/color][color=#006666]0[/color][color=#666600]:[/color][*][color=#880000]# get the 1 minute bar data[/color][*][color=#0000DD]if[/color][color=#000000] len[/color][color=#666600]([/color][color=#000000]bar_close[/color][color=#666600])[/color][color=#000000] [/color][color=#666600]>[/color][color=#000000] [/color][color=#006666]0[/color][color=#000000] [/color][color=#0000DD]and[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] [/color][color=#666600]!=[/color][color=#000000] [/color][color=#006666]0[/color][color=#666600]:[/color][*][color=#880000]#if the stock has returned to its normal values, we would consider entering a position on it.[/color][*][color=#0000DD]if[/color][color=#000000] [/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600]+[/color][color=#000000]purchase_atr_ratio [/color][color=#666600]*[/color][color=#000000] md[/color][color=#666600].[/color][color=#000000]stat[/color][color=#666600].[/color][color=#000000]atr[/color][color=#666600])[/color][color=#000000] [/color][color=#666600]>[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] \[/color][*][color=#0000DD]and[/color][color=#000000] [/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600]-[/color][color=#000000]purchase_atr_ratio [/color][color=#666600]*[/color][color=#000000] md[/color][color=#666600].[/color][color=#000000]stat[/color][color=#666600].[/color][color=#000000]atr[/color][color=#666600])[/color][color=#000000] [/color][color=#666600]<[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]]:[/color][*][color=#0000DD]if[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]PosToday[/color][color=#000000] [/color][color=#666600]!=[/color][color=#000000] [/color][color=#0000DD]True[/color][color=#666600]:[/color][color=#000000] [/color][color=#880000]############## Only allow one position per day per symbol[/color][*][color=#0000DD]try[/color][color=#666600]:[/color][*][color=#0000DD]if[/color][color=#000000] bar_1[/color][color=#666600].[/color][color=#000000]volume[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] [/color][color=#666600]<[/color][color=#000000] [/color][color=#006666]5[/color][color=#000000] [/color][color=#666600]*[/color][color=#000000] MAX_ORD_QTY[/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]IsPurchasable[/color][color=#666600]=[/color][color=#0000DD]False[/color][color=#000000] [/color][color=#880000]### Too Thinly Traded[/color][*][color=#0000DD]else[/color][color=#666600]:[/color][color=#000000] [/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]IsPurchasable[/color][color=#666600]=[/color][color=#0000DD]True[/color][*][color=#0000DD]except[/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]IsPurchasable[/color][color=#666600]=[/color][color=#0000DD]False[/color][*][*][color=#880000]# we want to have at least a certain amount of time left before entering positions[/color][*][*][color=#0000DD]if[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]IsPurchasable[/color][color=#666600]==[/color][color=#0000DD]True[/color][color=#000000] [/color][color=#0000DD]and[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]PosToday[/color][color=#000000] [/color][color=#666600]!=[/color][color=#000000] [/color][color=#0000DD]True[/color][color=#666600]:[/color][color=#000000] [/color][color=#880000]############## No position on, therefore if purchasable, enter into a position.[/color][*][*][color=#880000]# go long if stock is well above its normal values[/color][*][color=#0000DD]if[/color][color=#000000] [/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600]+[/color][color=#000000]purchase_atr_ratio[/color][color=#666600]*[/color][color=#000000]md[/color][color=#666600].[/color][color=#000000]stat[/color][color=#666600].[/color][color=#000000]atr[/color][color=#666600])<[/color][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]]:[/color][*][color=#880000]#print(self.symbol)[/color][*][color=#880000]#print(self.average_high)[/color][*][color=#880000]#print(md.stat.atr)[/color][*][color=#880000]#print(bar_close[0])[/color][*][color=#0000DD]if[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score [/color][color=#666600]>=[/color][color=#000000] [/color][color=#006666]0.5[/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]PosToday[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]True[/color][*][color=#880000]#print("symbol {}, Volume = {} OrdQty = {}".format(self.symbol, bar_1.volume[0], self.OrdQty))[/color][*][color=#0000DD]print[/color][color=#666600]([/color][color=#008800]'{}\tBUY\t{}\tQty: {}\tBreakout\tPX: {}\tS-Score: {}'[/color][color=#000000]\[/color][*][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#666600],[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600]))[/color][*][color=#000000]order_id [/color][color=#666600]=[/color][color=#000000] order[/color][color=#666600].[/color][color=#000000]twap[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#666600],[/color][color=#000000] [/color][color=#008800]"buy"[/color][color=#666600],[/color][color=#000000] time_frame[/color][color=#666600]=[/color][color=#006666]1[/color][color=#666600],[/color][color=#000000]order_aggression[/color][color=#666600]=[/color][color=#006666]3[/color][color=#666600])[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price [/color][color=#666600]=[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][*][*][color=#880000]#data_row ="Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]data_row [/color][color=#666600]=[/color][color=#008800]"{}\t{}\tbuy\t{}\t\t{}\t\tToOpen\t{}\t{}\t{}\t{}"[/color][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]\[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600])[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] data_row [/color][color=#666600])[/color][*][*][*][color=#880000]# short if the stock is well below its normal values[/color][*][color=#0000DD]elif[/color][color=#000000] [/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600]-[/color][color=#000000]purchase_atr_ratio[/color][color=#666600]*[/color][color=#000000]md[/color][color=#666600].[/color][color=#000000]stat[/color][color=#666600].[/color][color=#000000]atr[/color][color=#666600])>[/color][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] [/color][color=#0000DD]and[/color][color=#000000] allow_shorts [/color][color=#666600]==[/color][color=#000000] [/color][color=#0000DD]True[/color][color=#666600]:[/color][*][color=#880000]#print(self.symbol)[/color][*][color=#880000]#print(self.average_high)[/color][*][color=#880000]#print(md.stat.atr)[/color][*][color=#880000]#print(bar_close[0])[/color][*][color=#0000DD]if[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score [/color][color=#666600]<=[/color][color=#000000] [/color][color=#666600]-[/color][color=#006666]0.5[/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]PosToday[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]True[/color][*][color=#0000DD]print[/color][color=#666600]([/color][color=#008800]'{}\tSSRT\tQty: {}\t{}\tBreakout\tPX: {}\tS-Score: {}'[/color][color=#000000]\[/color][*][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#666600],[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600]))[/color][*][color=#000000]order_id [/color][color=#666600]=[/color][color=#000000] order[/color][color=#666600].[/color][color=#000000]twap[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]OrdQty[/color][color=#666600],[/color][color=#000000] [/color][color=#008800]"sell"[/color][color=#666600],[/color][color=#000000] time_frame[/color][color=#666600]=[/color][color=#006666]1[/color][color=#666600],[/color][color=#000000]order_aggression[/color][color=#666600]=[/color][color=#006666]3[/color][color=#666600])[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price [/color][color=#666600]=[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][*][*][color=#880000]#data_row ="Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]data_row [/color][color=#666600]=[/color][color=#008800]"{}\t{}\tSSRT\t{}\t\t{}\t\tToOpen\t{}\t{}\t{}\t{}"[/color][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]\[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600])[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] data_row [/color][color=#666600])[/color][*][*][*][color=#0000DD]else[/color][color=#666600]:[/color][color=#000000] [/color][color=#880000]########## position isn't zero[/color][*][color=#880000]###########################################################[/color][*][color=#880000]# Are we long? and without an already placed closing order[/color][*][color=#0000DD]if[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares [/color][color=#666600]>[/color][color=#000000] [/color][color=#006666]0[/color][color=#000000] [/color][color=#0000DD]and[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]ClosingOrder[/color][color=#000000] [/color][color=#666600]<[/color][color=#000000] [/color][color=#006666]0[/color][color=#666600]:[/color][*][color=#880000]# there is a position on, therefore we want to check to see if[/color][*][color=#880000]# we should realize a profit or stop a loss[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]IsPurchasable[/color][color=#666600]=[/color][color=#0000DD]False[/color][*][color=#0000DD]try[/color][color=#666600]:[/color][*][color=#0000DD]if[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] [/color][color=#666600]<[/color][color=#000000] [/color][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price [/color][color=#666600]-[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit[/color][color=#666600]):[/color][*][color=#880000]#### stop my loss now.[/color][*][color=#880000]#self.ClosingOrder = order.send(self.symbol, 'sell', account[self.symbol].position.shares, type='MKT')[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]ClosingOrder[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] order[/color][color=#666600].[/color][color=#000000]twap[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] abs[/color][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares[/color][color=#666600]),[/color][color=#000000] [/color][color=#008800]"sell"[/color][color=#666600],[/color][color=#000000] time_frame[/color][color=#666600]=[/color][color=#006666]1[/color][color=#666600],[/color][color=#000000]order_aggression[/color][color=#666600]=[/color][color=#006666]2[/color][color=#666600])[/color][*][color=#0000DD]print[/color][color=#666600]([/color][color=#008800]'{}\tSell\t{}\tStop To Close\tEntryPx: {}\tExitPx: {}\tP&L: {}\tTarget P&L: {}\tEOD\tEntrySscore: {}\tCloseSscore: {}'[/color][color=#000000]\[/color][*][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] [/color][*][color=#666600]([/color][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] [/color][color=#666600]-[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600]))[/color][*][color=#880000]#data_row ="Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]data_row [/color][color=#666600]=[/color][color=#008800]"{}\t{}\tSell\t{}\t{}\t{}\t\tStopLoss\t{}\t{}\t{}\t{}"[/color][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]\[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600])[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] data_row [/color][color=#666600])[/color][*][color=#0000DD]elif[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] [/color][color=#666600]>[/color][color=#000000] [/color][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price [/color][color=#666600]+[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit[/color][color=#666600]):[/color][*][color=#880000]#### take profit now.[/color][*][color=#880000]#self.ClosingOrder = order.send(self.symbol, 'sell', account[self.symbol].position.shares, type='MKT')[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]ClosingOrder[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] order[/color][color=#666600].[/color][color=#000000]twap[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] abs[/color][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares[/color][color=#666600]),[/color][color=#000000] [/color][color=#008800]"sell"[/color][color=#666600],[/color][color=#000000] time_frame[/color][color=#666600]=[/color][color=#006666]1[/color][color=#666600],[/color][color=#000000]order_aggression[/color][color=#666600]=[/color][color=#006666]2[/color][color=#666600])[/color][*][color=#0000DD]print[/color][color=#666600]([/color][color=#008800]'{}\tSell\t{}\tTo Close\tEntryPx: {}\tExitPx: {}\tP&L: {}\tTarget P&L: {}\tEOD\tEntrySscore: {}\tCloseSscore: {}'[/color][color=#000000]\[/color][*][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] [/color][*][color=#666600]([/color][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] [/color][color=#666600]-[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600]),[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600]))[/color][*][color=#880000]#data_row ="Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]data_row [/color][color=#666600]=[/color][color=#008800]"{}\t{}\tSell\t{}\t{}\t{}\t\tTakeProfit\t{}\t{}\t{}\t{}"[/color][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]\[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600])[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] data_row [/color][color=#666600])[/color][*][color=#0000DD]except[/color][color=#666600]:[/color][*][color=#0000DD]pass[/color][*][*][color=#880000]############################[/color][*][color=#880000]# Are we short? and without an already placed[/color][*][color=#0000DD]elif[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares [/color][color=#666600]<[/color][color=#000000] [/color][color=#006666]0[/color][color=#000000] [/color][color=#0000DD]and[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]ClosingOrder[/color][color=#000000] [/color][color=#666600]<[/color][color=#000000] [/color][color=#006666]0[/color][color=#666600]:[/color][color=#000000] [/color][*][color=#880000]# there is a position on, therefore we want to check to see if[/color][*][color=#880000]# we should realize a profit or stop a loss[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]IsPurchasable[/color][color=#666600]=[/color][color=#0000DD]False[/color][*][color=#0000DD]try[/color][color=#666600]:[/color][*][color=#0000DD]if[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] [/color][color=#666600]>[/color][color=#000000] [/color][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price [/color][color=#666600]+[/color][color=#000000] [/color][color=#006666]1.0[/color][color=#666600]):[/color][*][color=#880000]#### stop my loss now.[/color][*][color=#880000]#self.ClosingOrder = order.send(self.symbol, 'buy', account[self.symbol].position.shares, type='MKT')[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]ClosingOrder[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] order[/color][color=#666600].[/color][color=#000000]twap[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] abs[/color][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares[/color][color=#666600]),[/color][color=#000000] [/color][color=#008800]"buy"[/color][color=#666600],[/color][color=#000000] time_frame[/color][color=#666600]=[/color][color=#006666]1[/color][color=#666600],[/color][color=#000000]order_aggression[/color][color=#666600]=[/color][color=#006666]2[/color][color=#666600])[/color][*][color=#0000DD]print[/color][color=#666600]([/color][color=#008800]'{}\tBuy\t{}\tStop To Close\tEntryPx: {}\tExitPx: {}\tP&L: {}\tTarget P&L: {}\tEOD\tEntrySscore: {}\tCloseSscore: {}'[/color][color=#000000]\[/color][*][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] [/color][*][color=#666600]([/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price [/color][color=#666600]-[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600]))[/color][*][*][color=#880000]#data_row ="Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]data_row [/color][color=#666600]=[/color][color=#008800]"{}\t{}\tBuy\t{}\t{}\t{}\t\tStopLoss\t{}\t{}\t{}\t{}"[/color][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]\[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600])[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] data_row [/color][color=#666600])[/color][*][color=#0000DD]elif[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] [/color][color=#666600]<[/color][color=#000000] [/color][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price [/color][color=#666600]-[/color][color=#000000] [/color][color=#006666]1.0[/color][color=#666600]):[/color][*][color=#880000]#### take profit now[/color][*][color=#880000]#self.ClosingOrder = order.send(self.symbol, 'buy', account[self.symbol].position.shares, type='MKT')[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]ClosingOrder[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] order[/color][color=#666600].[/color][color=#000000]twap[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] abs[/color][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares[/color][color=#666600]),[/color][color=#000000] [/color][color=#008800]"buy"[/color][color=#666600],[/color][color=#000000] time_frame[/color][color=#666600]=[/color][color=#006666]1[/color][color=#666600],[/color][color=#000000]order_aggression[/color][color=#666600]=[/color][color=#006666]2[/color][color=#666600])[/color][*][color=#0000DD]print[/color][color=#666600]([/color][color=#008800]'{}\tBuy\t{}\tTo Close\tEntryPx: {}\tExitPx: {}\tP&L: {}\tTarget P&L: {}\tEOD\tEntrySscore: {}\tCloseSscore: {}'[/color][color=#000000]\[/color][*][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] [/color][*][color=#666600]([/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price [/color][color=#666600]-[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600]))[/color][*][*][color=#880000]#data_row ="Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]data_row [/color][color=#666600]=[/color][color=#008800]"{}\t{}\tBuy\t{}\t{}\t{}\t\tTakeProfit\t{}\t{}\t{}\t{}"[/color][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]\[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600])[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] data_row [/color][color=#666600])[/color][*][color=#0000DD]except[/color][color=#666600]:[/color][*][color=#0000DD]pass[/color][*][*][*][color=#0000DD]else[/color][color=#666600]:[/color][*][color=#880000]# close out of our positions at the end of the day [/color][*][color=#0000DD]if[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]IsInClose[/color][color=#000000] [/color][color=#666600]==[/color][color=#000000] [/color][color=#0000DD]False[/color][color=#666600]:[/color][color=#000000] [/color][color=#880000]# Only want to do the closing logic once.[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]IsInClose[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]True[/color][*][color=#000000]bar_1 [/color][color=#666600]=[/color][color=#000000] bar[/color][color=#666600].[/color][color=#000000]minute[/color][color=#666600]()[/color][*][color=#000000]bar_close [/color][color=#666600]=[/color][color=#000000] bar_1[/color][color=#666600].[/color][color=#000000]close[/color][*][color=#0000DD]if[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares [/color][color=#666600]>[/color][color=#000000] [/color][color=#006666]0[/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]ClosingOrder[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] order[/color][color=#666600].[/color][color=#000000]twap[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] abs[/color][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares[/color][color=#666600]),[/color][color=#000000] [/color][color=#008800]"sell"[/color][color=#666600],[/color][color=#000000] order_aggression[/color][color=#666600]=[/color][color=#006666]3[/color][color=#666600])[/color][*][color=#0000DD]if[/color][color=#000000] len[/color][color=#666600]([/color][color=#000000]bar_close[/color][color=#666600])[/color][color=#000000] [/color][color=#666600]>[/color][color=#000000] [/color][color=#006666]0[/color][color=#666600]:[/color][*][color=#0000DD]print[/color][color=#666600]([/color][color=#008800]'{}\tSell\t{}\tTo Close\tEntryPx: {}\tExitPx: {}\tP&L: {}\tTarget P&L: {}\tEOD\tEntrySscore: {}\tCloseSscore: {}'[/color][color=#000000]\[/color][*][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] [/color][*][color=#666600]([/color][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]][/color][color=#000000] [/color][color=#666600]-[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600]))[/color][*][color=#880000]#data_row ="Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]data_row [/color][color=#666600]=[/color][color=#008800]"{}\t{}\tSell\t{}\t{}\t{}\t{}\tToClose\t{}\t{}\t{}\t{}"[/color][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]\[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] \[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600],[/color][color=#000000] \[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600])[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] data_row [/color][color=#666600])[/color][*][*][color=#0000DD]else[/color][color=#666600]:[/color][*][color=#0000DD]print[/color][color=#666600]([/color][color=#008800]'{}\tSell\t{}\tTo Close\tEntryPx: {}\tExitPx: {}\t\tEntrySscore: {}\tCloseSscore: {}'[/color][color=#000000]\[/color][*][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#008800]"unknown"[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600]))[/color][*][color=#880000]#data_row ="Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]data_row [/color][color=#666600]=[/color][color=#008800]"{}\t{}\tSell\t{}\t\t{}\t{}\tToClose\t{}\t{}\t{}\t{}"[/color][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]\[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600],[/color][color=#000000] \[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600])[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] data_row [/color][color=#666600])[/color][*][*][*][color=#880000]# close out of our short positions at the end of the day[/color][*][color=#0000DD]if[/color][color=#000000] account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares [/color][color=#666600]<[/color][color=#000000] [/color][color=#006666]0[/color][color=#000000] [/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#660066]ClosingOrder[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] order[/color][color=#666600].[/color][color=#000000]twap[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000] abs[/color][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]shares[/color][color=#666600]),[/color][color=#000000] [/color][color=#008800]"sell"[/color][color=#666600],[/color][color=#000000] order_aggression[/color][color=#666600]=[/color][color=#006666]3[/color][color=#666600])[/color][*][color=#0000DD]if[/color][color=#000000] len[/color][color=#666600]([/color][color=#000000]bar_close[/color][color=#666600])[/color][color=#000000] [/color][color=#666600]>[/color][color=#000000] [/color][color=#006666]0[/color][color=#666600]:[/color][*][color=#0000DD]print[/color][color=#666600]([/color][color=#008800]'{}\tBuy\t{}\tTo Close\tEntryPx: {}\tExitPx: {}\tP&L: {}\tTarget P&L: {}\tEOD\tEntrySscore: {}\tCloseSscore: {}'[/color][color=#000000]\[/color][*][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000] bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] [/color][*][color=#666600]([/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600]-[/color][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600]))[/color][*][color=#880000]#data_row ="Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]data_row [/color][color=#666600]=[/color][color=#008800]"{}\t{}\tBuy\t{}\t{}\t{}\t{}\tToClose\t{}\t{}\t{}\t{}"[/color][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]\[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#000000]bar_close[/color][color=#666600][[/color][color=#006666]0[/color][color=#666600]],[/color][color=#000000] \[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600],[/color][color=#000000] \[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600])[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] data_row [/color][color=#666600])[/color][*][*][color=#0000DD]else[/color][color=#666600]:[/color][*][color=#0000DD]print[/color][color=#666600]([/color][color=#008800]'{}\tBuy\t{}\tTo Close\tEntryPx: {}\tExitPx: {}\t\tEntrySscore: {}\tCloseSscore: {}'[/color][color=#000000]\[/color][*][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]account[/color][color=#666600][[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600]].[/color][color=#000000]position[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#008800]"unknown"[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600]))[/color][*][color=#880000]#data_row ="Timestamp\tSymbol\tB-S\tEntryPx\tExitPx\tEntryS-Score\tExitS-Score\tAction\tDailyAvgHigh\tDailyAvgLow\tDailyBarHigh\tDailyBarLow"[/color][*][color=#000000]data_row [/color][color=#666600]=[/color][color=#008800]"{}\t{}\tBuy\t{}\t{}\t\t{}\tToClose\t{}\t{}\t{}\t{}"[/color][color=#666600].[/color][color=#000000]format[/color][color=#666600]([/color][color=#000000]\[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]time_to_string[/color][color=#666600]([/color][color=#000000]service[/color][color=#666600].[/color][color=#000000]system_time[/color][color=#666600]),[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]symbol[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]entry_price[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score_at_Entry[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]sma_s_score[/color][color=#666600],[/color][color=#000000] \[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600],[/color][color=#000000]\[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600])[/color][*][color=#000000]service[/color][color=#666600].[/color][color=#000000]write_file[/color][color=#666600]([/color][color=#000000] filename[/color][color=#666600],[/color][color=#000000] data_row [/color][color=#666600])[/color][*][*][*][color=#0000DD]def[/color][color=#000000] on_start[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600],[/color][color=#000000] md[/color][color=#666600],[/color][color=#000000] order[/color][color=#666600],[/color][color=#000000] service[/color][color=#666600],[/color][color=#000000] account[/color][color=#666600]):[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]model_start [/color][color=#666600]=[/color][color=#000000] service[/color][color=#666600].[/color][color=#000000]system_time [/color][color=#666600]+[/color][color=#000000] service[/color][color=#666600].[/color][color=#000000]time_interval[/color][color=#666600]([/color][color=#000000]minutes[/color][color=#666600]=[/color][color=#000000]start_delay[/color][color=#666600],[/color][color=#000000] seconds[/color][color=#666600]=[/color][color=#006666]1[/color][color=#666600])[/color][*][color=#880000]#gather some statistics[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_daily[/color][color=#666600]=[/color][color=#000000]md[/color][color=#666600].[/color][color=#000000]bar[/color][color=#666600].[/color][color=#000000]daily[/color][color=#666600]([/color][color=#000000]start[/color][color=#666600]=-[/color][color=#000000]index[/color][color=#666600])[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_high[/color][color=#666600]=[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_daily[/color][color=#666600].[/color][color=#000000]high[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high[/color][color=#666600]=[/color][color=#000000]np[/color][color=#666600].[/color][color=#000000]mean[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_daily[/color][color=#666600].[/color][color=#000000]high[/color][color=#666600])[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_low[/color][color=#666600]=[/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_daily[/color][color=#666600].[/color][color=#000000]low[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][color=#666600]=[/color][color=#000000]np[/color][color=#666600].[/color][color=#000000]mean[/color][color=#666600]([/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]md_daily[/color][color=#666600].[/color][color=#000000]low[/color][color=#666600])[/color][*][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit [/color][color=#666600]=[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_high [/color][color=#666600]-[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]average_low[/color][*][*][color=#0000DD]if[/color][color=#000000] [/color][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit [/color][color=#666600]>[/color][color=#000000] MAX_PNL_PER_SHARE[/color][color=#666600]:[/color][*][color=#0000DD]self[/color][color=#666600].[/color][color=#000000]target_profit [/color][color=#666600]=[/color][color=#000000] MAX_PNL_PER_SHARE[/color][*][*][*][*][*][color=#0000DD]pass[/color][/list]
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
Any useful free resources for 2018?
Answer:
If you are interested in trading FX, you can use the REST API at FXCM for free. With it, you have access to real-time streaming market data, retrieve historical price, live trading, etc. You can demo the API to see if it right for you, here is the GitHub page: https://github.com/fxcm/RestAPI
REST API is a web-based API using a Websocket connection. Developers and investors can create custom trading applications, integrate into our platform, back test strategies and build robot trading.
Attached is an RSI strategy.
Interesting HFT blog:
I just stumbled across rigtorp.se and found it pretty interesting
The intro the guy has for his site is:
I'm a high-frequency trader. I design and build sub-microsecond trading strategies. I rip the face off retail investors and engineer flash crashes.
Here is his GitHub. Some interesting repositories: rigtorp/MPMCQueue "A bounded multi-producer multi-consumer lock-free queue written in C++11", rigtorp/spartan "A collection of High-Frequency trading components", rigtorp/SPSCQueue "A bounded single-producer single-consumer wait-free and lock-free queue written in C++11", and lastly rigtorp/Seqlock, "An implementation of Seqlock in C++11".
Interesting blog post: http://www.rigtorp.se/2012/11/22/feed-handler.html
Answer:
If you are interested in trading FX, you can use the REST API at FXCM for free. With it, you have access to real-time streaming market data, retrieve historical price, live trading, etc. You can demo the API to see if it right for you, here is the GitHub page: https://github.com/fxcm/RestAPI
REST API is a web-based API using a Websocket connection. Developers and investors can create custom trading applications, integrate into our platform, back test strategies and build robot trading.
Attached is an RSI strategy.
Interesting HFT blog:
I just stumbled across rigtorp.se and found it pretty interesting
The intro the guy has for his site is:
I'm a high-frequency trader. I design and build sub-microsecond trading strategies. I rip the face off retail investors and engineer flash crashes.
Here is his GitHub. Some interesting repositories: rigtorp/MPMCQueue "A bounded multi-producer multi-consumer lock-free queue written in C++11", rigtorp/spartan "A collection of High-Frequency trading components", rigtorp/SPSCQueue "A bounded single-producer single-consumer wait-free and lock-free queue written in C++11", and lastly rigtorp/Seqlock, "An implementation of Seqlock in C++11".
Interesting blog post: http://www.rigtorp.se/2012/11/22/feed-handler.html
Attached File(s)
RsiStrategy.zip
7.3 MB
|
815 downloads
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
If I have a losing BUY strategy, why not just make it SELL instead?
Answer:
- The opposite of random is random.
- It may just be in a temporary losing streak.
- You'll need to invest in the infrastructure as well as capital costs to make a profitable market making strategy. You need to read order flows, watch correlated assets, and execute or cancel your orders in under millisecond timeframes if you're planning on market making.
Answer:
- The opposite of random is random.
- It may just be in a temporary losing streak.
- You'll need to invest in the infrastructure as well as capital costs to make a profitable market making strategy. You need to read order flows, watch correlated assets, and execute or cancel your orders in under millisecond timeframes if you're planning on market making.
Join our skype group.
- Joined Dec 2013 | Status: Member | 727 Posts
Secrets in Forex: threads that talk about secrets in forex
- http://blog.tomorrowintrading.com/on...ading-secrets/
- https://www.scribd.com/document/9368...crets-in-Forex
- https://www.mql5.com/en/forum/200250
- https://www.dailymotion.com/video/x4x2g0n
- http://www.bitcoin-exchange-berlin.c...rency-trading/
- http://blog.tomorrowintrading.com/on...ading-secrets/
- https://www.scribd.com/document/9368...crets-in-Forex
- https://www.mql5.com/en/forum/200250
- https://www.dailymotion.com/video/x4x2g0n
- http://www.bitcoin-exchange-berlin.c...rency-trading/
Attached File(s)
TCFX_Special_Report - hidden secrets in forex.pdf
208 KB
|
411 downloads
Join our skype group.
1
- | Joined Oct 2011 | Status: Broke | 143 Posts
Very interesting thread. Thumbs up!
Thanks for your efforts and work, michaellobry.
Thanks for your efforts and work, michaellobry.
F_ck your analysis, I know exactly where the market will go. To the right.
1
- Joined Dec 2013 | Status: Member | 615 Posts
Disliked{quote} Thank you! If you'd like, could you answer the first question in the #1st post https://www.forexfactory.com/showthread.php?t=784994. I'm very interested in your opinion. I appreciate it a lot. Have a nice day.Ignored
Regards
1