Grid Schaff Trend Cycle EA
- エキスパート
- バージョン: 3.17
- アクティベーション: 5
Run it first, decide later: open Grid Schaff Trend Cycle EA in the MetaTrader 5 Strategy Tester with visual mode on, and you can watch each cycle turn it accepts and each one it waves through.
A TREND HAS A RHYTHM. THIS EA WAITS FOR THE BEAT.
MACD tells you the trend is changing, but slowly. A stochastic tells you where price sits in its range, but it jumps at every noise. The Schaff Trend Cycle puts the two together: it runs MACD through two smoothed stochastic passes, which gives a line from 0 to 100 that sits flat while a move runs and then swings quickly from one side to the other when the move turns. Grid Schaff Trend Cycle EA starts a cycle only when that swing has begun on a finished bar, is real rather than a hair, is not already spent, and agrees with the larger trend. After that a full management engine takes over the book: it banks small group closures and trims heavy old orders slice by slice.
In short
• Entry: the STC line crosses its own short signal line on a closed bar. The forming candle is ignored by default, so an accepted signal does not repaint.
• The STC is calculated inside the EA from the chart's closes. No indicator file, no DLL, no web request.
• Five guards decide whether a crossing becomes an order: Climb, Gap, Stretch, Settle and Range, plus an EMA 200 side filter.
• New in this product: the Zone Guard, which can demand that STC touched its far zone (25 or lower for a BUY, 75 or higher for a SELL) shortly before the crossing. It ships switched off; the numbers behind that choice are below.
• Past crossings appear on the live chart: a small arrow when accepted, a grey dot when a guard said no.
• Closures pair the oldest and newest orders; an old order too heavy to close in one go can be retired in parts.
• There is no stop loss and no forced close-all. Limits stop new levels, and the open book stays under management.
----------
Getting started
1. Put it on a EURUSD H1 chart and keep the defaults: 0.01 first lot, additive ladder.
2. Choose Scan only in RunMode for the first session. Every plan appears on the panel and nothing is sent.
3. Once the plans look sensible to you, press ARMED on the panel.
4. Before trading real money, repeat the tests below on your own broker's data; spread, swap and commission all move the result.
5. Running more than one copy? Give each chart its own magic numbers.
----------
Tester figures
Strategy Tester, default inputs, 1 minute OHLC, leverage 1:100, 2025.01.01 to 2026.09.30, one broker's demo data. With the same settings you can reproduce them.
• EURUSD H1, $10,000: net +1,200.18, maximal equity drawdown 796.76 (7.94%), 414 trades. No stop-out, no margin refusal.
• EURUSD H1, $1,000,000: net +1,200.18, maximal equity drawdown 796.76 (0.08%), 414 trades. No stop-out, no margin refusal.
• XAUUSD D1, $10,000: net +2.34, maximal equity drawdown 3.93 (0.04%), 1 trade. No stop-out, no margin refusal.
• XAUUSD D1, $1,000,000: net +2.34, maximal equity drawdown 3.93 (0.00%), 1 trade. No stop-out, no margin refusal.
Treat these as a diary of one past stretch, not a promise. On gold the defaults took a single trade in 21 months, which proves nothing either way; this EA is clearly more at home on the H1 pair. The drawdown in money is the same at both deposits because lots do not grow with the balance, so 796.76 is close to 8% of a $10,000 account and a far larger share of a smaller one; deposits under $10,000 were not tested. The guard defaults were chosen on this same period, which flatters the figures. Netting accounts were not verified.
----------
The Zone Guard and why it ships off
The thought behind it: a cycle turn means most when it starts from the far end of the scale, so a BUY crossing should come after STC has been down in the low zone, and a SELL after it has been up high. We measured it twice on EURUSD H1, $10,000, everything else at default. With 10 bars and depth 25 (STC 25 or lower / 75 or higher): exactly the same as off, +1,200.18, 414 trades, because STC visits its extremes so often that the rule never bit. With 3 bars and depth 45 (STC 5 or lower / 95 or higher): net +851.50, drawdown 624.45 (5.98%), 347 trades. Off: net +1,200.18, drawdown 796.76 (7.94%), 414 trades. The strict version lowered drawdown by about a fifth but took about 29% of the profit, so profit per unit of drawdown got worse. That is why it is off by default. If you prefer a calmer curve at the cost of profit, set InpSTCZoneBars to 3 and InpSTCZoneDepth to 45 and compare on your own data. Two runs on one period are not a verdict.
----------
Why the Schaff Trend Cycle
The line spends long stretches pinned near 0 or 100 and then crosses the middle in a few bars. That shape is useful for a grid that should start once and then let the engine work: the EA reads the start of the swing, not every wiggle inside it. It also has a cost. Because it is built on MACD, the turn still comes after price has moved, and in a slow sideways market the line can flip more often than you would like. The Range Guard and the trend filter are there for exactly that.
----------
One cycle, step by step
1. Read. Each new bar rebuilds MACD, both stochastic passes and the signal line from finished bars.
2. Cross. STC moves above its signal line for BUY, below it for SELL.
3. Climb Guard. STC must have gained enough points in that direction over the last few bars.
4. Gap Guard. It must clear its line by more than a hair.
5. Stretch Guard. A BUY with STC already above 80, or a SELL below 20, comes too late and is refused.
6. Settle Guard, optional. STC must have stayed on the other side of its line for a few bars first.
7. Zone Guard, optional. STC must have touched its far zone shortly before.
8. Range Guard. The recent window must be wide enough in ATR, so tight boxes are skipped.
9. Trend filter. By default the close must be on the matching side of the EMA 200. It can also fade that side, or be switched off.
10. Timing. Accepted signals are kept apart by a gap of bars, and a signal may wait a few bars if the level cannot be placed at once.
11. Ladder. Levels follow ATR or fixed points, with a floor, a ceiling and an optional freeze. BUY and SELL grids can run together or alone.
12. Banking. Groups of oldest and newest orders close when their joint result, after swap and commission, clears the target. If the oldest order is too heavy, a slice of it is closed instead.
13. Safety checks. A closure that would reopen a level at once is blocked, each leg is confirmed in deal history, failed legs are retried, and a plan is dropped if the book changed before sending.
14. Hedge cycle, optional. Off by default and not exercised in our tests. When on, it holds a balanced pair on a chosen symbol and retires it in equal slices, paid by a small surcharge on closures the grid already makes.
----------
The panel
The panel lives on the left so the right side and the price scale stay clear. It lists symbol, magic number, a status pill, grid mode, lot step, spacing, banked result, the book, each side's closing plan and the order table. The STC PULSE row shows the fast, slow and cycle lengths, the current STC and its signal line on the 0 to 100 scale, and the bars since the last crossing. The ZONE GUARD row shows the favoured side, how many bars ago the far zone was touched, then Gap, Stretch and Range, each marked OPEN, HOLD or off, and finally the EMA side. Buttons switch Armed / Scan only, Pause / Resume, chart marks and slicing. The Hedge Vault card is designed to dock under the main panel; with the hedge off it stayed hidden in our screenshots, so the live dock was not checked. Nothing is drawn in a non-visual backtest.
----------
Limits you control
No setting closes the book for you; limits only stop new levels.
Each order passes a free margin check with a safety buffer before it is sent.
Caps on levels per grid, orders per side and lot per order keep the ladder finite. MinMarginLevelPercent and MaxAccountRiskPercent start at off; set them for your own account.
An optional margin-level timeframe safety moves the signal and spacing to a higher timeframe as margin falls. It is off by default and was not exercised in our tests.
Copies are kept apart by symbol and magic number.
Scan only shows every decision without sending a single order.
----------
Is it for you?
Yes, if you like to wait for a move to turn rather than chase it, are happy with many small closures, and will size lots to your balance. No, if you need a stop loss on every order, expect a fixed monthly return, or want large lots running unattended on a small deposit.
----------
Common questions
Does it repaint? Accepted signals, chart marks and both panel rows use finished bars only.
Is it the same STC as on my charting site? It follows the usual recipe, MACD 23/50, cycle 10, factor 0.5, but each platform seeds the averages slightly differently, so early values can differ by a few points.
Which markets were tested? EURUSD H1 and XAUUSD D1. Everything else is for you to test.
What should I change first? InpSTCStretchMax, then InpSTCClimbMin. One change at a time, and look at drawdown next to net result.
Why only one gold trade? On a daily chart the guards, the trend filter and the 30 bar gap leave very few chances. Looser guards give more trades and more risk.
Can I make it faster? Lower InpSTCCycle or the MACD lengths. It will cross more often, so look at the guards again afterwards.
Netting accounts? A separate margin cap exists for them, but netting behaviour is unverified.
----------
All inputs
Grid levels
TradeMode - two grids, BUY and SELL, by default, or one direction only.
GridSpacePoints - level distance in fixed spacing mode (25).
GridSpaceMultiplier - above 1.0 widens deeper levels (1.0 = even).
MaxGridLevels - most levels in one grid (1000).
UpDirectionIsBuy - which side an up move arms.
EAMagicNumber - number on grid orders (9761830).
GridOrderComment - text on grid orders (GSTC).
OneOrderPerBar - at most one new level per bar.
Lots
InitialLotSize - volume of the first level (0.01).
LotSizingMode - additive by default, multiply as the alternative.
LotMultiplier - factor per level in multiply mode (1.25).
LotAddStep - step per level in additive mode (0.01; 0 uses the starting lot).
MaxOrderVolume - largest single order (1.0).
UseAutoLot - links the starting lot to balance (off).
AutoLotBaseBalance - balance that matches the starting lot (1000).
AutoLotAllowDecrease - lets auto lot go below the starting lot (off).
ATR spacing
GridSpacingMode - ATR by default, fixed points as the alternative.
ATRTimeframe - ATR timeframe (current chart).
ATRPeriod - ATR length (14).
ATRSpacingFactor - spacing as a multiple of ATR (1.0).
ATRBarShift - ATR bar; 1 is the last finished bar.
ATRMinSpacingPts - lowest spacing in points (50; 0 none).
ATRMaxSpacingPts - highest spacing in points (5000; 0 none).
ATRFreezeOnStart - keeps one spacing for the whole cycle (off).
Profit target
DesiredProfitPerClosure - base target in account currency (2.0).
ProfitMultiplier - final scale, 1.00 to 2.00.
ProfitTargetMode - scaled by default: bigger, deeper books aim higher.
ProfitVolumePower - how closing volume lifts the target (1.0; 0 off).
ProfitDepthBonus - extra target per additional open level (0.10).
ProfitMaxMultiple - scaled target ceiling in multiples of the base (50).
ProfitMaxReachFraction - keeps the target inside this share of one grid step (0.50).
Fragment scanner
UseMultiLegScan - checks multi-order groups before the plain pair (on).
MaxOldestLegs - most old orders in one closure (3).
MaxNewestLegs - most new orders in one closure (6).
ScanPriority - ranking of qualifying groups; largest group first by default.
NeverBankLessThanPair - a group must also beat the pair target (on).
RequireCloseVolumeExceedsTarget - newest volume must be above oldest volume (on).
MinCloseVolumeRatio - required ratio of those volumes (1.5).
Target slicing
EnableTargetSlicing - allows part-closing the oldest order (on).
FragProfitWeightPower - profit weight per closing lot (1.5).
FragMinSlicePercent - smallest slice, percent of the target order (20).
FragAllowMultiCloser - several new orders may fund one slice (on).
FragPreferFullClosure - a full closure wins when both are possible (on).
Reopen guard
ReopenGuard - blocks closures that would reopen a level at once (step based).
ReopenGuardCushion - safe distance as a share of one step (0.90).
Account protection
MinMarginLevelPercent - no new levels below this margin level (0 off).
MaxAccountRiskPercent - no new levels beyond this floating loss, percent of balance (0 off).
NetMaxMarginPercent - netting only: cap on net position margin, percent of equity (5.0).
MaxTotalOrders - absolute order cap per side (1000).
Execution and checks
RunMode - Armed or Scan only.
CloseSequence - order in which legs are sent; oldest first by default.
MaxSlippagePoints - allowed slippage (30).
MaxSpreadPoints - no trading above this spread (7500).
MinSecondsBetweenClosures - pause between closures per side (5).
CloseAttemptsPerLeg - attempts before the retry queue (3).
VerifyTimeoutSeconds - how long a stuck leg is followed (90).
DeferWhenMarketClosed - waits for the session instead of halting (on).
MarketClosedRetrySeconds - retry spacing while orders are refused (30).
AutoResumeAfterSeconds - a halt clears itself after this many seconds (300; 0 waits for you).
NoPartialRetryMinutes - partial closes tried again this many minutes after a broker refusal (15; 0 never).
AbortIfBookChanged - drops a plan if a leg changed (on).
UseFullCommission - counts commission on both sides (on).
CommissionPerLot - fallback figure (0 reads history).
CloseOrderComment - text on closing deals.
Hedge cycle
EnableHedgeCycle - main switch (off).
HedgeSymbols - comma list; repeat a symbol for more turns (XAGUSD).
HedgeSymbolRotation - how the next symbol is picked (per cycle).
HedgeMaxSymbolsInTester - rotation cap in the tester only (2; 0 none).
HedgeCycleLots - lots on each side of the pair (0.01).
HedgeSliceLots - lots retired per side each slice (0.01).
HedgeFragmentBonus - bonus over the slice cost (100).
HedgeBonusIsPercent - bonus is a percent; false means money (on).
HedgeMaxSurcharge - money cap per closure (0 none).
HedgeMaxSurchargePercent - largest rise of any closure target, percent (50).
HedgeMagicNumber - number on hedge legs, must differ from the grid (9761831).
HedgeReopenOnFinish - opens a new cycle when one ends (on).
HedgeStartRequiresTrade - first cycle waits for a grid order (on).
HedgeIntegritySeconds - leg balance check interval (5).
HedgeAutoRepair - repairs a lone leg automatically (on).
HedgeNakedAction - what to do with a lone leg; re-hedge by default.
HedgeMaxSpreadPoints - hedge spread limit (0 off).
HedgeSlippagePoints - hedge slippage allowance (30).
HedgeAttemptsPerLeg - attempts per hedge leg (3).
HedgeVerifyTimeout - follow time for a stuck hedge leg (90).
HedgeCommissionPerLot - fallback hedge commission (0 reads history).
HedgeOrderComment - text on hedge deals.
Weekly cash day
WeeklyCashDay - pauses new cycles and slices around withdrawals (off).
CashDayOfWeek - 0 Sunday, 1 Monday and so on (1).
CashCutoffHour - server hour after which no new slice fires (21).
Panel and chart
ShowPanel - panel on or off.
PanelX and PanelY - distance from the chart edge (12, 15).
PanelFontSize - base text size (9).
ShowArabic - second language line (on).
ShowChartMarks - plans and levels drawn on the chart (on).
MaxTableRows - order rows per grid (13).
PanelCorner - corner the panel is anchored to.
Entry trigger
EntryTriggerMode - the STC strategy by default.
SignalBarShift - 1 is the last finished bar.
SignalBarsDelay - bars between accepted signals (30; 0 every).
SignalValidBars - bars a signal stays usable (3).
SignalAllowBuy and SignalAllowSell - switch each side.
SignalReverse - turns the direction around (off).
Schaff Trend Cycle
InpSTCFast - fast EMA of the inner MACD (23).
InpSTCSlow - slow EMA of the inner MACD, above the fast one (50).
InpSTCCycle - bars in each stochastic pass (10).
InpSTCFactor - smoothing of each pass, 0.05 to 1; lower is smoother (0.5).
InpSTCSignal - length of the signal line EMA (3).
InpSTCClimbMin - Climb Guard: least STC gain in points (10; 0 off).
InpSTCClimbBars - Climb Guard: bars the gain is measured over (3).
InpSTCGapMin - Gap Guard: least distance from the signal line in points (2; 0 off).
InpSTCStretchMax - Stretch Guard: points past the 50 midline STC may already be on the signal side; 30 refuses a BUY above 80 and a SELL below 20 (30; 0 off).
InpSTCSettleBars - Settle Guard: bars STC must have stayed on the other side of its line before the crossing (0 off).
InpSTCZoneBars - Zone Guard: bars back in which STC must have touched its far zone (0 off; try 3).
InpSTCZoneDepth - Zone Guard: depth of that zone in points past the midline; 25 means 25 or lower for BUY, 75 or higher for SELL (25).
InpSTCRangeMinATR - Range Guard: least window width in ATR (5; 0 off).
InpSTCRangeBars - Range Guard: window length in bars (20).
InpSTCATRPeriod - ATR length for the Range Guard (14).
InpSTCTrendFilter - 1 with the EMA side, 2 against it, 0 off (1).
InpSTCTrendMAPeriod - trend EMA length (200).
InpShowSignalArrows - arrow where a cycle armed (on).
InpShowSTCOnChart - past crossings on the live chart (on).
Debug
DebugMode - extra journal detail (off).
Margin timeframe safety
UseMarginTFSafety - main switch (off).
Level1MarginPct and Level1TF - at 6000 percent the work moves to M15.
Level2MarginPct and Level2TF - at 5000 percent the work moves to H1.
MarginTFHysteresisPct - recovery needed before stepping back (500).
----------
Risk, plainly
Grid trading is risky. It adds to losing positions, uses no stop loss, and a long trend can keep the book open for a long time or, with lots too big for the balance, end in a stop-out and a heavy loss. The STC is built from past prices and cannot see the next bar. No profit is promised. Pick lots that survive a bad run, test on your own broker, and only risk money you can afford to lose. No DLLs or extra files are needed.
If you use it, please leave an honest review of how it behaved for you, good or bad; it helps the next trader decide.
