A few examples of how to use Stoqey
-- primitives (safety net) -----------
IF stopLoss ticks=10 transmit=false
IF takeProfit ticks=20 transmit=false
IF breakEven ticks=5 -- auto‑move stop to entry
-- L2 conditions ---------------------
TICK volume WITH minutes=1 > 8000 AND ema WITH minutes=1 > ema WITH minutes=3
THEN
order SET action=buy, quantity=2, transmit=true
-- exit on overbought ---------------
POS rsi WITH minutes=1 > 70 THEN closeOrder SET transmit=true
Enters only on a 1‑min volume burst + EMA flip; exits at RSI > 70 or TP/SL/breakeven, whichever fires first.
--- primitives ------------------------
IF trailingStopLoss ticks=25 transmit=false
IF scaleIn increments=5 size=1 transmit=false -- pyramid every +5 ticks
--- entry -----------------------------
TICK macd WITH minutes=5 > 0
THEN
order SET action=buy, quantity=1, transmit=true
--- trend reversal exit ---------------
POS macd WITH minutes=5 < 0
THEN
closeOrder SET transmit=true
Starts with one lot, adds size every 5‑tick advance, follows with a trailing stop; bails when the 5‑min MACD flips negative.
--- primitives ------------------------
IF stopLoss ticks=20 transmit=false
IF hedge side=short size=1 transmit=false -- fires right after long entry
IF timeExit seconds=900 transmit=false -- auto‑close after 15 min
--- opening‑range breakout ------------
TICK price > donchian WITH minutes=30.upper
THEN
order SET action=buy, quantity=1, transmit=true
Buys the 30‑min upper Donchian break at the open, instantly opens a protective short hedge, and forces a flat book 15 minutes later.
--- global safety layer ---------------
IF riskCap percent=1.0 -- never risk > 1 %/trade
IF cooldown seconds=60 -- 1‑min chill between trades
IF stopLoss ticks=15 transmit=false
IF trailingProfit ticks=8 transmit=false
--- trade only 09:30 → 11:00 --------
IF session start="09:30" end="11:00"
--- entry logic ----------------------
TICK rsi WITH minutes=1 < 30
AND price < ema WITH minutes=5
THEN
order SET action=buy, quantity=2, transmit=true
--- exit on RSI snap‑back -----------
POS rsi WITH minutes=1 > 50
THEN
closeOrder SET transmit=true
--- primitives -----------------------
IF takeProfit ticks=25 transmit=false
IF scaleOut steps=10 size=1 -- peel 1 lot every +10 ticks
IF cancelOrder afterSeconds=120 -- kill stale entry orders in 2 min
--- enter only at 12:00 sharp -------
IF timeExit seconds=1800 transmit=false -- flat by 12:30 no matter what
TICK time = "12:00:00" -- (engine supplies time field)
AND price > bbands WITH minutes=30.upper
THEN
order SET action=sell, quantity=3, transmit=true
--- exit on mean re‑version ---------
POS price
<=
bbands WITH minutes=30.middle
THEN
closeOrder SET transmit=true
Sells 3 lots at 12:00 sharp, cancels stale orders, and exits on mean reversion.
safety net
IF stopLoss ticks=12 transmit=false
IF takeProfit ticks=24 transmit=false
long when fast SMA crosses above slow
TICK sma WITH minutes=1 > sma WITH minutes=5
THEN
order SET action=buy, quantity=1, transmit=true
IF stopLoss ticks=20 transmit=false
enter on ATR volatility spike
TICK atr WITH minutes=2 > 15
THEN
order SET action=buy, quantity=2, transmit=true
IF timeExit seconds=1800 transmit=false # always flat 30 min later
TICK volume WITH minutes=1 > 5000
THEN
order SET action=sell, quantity=1, transmit=true
hard cap = 0.5 % account risk
IF riskCap percent=0.5
TICK rsi WITH minutes=1 > 80
THEN
order SET action=sell, quantity=1, transmit=true
emergency kill‑switch primitive
IF flatten