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
strategy "Grid Accumulator"market: EURUSDbars: 15mdirection: longpyramiding: 5max_open: 5input levels = 5input spacing = 15 pipsinput grid_size = 0.1 lotsstate anchor: price = nawhen trades.open(tag: "grid").len == 0 and orders.pending(tag: "grid").len == 0 and close > ema(close, 200):anchor = closefor step in 1..levels:buy limit: close - spacing * step, size: grid_size, stop: close - spacing * (levels + 2), target: close + spacing, tag: "grid"when close < anchor - spacing * (levels + 2):close_all tag: "grid"cancel orders.pending(tag: "grid")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".