Vidya Harborlight EA
- Experts
-
AL MOOSAWI ABDULLAH JAFFER BAQER
To trade successfully we need to go through the proven path that others had gone and reached!
Here are 17 quotes from such successful investors:
1- Limit your size in any position so that fear does not become the prevailing instinct guiding your judgment.
Joe Vidich - 버전: 3.43
- 활성화: 5
VIDYA grid EA for traders who want an average that runs when the market runs and nearly stands still when it only shakes. One job: start a grid when a fast VIDYA crosses a slow VIDYA on a closed bar with the main trend behind it. Mechanism: Tushar Chande's Variable Index Dynamic Average, whose speed is set bar by bar by the Chande Momentum Oscillator, computed inside the EA from bar closes, then a Range Guard, an EMA 200 and an ATR-spaced grid that banks small closures.
Vidya Harborlight EA is a VIDYA expert advisor for MetaTrader 5, an adaptive moving average crossover grid EA. How it differs from the moving average cross you know: two plain EMAs move at the same pace in a dead range and in a breakout, so they cross again and again while price goes nowhere. VIDYA multiplies its smoothing by the absolute CMO: when the last 9 closes all point one way, the average moves at full EMA speed; when up and down moves cancel out, it almost freezes. Two VIDYAs therefore cross far less in noise and quickly when a real push starts. The price is the same as every average: it trails a sharp turn by a few bars.
Try it free first: load Vidya Harborlight EA in the MetaTrader 5 Strategy Tester with visual mode on, default inputs, EURUSD H1, and watch where it opens and closes on your own broker's data. Every cross it accepts gets an arrow; on the live chart every cross a guard refuses is shown as a grey dot. Spread, swap and commission differ between brokers, so your own test is the one that counts.
The trade lifecycle in four verbs. It measures how purposeful the last closes were, lets both VIDYAs move at that speed, waits for the fast one to cross the slow one on a closed bar with the trend behind it, then opens and spaces the grid by ATR and banks groups of orders as soon as their joint result clears the target.
Plain risk up front. This IS a grid. It adds to losing positions and uses no stop loss by default. Defaults: 0.01 first lot, additive steps of 0.01, ATR spacing with a 50 point floor, hedge cycle off, margin-level safety off. Limits stop new levels; they never force-close the book.
AN AVERAGE WITH A THROTTLE
In 1992 Tushar Chande described VIDYA in Technical Analysis of Stocks and Commodities. Start with an ordinary EMA and its fixed smoothing 2/(N+1). Then, on every bar, scale that smoothing by a number between 0 and 1 that measures how one-sided recent trading was. Chande used his own Momentum Oscillator for this: CMO = 100 x (sum of up moves - sum of down moves) / (sum of all moves). A CMO near +100 or -100 means the closes marched in one direction, so VIDYA follows at full speed; a CMO near 0 means the moves cancelled out, so VIDYA barely moves. Think of a harbour light that only swings round when a ship is really coming in.
Five things to know first
- Entry: on a closed bar the fast VIDYA (10) finishes above the slow VIDYA (30) after finishing at or below it on the bar before (BUY), or the mirror for SELL. A slope-turn mode of the fast VIDYA is included as an alternative. Accepted signals do not repaint.
- Calculated inside the EA from bar closes: CMO over 9 closes, k = |CMO| / 100, VIDYA = previous VIDYA + 2/(N+1) x k x (close - previous VIDYA), once with N = 10 and once with N = 30. No indicator file, no DLL, no web request.
- The known weak spot of VIDYA: after a long quiet stretch both lines sit almost flat and close together, so the first push can make them cross on a move that fades. The Range Guard skips tight boxes and the EMA 200 filter takes crosses only in the trend direction; Side Hold, Stretch Guard, Slope Confirm, Cool Down and Body Guard are there too, all off by default.
- New CMO Strength Guard is built in and ships switched OFF: when set, a BUY cross needs CMO at least +N on the signal bar and a SELL cross at most -N, so a cross made by a slow drift with no push behind it is refused. Try 20 to 40 in the Strategy Tester and compare with off.
- No stop loss and no forced close-all. Limits stop new levels; the open book stays under management.
Start here (5 minutes)
1. Attach it to EURUSD H1 and leave every input at its default.
2. Set RunMode to Scan only for the first session. The panel shows each plan; no order is sent.
3. Look at the arrows and grey dots on the chart: they show which past crosses the guards would have taken or refused.
4. Run the Strategy Tester on your own broker, look at the worst equity dip next to the result, and size the first lot so that dip fits your balance many times over.
5. Only then press ARMED on the panel. More than one chart? Give each copy its own EAMagicNumber and HedgeMagicNumber.
Why VIDYA for a grid
A grid needs one clean starting gun, then it needs the engine to work. VIDYA is a good gun for three reasons. It is built from closes only, so it means the same on every broker. Its speed comes from the market itself, so the same two settings behave sensibly in a slow Asian session and in a fast news hour. And its formula is short and published, so you can check every arrow yourself. The honest costs: an adaptive average still turns late after a sharp reversal, and a long one-way trend holds the book open. The Range Guard, the trend filter, the gap between signals and the optional CMO Strength Guard are there for exactly that.
One cycle, step by step
1. Measure. On each new bar the EA sums the up and down moves of the last 9 closes into the CMO.
2. Adapt. Both VIDYAs step toward the close by their EMA factor times |CMO| / 100.
3. Cross. In the default mode the fast VIDYA must finish on the other side of the slow one from the bar before. In slope mode the fast VIDYA itself must turn up (BUY) or down (SELL).
4. CMO Strength Guard. Off by default. When set, the CMO must point the trade's way with at least the chosen strength.
5. Stretch Guard. Off by default. When set, the fast VIDYA may sit at most N points from the slow one on the signal bar, so a late cross after a burst is refused.
6. Side Hold, Slope Confirm, Cool Down, Body Guard. All off by default: fast VIDYA on the old side for N bars, slow VIDYA moving the trade's way over N bars, no other cross in the N bars before, and a candle body at least N% of its range.
7. Range Guard. The last 20 bars must span at least 5 ATR, so tight boxes are skipped.
8. 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.
9. 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.
10. Ladder. Levels follow ATR or fixed points, with a floor, a ceiling and an optional freeze. BUY and SELL baskets can run together or alone.
11. 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.
12. 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.
13. Hedge cycle, optional: off by default; 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 sits 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. Two rows belong to the signal, and every short code on them is spelled out here:
- VIDYA row: 10/30 = fast and slow VIDYA periods, CMO 42 = the Chande Momentum Oscillator on the last closed bar, ABOVE or BELOW = fast VIDYA against the slow one, UP or DN = fast VIDYA rising or falling, ev 5b = the last cross was 5 bars ago.
- VD GUARDS row: SH 4/3 = Side Hold count against bars required (off when not used), CS 30 OK = CMO Strength Guard level and whether the current CMO is strong enough (LOW when not; off when not used), GAP 12 = fast-to-slow distance in points with OK, HOLD or off, SL UP/DN = slow VIDYA slope for Slope Confirm, R 6.3 OK = Range Guard width in ATR with its state, CD 3 = Cool Down bars, BD 55 OK = candle body % against Body Guard, EMA UP/DN = side of the EMA 200.
On the live chart every cross of the last 150 bars is marked: a small arrow when accepted, a grey dot when a guard refused it. Buttons switch Armed / Scan only, Pause / Resume, chart marks and slicing. The Hedge Vault card docks under the main panel; with the hedge off it stays hidden. 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.
Copies are kept apart by symbol and magic number.
Scan only shows every decision without sending a single order.
Who this is for
Traders who like moving average crosses but are tired of the whipsaw in quiet markets; who are happy with many small closures; who prefer an EA that trades with the main trend; and who will size lots to their balance after their own test.
Who this is NOT for
- Anyone who needs a stop loss on every order. This grid has none by design.
- Anyone expecting a fixed monthly return or a fast doubling. No result is promised.
- Small accounts running large lots unattended. A long one-way trend can hold the book open for weeks.
- Traders who want a trade on every candle. The filters keep it quiet on purpose, and on daily charts it may wait a long time between entries.
- Traders who will not test first.
Common questions
Does it repaint? Accepted signals, chart marks and both panel rows use finished bars only.
Is it the classic VIDYA? Yes, the CMO-driven form: k = |CMO(9)| / 100 and VIDYA = VIDYA[1] + 2/(N+1) x k x (close - VIDYA[1]). The MetaTrader 5 VIDYA indicator with the same CMO and EMA periods follows the same rule; small differences in the first bars come from seeding.
What do the periods do? Longer fast and slow periods make crosses rarer and later; a longer CMO period makes the speed change more slowly. Keep the slow period clearly above the fast one.
Cross or slope mode? Cross mode waits for the fast VIDYA to close through the slow one. Slope mode reacts when the fast VIDYA itself turns, which comes earlier and more often.
What does the CMO Strength Guard add? It refuses crosses that happen without a one-sided push behind them. Higher values mean fewer, stronger entries; test 20 to 40 against off on your broker.
Why does it sometimes not trade for days? The Range Guard, the EMA side and the gap between signals all wait for a clear move. That is by design.
What should I change first? InpVDMinCMO, then InpVDRangeMinATR, then InpVDFast and InpVDSlow. One change at a time, and look at the worst dip next to the result.
Netting or hedging accounts? Both are supported; the grid keeps each side's book by symbol and magic number.
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 (9786430).
GridOrderComment - text on grid orders (VHBL).
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).
Closure 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 - gain 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 (9786431).
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 VIDYA 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).
Chande VIDYA
InpVDFast - fast VIDYA period: base EMA length of the quick adaptive average (10).
InpVDSlow - slow VIDYA period: base EMA length of the slow adaptive average (30).
InpVDCMO - CMO period: closes used by the Chande Momentum Oscillator that sets the VIDYA speed (9).
InpVDMinCMO - CMO Strength Guard: BUY only with CMO at least +N, SELL only with CMO at most -N on the signal bar (0 off by default).
InpVDBodyPct - Body Guard: signal candle body must be at least this % of its high-low range (0 off).
InpVDMode - 0 fast VIDYA crosses slow VIDYA, 1 fast VIDYA slope turns (0).
InpVDPrevBars - Side Hold: bars the fast VIDYA must have stayed on the old side before a cross counts (0 off).
InpVDCoolBars - Cool Down: a cross is refused if another cross came within this many bars before it (0 off).
InpVDSlopeBars - Slope Confirm: the slow VIDYA must have moved in the signal direction over this many bars (0 off).
InpVDMaxGap - Stretch Guard: largest fast-to-slow VIDYA distance on the signal bar, in points (0 off).
InpVDRangeMinATR - Range Guard: least window width in ATR (5; 0 off).
InpVDRangeBars - Range Guard: window length in bars (20).
InpVDATRPeriod - ATR length for the Range Guard (14).
InpVDTrendFilter - 1 with the EMA side, 2 against it, 0 off (1).
InpVDTrendMAPeriod - trend EMA length (200).
InpShowSignalArrows - arrow where a cycle armed (on).
InpShowVDOnChart - past VIDYA crosses on the live chart, arrow or grey dot (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. VIDYA is built from past closes and cannot see the next bar; an adaptive average is not a prediction. No result 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.
Tested it in the Strategy Tester or on a live account? A short, honest review helps the next trader: tell us the symbol, the timeframe and the CMO Strength level you used, what worked and what did not. Critical reviews are as welcome as good ones; they shape the next release.
