Greets,
Here's a quick implementation of a grid trading idea showcased here
I'm not sure if I've made a mistake, or if the concept simply doesn't work, but it always results in a loss in backtesting. Maybe someone can have a look, play with it, and possibly give ideas.
Since the strategy apparently does better in ranging conditions, I've added the ADX check. You can also decide to use a fixed point grid gap size, or use multiples of ATR.
Have a go and let me know.
There are many ways to create a grid and/or make the distance between a grid to be dynamic, and do NOT believe the dooms dayers that put down grid trading. a grid can be very helpful in trading. The only reason that grid trading has a bad name is the same reason that most traders who use eas lose: because they dont monitor their account and rely on the ea to trade for them. EAs are not meant to do the trading for you; but to, only: assist the trader.
However, grid trading is the most risky of all trading systems there are. But if you close the trades to avoid bad markets, as you should with any ea, and do not try to take too much profit; dont be greedy, and monitor every trade, every day, then you will learn when to "hit and run' and when it is a bad day to trade.
I suggest that you search codebase. There are hundreds of different grid eas on there, and even more free ones on the marketplace, all with lots of trading options and even more options to close trades. Do not try to reinvent the wheel. Use one from codebase and make changes to the code to suite your trading style.
EDIT-
I've just noticed now that this is a few months old thread,
Who got 'bumped' because of another user's comment.
I'm guessing it is probably irrelevant by now,
But I leave my comment below anyway, in case it is still needed.
Cheers.
Hey mate,
First I just want to say that I personally don't believe that grid trading is profitable (maybe only on a very short run, and in very specific markets conditions),
I am not an native English speaker, so I'll try to keep it short and clear,
If you need more explanation just tell me.
I haven't gone thoroughly thru your code,
But at a quick glance few things popped into my eyes-
1-
The 'strategy' shown in the video does not consist of setting a S/L, but letting 'losing' trades just 'float' until it evens with grid.
Your T/P and S/L are (supposedly) at the same levels,
So your code always generate zero-sum transactions,
But because of fees, your code always lose money when hits T/P and S/L.
(If assuming 0 spread, for simplicity)
2-
I might be mistaken, since I haven't tested it,
But from a quick glance I think that your code doubles the amount of positions each time.
You call openPositions() if you hit T/P level and also if you hit S/L level.
So, for example, you open the first buy and sell orders (lets assume 0 spread and instant execution, for simplicity),
So you reach first level (lets say that price went up),
So your buy hit T/P and your code calls openPositions(),
But also your sell hit S/L and your code calls openPositions() again,
So now you have 2 buy + 2 sell,
And, again, each of the above positions (2 buy + 2 sell = 4 total positions) will open 1 buy and one sell (4 total positions opening 1 buy and 1 sell each),
So next time you will have 4 buy + 4 sell,
etc'
etc'
etc'
Cheers.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Greets,
Here's a quick implementation of a grid trading idea showcased here
I'm not sure if I've made a mistake, or if the concept simply doesn't work, but it always results in a loss in backtesting. Maybe someone can have a look, play with it, and possibly give ideas.
Since the strategy apparently does better in ranging conditions, I've added the ADX check. You can also decide to use a fixed point grid gap size, or use multiples of ATR.
Have a go and let me know.