Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hi, I'm trying to create a script to initiate a long position when the fast MA crosses two other slower MAs. The problem I have when using the "crossabove" or "crossbelow" is that trades are initiated when the crossover occurs over 1 bar. Likewise for the exit. By default however, it will exit on close. It will not initiate or exit a position if the crossover occurs over a few bars.
The attached chart show a long position at approx 9:37 when the green lines crosses above the red and orange lines. But at approximately 11.57, when the green line crosses below the other 2 lines, it should exit. Instead it exits on close. Would anybody be able to assist?
Can you help answer these questions from other members on NexusFi?
From what I can see, the problem is that your logic is looking for both crossovers to happen on the same bar. What you need to do is use one crossover as a trigger (using the actual crossover keyword) and another as a filter (by just checking that the value is higher or lower).
if you try to trade crossovers you will blow your account if it was a good method of trading everyone would do it trust me just look in another direction to trade it wont help you ...sharky
Guys, your comments are noted and appreciated. Thanks. The initial question i posed allows me to 1) learn how to write the code for similar stuff which I have very little idea how to at the moment and 2) see how the strategy works in asia.
Does that mean one should refrain from automated trading with crossovers? May be it
varies from instrument to instrument as I know someone who has been trading
different types of crossovers with very good end results.
kaywai: crossover has problems like that. I ended up coding it manually like:
if MAfast[1] < MAslow[1] and MAfast[0] > MAslow[0] then that's an upcross.
In terms of crossovers in general: if you are trading generally trending markets they work well. In high-volume heavily institutional markets this often doesn't work out since the chops eat up the winners. But there are many markets out there which do trend nicely.
Thing is: those that do trend nicely you can probably get the same results with simple turtle-trading style, i.e. buy higher highs and sell lower lows. Throw up a Donchian or two and see if this is true or not.
Another classic approach - again with markets which tend to trend - and which uses MA's:
Let's say you have a slow MA for the LT trend, like a Weekly 20 EMA = 100 Daily (5*), or if you are intraday it's the same principle: something quite slow for LT trend (I find 63-ish is often good = 3* 21).
Then any time that weekly/LT is long, say, and the ST Stochastic (say 21) crosses up from underneath the 20 level, you got yourself a good-looking pullback. Very simple, but quite effective. In this case the trick is not so much in the system as
a) picking strong trending markets (no mean trick, although I suspect many Asian instruments do trend strongly since you guys are in boom times like the US in the late 1800's - late 1920's and your boom is MUCH bigger than ours since you are starting with over 1.4 billion people and the US had less than 100 million).
b) money management in terms of loss and trailing stops, multiple scaleouts etc.
Just for fun, I picked a trending market: Crude.
Since it seems you are trading in Asia I threw up:
1) LT Ichimoku Kinkyo Ho clouds, which use medians from 27 to 81. If price is above clouds = bull mkt. Simple.
2) ST Stochastics from NT basic indicators.
3) For fun: an oscillator derived from the Ichimoku fast and slow lines also in above chart (red and green) which give added medium term info; the indy is designed to help with trend trading but is slower than the stochs and the buy areas tend to be in crosses above zero versus from down below, i.e. above zero is bullish and below zero is bearish.
4) Ichimoku Kinkyo Ho Lines (Donchian Medians 9 and 27). Developed in the 1960's I believe (before computers). Still solid. The clouds are VERY Japanese and VERY helpful (drawn 81 bars before current price action, i.e. they predict probable future price. If price is above this prediction, it's bullish.)
As you can see, in a strong trending market, buying pullbacks works pretty well. Probably your crossing MA's are doing the same thing on some level.
They have to. Why: if market is not strongly trending, MA cross strategies get chewed to bits.
If you are making money in trending markets you must be getting on board (somehow) and staying along for the ride long enough to more than make out for the losing entries. So the cheapest way to get in is on pullbacks. The most momentum-rich way is on breakouts (that work). MA crosses tend to do one or the other depending on how they are configured, but no matter the indicator if you are buying into a strongly trending bull market, it doesn't really matter the entry technique: the strongly trending market will take care of it for you!
The real issue is: what happens when it's not strongly trending? Are you ceasing to trade that instrument? If so, no worries. But if you are trading it all the time no matter what, it's going to be a very sophisticated MA technique that will come away with net gains over time.
my 2 cents about MAs crossovers.
Agree with Sharky trading based solely on crossovers seems not quite good way, but...
big difference how you use that crossovers.
For example, if you wait for crossover and then enter as per that crossover, that one way
if you wait for crossover and then enter on the pull back from "longer" MA in your crossover that's another way.
Not brilliant idea, because apart from that better to have some meaningful levels supports that pullback, but it helps me to see some picture.
+ pullbacks from "longer" MA works only when price reach that first time, at least second time on third it usually not pullsback from that "longer" MA.
I've noted also that simply crossover of 10 SMA and 10 EMA shows quite interesting levels intraday, but not deepen yet in to that enough.
+ also quite important seems what MAs used for crossovers.
P.s. if any I will be glad to discuss further that issue