How can I code cross-over of moving averages to trigger the order?
ml992026
Posts: 3
I have researched through some of the forums and I don't see the answers for coding trigger for crossing of averages
Comments
What periods of moving average crosses are you looking at.
As a note, a moving average cross is only really useful as a training exercise. They may look good when you look at them on a chart but in real life they are lagging indicators meaning you are always late in and late out, if you try to move closer to the cross event your indicator actually crosses and uncrosses too frequently.
To answer your question, I currently trying to test 5 days and 8 days, 50 days and 200days interval.
I'm trying to script a back test system where I uses moving average crosses on different days.
My goal is to test the indicator that has best win rates.
I may develop onto RSI and other indicator cross over as well.
Watch the beginner set of videos on the home tab or on our YouTube page.
Then also watch the TALIB video if you plan to do RSI.
But for testing, qualify one symbol, a nice big one that will always give you bars.. say SPY
Then pull the bars for the longest period you are intersted in, pull all the bars into a variable called mybars.
Then pull out the data and the length of data using Python list manipulation.
There are two ways to calculate a moving average, pass it to TALIB or do it yourself.
For moving average doing it yourself is probably easiest, but for more compicated Trading expressions TALIB will probably work better for you.
So this would look something like this ...
This is not trading, just calculating MA and RSI. Getting into positions, holding for x days and exiting all requires extra code. Watch the videos.
Also do not expect MA and RSI to give you a working profitable model. If it was that easy everyone would be doing it.
Thank you very much for the thorough explanation, I have seen all the videos and I got the calculation part.
I will look through the videos again.
The reason I am working on those model so they can give somewhat direction to my trading, as of right now, I am only trading based on patterns.
Good, only use these kind of things to back up your decisions.
If so do what everyone else is doing the chance is you will always be the last one to the party.
You are a unique human being with a unique view of the world. That is your advantage.
Develop your own unique trading style, even if it is something as seemingly crazy as knowing the behavior one symbol better than anyone else.