Grid Accumulator

Grid Accumulator is a strategy that trades EURUSD on 15-minute bars. It holds at most 5 open trades, takes long trades only and adds up to 5 entries i

statepending orders

grid-accumulator.abx
1strategy "Grid Accumulator"
2market: EURUSD
3bars: 15m
4direction: long
5pyramiding: 5
6max_open: 5
7
8input levels = 5
9input spacing = 15 pips
10input grid_size = 0.1 lots
11
12state anchor: price = na
13
14when trades.open(tag: "grid").len == 0 and orders.pending(tag: "grid").len == 0 and close > ema(close, 200):
15anchor = close
16for step in 1..levels:
17buy limit: close - spacing * step, size: grid_size, stop: close - spacing * (levels + 2), target: close + spacing, tag: "grid"
18
19when close < anchor - spacing * (levels + 2):
20close_all tag: "grid"
21cancel orders.pending(tag: "grid")
What this script says

Grid Accumulator is a strategy that trades EURUSD on 15-minute bars. It holds at most 5 open trades, takes long trades only and adds up to 5 entries in the same direction.

You can change 3 inputs: levels (default 5), spacing (default 15 pips) and grid_size (default 0.1 lots).

It remembers anchor from one bar to the next.

When the number of open trades tagged "grid" is 0 and the number of pending orders tagged "grid" is 0 and the close is above the 200-bar EMA of the close, it sets anchor to the close; it also goes through each step in 1 to levels and buys with a limit order at the close minus spacing × step, with a size of grid_size, with a stop at the close minus spacing × (levels plus 2), with a target at the close plus spacing and tagged "grid".

When the close is below anchor minus spacing × (levels plus 2), it closes all trades tagged "grid" and cancels pending orders tagged "grid".

Try this in the Terminal. AlgoBars is free: $0 a month, no card needed.

Create my free account