Cloud Twist
- Uzmanlar
-
Steve Zoeger
Hello to my Fx friends. Forex is so diverse that you can't really single out any particular indicator or strategy. The ever-changing market and the ever-changing economic conditions around the world mean that there are many different ways to trade, so I have developed many different robots. These - Sürüm: 1.2
- Etkinleştirmeler: 5
Overview
Horizon Cloud Twist is a MetaTrader 5 Expert Advisor that trades Ichimoku cloud twist signals. A cloud twist happens when the two Senkou Span lines cross, which changes the colour of the cloud and signals a possible trend shift. The EA waits for that twist, then confirms it with a candle close beyond the cloud before entering a trade.
The EA is self contained. It calculates Ichimoku values internally, draws historical arrows on the chart, and offers four different trade management styles. These range from a single fixed trade to martingale grids and basket sequences.
The Core Signal
The Cloud Twist
The EA calculates the Ichimoku components directly from price data.
The Tenkan line is the midpoint of the nine bar high and low. The Kijun line is the midpoint of the twenty six bar high and low. Senkou Span A is the average of Tenkan and Kijun. Senkou Span B is the midpoint of the fifty two bar high and low.
The default periods are nine, twenty six and fifty two. All of these are adjustable.
The Senkou spans are projected twenty six bars forward. The calculation offsets bars by the Kijun period to account for this. This means the cloud the EA evaluates is the cloud actually visible on the chart at that bar.
Twist Detection
A twist is registered when the cloud flips. A bull twist happens when Span A crosses above Span B, which turns the cloud bullish and gives a bias to buy. A bear twist happens when Span A crosses below Span B, which turns the cloud bearish and gives a bias to sell.
Each twist is stored with its bar time and direction. Only the first twist per bar is recorded.
Confirmation
After a twist, the EA waits for price to confirm. A buy confirmation requires the close to be above the cloud top, which is the higher of Span A and Span B. A sell confirmation requires the close to be below the cloud bottom, which is the lower of the two spans.
When strict confirmation is enabled, the whole candle must be clear of the cloud. The low must be above the top for buys, and the high must be below the bottom for sells. This is a stricter filter that reduces false signals.
One Shot Logic
When a twist is detected, a consumed flag is set to false. The first confirmed candle fires the signal and sets the flag to true. This means each twist produces at most one entry. A new twist resets the cycle.
Signal Flow Per New Bar
First, the EA checks that a new bar has formed. Second, it checks the trading day, the time window and the spread. Third, the signal function scans the last closed bar against the current bar. If a new twist is found, the trend badge is updated and a log line is printed. If there is an unconsumed twist and confirmation is present, the function returns a buy or sell signal. An optional alert fires and an optional arrow is drawn. Finally, the entry is routed to the selected trade mode.
Visual Features
Ichimoku Overlay
When the show Ichimoku option is enabled, the EA attaches a native MetaTrader 5 Ichimoku indicator to the chart using your periods. It removes any existing Ichimoku indicators first to avoid duplicates. This is skipped in the Strategy Tester.
Signal Arrows
Arrows are drawn on confirmed signals, using upward and downward arrow codes in lime and red with a width of four. They are positioned a set distance in points below the low for buys or above the high for sells.
On initialisation, the history scan replays up to one thousand bars by default and redraws every historical twist and confirmation arrow. This lets you visually audit the logic on past price action. Drawings can be disabled in the tester.
Centre Screen Badge
A branded overlay shows the title Horizon Cloud Twist in an accent colour, an accent divider line, a subtitle and a version tag. It also shows a live trend readout of up, down or side, coloured lime, tomato or gold respectively. The badge re-centres when the chart is resized and is suppressed in the tester. All elements are cleaned up on deinitialisation.
Chart Styling
The EA applies a dark theme. The background is a dark grey, bull candles are yellow, bear candles are red, and the grid and volumes are hidden.
Trade Modes
The mode is selected through an input. The mode determines position sizing, stacking and exit logic. Trailing stops and protection apply to all modes.
Mode One Simple
This is the cleanest mode and holds one position at a time. The entry uses a fixed or dynamic lot, with a stop loss of fifty pips and a take profit of one hundred and fifty pips by default. If any position is already open, new signals are ignored until it closes. Exits happen through take profit, stop loss or the trailing stop.
Mode Two Martingale Price Grid
This is a classic averaging grid in one direction. The first signal opens the basket at the dynamic lot, capped at the maximum lot. The direction is locked and no new signals are taken while the basket is active.
Each additional step triggers when price moves against the entry by the count multiplied by the step in pips, which is forty five pips per level by default. The lot is the previous lot multiplied by the multiplier, which is one point two by default, capped at the maximum lot. A trigger distance guard prevents duplicate adds at the same price.
The exit happens when total basket profit, including swap, reaches the target of one dollar by default, and then everything is closed. The maximum number of levels is one hundred by default. This mode requires martingale to be enabled and the multiplier to be greater than one for adds to occur.
Mode Three Arrow Sequence Fixed
This is a basket trader that follows every arrow without lot escalation. Every confirmed signal opens a new position at the fixed lot of zero point zero one by default. Positions in both directions can coexist, and buy and sell counts are tracked. An optional close on flip setting makes an opposite signal close the entire basket first.
The exit happens when basket profit reaches the target of zero point three three dollars by default, and then all positions are closed. The position cap is fifty by default. State resets automatically when no positions remain.
Mode Four Arrow Sequence Plus Martingale
This is a hybrid that takes arrow by arrow entries with per direction lot multiplication. The first signal in a direction uses the base lot of zero point zero one by default. Subsequent same direction signals use the previous lot multiplied by one point five by default, capped at the maximum lot.
A direction flip resets the multiplier chain if reset on flip is enabled, and may close the basket if close on flip is enabled. The opposite direction counter is zeroed on each entry, keeping the two sides independent.
The exit happens when basket profit reaches the target of zero point three three dollars by default, and then all positions are closed.
Lot Sizing
There are two modes. In fixed mode, the lot is always the base lot, which is zero point zero one by default. In dynamic mode, the lot grows with account profit since the EA started. The formula is the base lot plus the integer part of the balance growth divided by the growth step, multiplied by the lot step. For example, every one hundred dollars of growth adds zero point zero one lots.
All lots pass through a normalisation function that clamps them to the symbol minimum and maximum and rounds them to the volume step.
The specialised modes use their own dedicated lot inputs where noted. The dynamic lot seeds the martingale start and simple mode.
Trade Management
Margin Guard
Before every order, the EA calculates the margin required for the exact lot and price. It requires free margin to be at least the required margin multiplied by one point zero two, which gives a two percent buffer. Orders that would fail with a no money error are blocked up front with a clear log line. This is the primary defence against broker side rejection errors.
Order Execution
All orders go through the trade class with the configured magic number, a symbol appropriate filling mode, a deviation of twenty points, error only logging, and a descriptive comment that includes the direction and step number.
Trailing Stop and Break Even
This is enabled through an input. For each EA position, the EA first checks that profit has reached the trailing start of ten pips by default. It then computes a break even stop loss at the entry plus or minus the break even buffer of one pip if break even is enabled. It also computes a trailing stop loss at the current price minus or plus the trailing distance of three pips.
The EA uses whichever level is tighter and behind price appropriately. A step filter means the stop loss is only modified if the improvement exceeds the trailing step of five pips by default. This prevents stop loss spam and requote churn. The stop loss is never moved backwards, so it only tightens.
Position Counting
The counting functions filter by magic number and symbol and count distinct position tickets. On netting accounts, multiple orders merge into one position, so counts reflect distinct positions. A volume function sums the EA volume as a fallback reference. A basket profit function sums profit and swap across all EA positions on the symbol. This is the number every basket exit compares against its target. The close all function iterates positions in reverse, closes EA matching tickets, and resets all martingale and sequence state.
Protection Layer
Drawdown Stop
When enabled, peak equity is tracked continuously. Drawdown is calculated as peak minus equity, divided by peak, times one hundred. If drawdown reaches the maximum of twenty percent by default, the EA closes all positions and halts trading.
The drawdown action input decides what happens next. In stop mode, trading remains halted. In continue mode, trading resumes after a five second cooldown and peak equity is rebased to current equity.
Equity Floor
When enabled, the floor is peak equity multiplied by the floor percentage, which is ninety percent by default. Below the floor, no new trades are taken. If close on floor is enabled, existing positions are also liquidated.
Time and Day Filters
The time filter uses a start and end time in hours and minutes and supports overnight windows where the start is later than the end. Individual day toggles cover Monday to Sunday, with Monday to Friday on and the weekend off by default.
Spread Filter
The spread filter uses a maximum spread in pips, which is two point five by default. It automatically handles three and five digit symbols by dividing the raw point spread by ten.
Execution Flow Per Tick
First, the EA updates peak equity. Second, it checks drawdown and stops if needed, resuming after five seconds in continue mode. Third, it checks the equity floor and optionally closes all positions. Fourth, it runs the trailing stops. Fifth, it manages the active basket mode.
Sixth, it checks whether a new bar has formed and returns if not. Seventh, it applies the trading day, time and spread filters. Eighth, it requests the cloud twist signal. Ninth, if there is a signal, it fires an alert, logs the event and draws an arrow. Tenth, it routes the entry to the correct entry function for the mode.
Basket management runs every tick because profit targets and grid adds are price driven. Entries are bar close driven. This split keeps management responsive without repainting entries.
Initialisation and Cleanup
On initialisation, the EA detects tester mode and configures the trade class with the magic number, filling mode, deviation and log level. It applies the chart theme and builds the badge on live charts only. It attaches the Ichimoku overlay if enabled, clears old arrows, and redraws the twist history. It records the initial balance and peak equity and resets all sequence and twist state.
On deinitialisation, it removes the badge, the arrows and the attached Ichimoku indicator.
Input Reference Summary
The Ichimoku entry group holds the Tenkan, Kijun and Senkou periods, the strict confirm toggle, the arrow distance of thirty points by default, and the alert on signal toggle. These control signal generation.
The display group holds the show Ichimoku and show arrows toggles, the arrow history of one thousand bars by default, and the disable drawings in tester toggle.
The time window group holds the use trade time toggle, the start time of eight in the morning, the end time of four in the afternoon, and the day toggles.
The trade management group holds the enable martingale toggle, the trade mode selector, the magic number of two by default, the use spread toggle, and the maximum spread of two point five pips.
The simple mode group holds the take profit of one hundred and fifty pips and the stop loss of fifty pips.
The martingale group holds the step of forty five pips, the target of one dollar, the maximum trades of one hundred, the multiplier of one point two, and the maximum lot of twenty.
The arrow sequence group holds the target of zero point three three dollars, the lot of zero point zero one, the maximum positions of fifty, and the close on flip toggle.
The sequence plus martingale group holds the target of zero point three three dollars, the base lot of zero point zero one, the multiplier of one point five, the maximum lot of twenty, the maximum positions of fifty, the reset on flip toggle, and the close on flip toggle.
The lot size group holds the base lot, the lot mode, the lot per hundred dollars, and the lot step.
The protection group holds the use drawdown toggle, the maximum drawdown of twenty percent, the drawdown action, the use equity floor toggle, the floor percentage of ninety, and the close on floor toggle.
The trailing group holds the use trail toggle, the trail start of ten pips, the trail distance of three pips, the trail step of five pips, the use break even toggle, and the break even buffer of one pip.
The user interface group holds the show badge toggle, the accent colours, and the brand text.
Practical Notes and Cautions
Signals evaluate the last closed bar, so entries occur at the open of the next bar. There is no intrabar repainting of entries.
Modes two and four multiply lots. Even with multipliers between one point two and one point five and lot caps in place, deep grids can consume margin rapidly. The margin guard blocks orders the account cannot afford, but basket drawdown can still be severe. Test thoroughly and consider the drawdown and equity floor protection.
On netting accounts, opposite direction entries in the sequence modes merge into a single net position. Profit targets still evaluate on summed profit, but per ticket behaviour differs. Hedging accounts behave as described per position.
In the tester, drawings and the badge are skipped and the chart Ichimoku overlay is not attached. The logic runs identically.
Profit targets are in account currency and default to dollars. Adjust them if your account currency differs or if lot sizes scale up, because very small basket targets on larger lots will trigger almost instantly.
A sensible workflow is to backtest each mode separately, verify the arrow history visually on a live chart, start on demo with conservative lots, and keep drawdown protection enabled.
One Line Summary
Horizon Cloud Twist detects Ichimoku cloud flips, confirms them with a candle close beyond the cloud, marks them with arrows and a live trend badge, and executes them through four configurable strategies. These range from a single fixed take profit and stop loss trade to martingale grids and escalating arrow sequence baskets, all wrapped in margin, drawdown, equity floor, spread, session and trailing stop safeguards.
