SWING
The model of the well-known strategy Pendulum is the sequential opening of pending orders with an increased lot.
The principle is two pending orders are placed and when one order is activated, the second order is re-pending before the whole basket is closed by take-profit.
Extra Links:
How to test and optimize advisor
Solving problems with the advisor. Log Files for MetaTrader 4
Solving problems with the advisor. Log Files for MetaTrader 5
There are three types of opening pending orders in our advisor!
- Auto-opening after installation ( Instant opening AutoTrade )
- Opening and maintenance after manual opening ( Manual opening ManualTrade )
- Opening on the High Low levels ( High Low for the past bar TFTrade )
At startup, the advisor sets two Buy Stop and Sell Stop orders at a distance of StopOrderDeltaifUSE from the current price. If Buy Stop worked, Sell Stop is deleted and is set on its place Sell Stop with BuyStop * Martin lot. If Sell Stop is triggered, Buy Stop is deleted and on its place installed Buy Stop with the Sell Stop * Martin lot.
When the take-profit is achieved, all orders are deleted and everything starts again!
To achieve the swing effect, the parameters StopOrderDeltaifUSE and StopLoss must be equal.
Use cases
In our advisor there are three types of opening pending orders!
- Auto-open after installation,
- Opening and maintenance after a manual opening
- Opening on High Low!
TypeofTrade - Choosing an Expert Advisor Trading Mode!
We made the Expert Advisor which worked in 3 different types. Let us examine them in more detail:
AutoTrade or opening after installation :
In this mode, the advisor works to maintain the manual positions:
Algorithm:
- At startup, the advisor sets two Buy Stop and Sell Stop orders at a distance of StopOrderDeltaifUSE from the current price.
- If Buy Stop worked, Sell Stop is deleted and set on its place Sell Stop with BuyStop * Martin lot.
- If Sell Stop is triggered, Buy Stop is deleted and on its place is installed Buy Stop with the Sell Stop * Martin lot.
- If the position receives a loss, then the current series is considered not closed! And the advisor continues work with the algorithm!
- If the position received a take-profit, then the position is closed and everything starts again.
Result of work:
ManualTrade or tracking after manual opening :
In this mode, the EA waits for the trader to open the position using our panel for the EAPADPRO advisor
Algorithm:
- On startup, the Expert Advisor waits until the user opens the position from our EAPADPRO panel.
- Only after the trader opens the position using our panel, the advisor will put the opposite pending order, while the take-profit and stop-loss will be modified according to the system settings
- If Buy is open, is set Sell Stop with Buy * Martin lot.
- If Sell is open, is installed Buy Stop with the Sell * Martin lot.
- If the position receives a loss, then the current series is considered not closed! And the advisor continues to work with the algorithm!
- If the position received a take-profit, then the position is closed and everything starts again.
- The advisor stops his work until the trader opens a new position.
Result of work:
TFTrade or work on High Low levels :
In this mode, the Expert Advisor works in the High and Low levels set by the variables:
TFTrade_PERIOD = PERIOD_D1; - Timeframe, according to which the advisor will determine the levels of High Low
TFTrade_Num = 1; - The number of bars to determine the level.
Code:
StopOrdersDistance = (iHigh (Symbol (), TFTrade_PERIOD, iHighest (Symbol (), TFTrade_PERIOD, MODE_HIGH, TFTrade_Num, 1)) -iLow (Symbol (), TFTrade_PERIOD, iLowest (Symbol (), TFTrade_PERIOD, MODE_LOW, TFTrade_Num, 1))) / MarketInfo (Symbol (), MODE_POINT);
Algorithm:
- At startup, the Expert Advisor calculates the HIGH and LOW levels according to the set TimeFrame.
- Using the formula, the EA calculates the distance and places two pending orders Buy Stop and Sell Stop at a distance StopOrderDeltaifUSE from the current price
- If Buy Stop worked, Sell Stop is deleted and is set in its place Sell Stop with BuyStop * Martin lot.
- If Sell Stop is triggered, Buy Stop is deleted and is installed in its place Buy Stop with the Sell Stop * Martin lot.
- If the position receives a loss, then the current series is considered not closed! And the advisor continues to work with the algorithm!
- If the position received a take-profit, then the position is closed and everything starts again.
Result of work:
Optimization tips
We created this adviser on the pendulum algorithm. And the logic of the Expert Advisor's work is designed to perform a mathematical algorithm.
Therefore, all parameters are automatically configured, except for the distance between two pending orders.
You can optimize all the parameters, but we will give some recommendations:
Optimization for TypeofTrade = Manual Trade and AutoTrade
Manual Trade - Maintenance of manual opening
Auto Trade - Constant opening of pending orders
It makes sense to optimize only the parameters: StopOrdersDistance, MaxOrders and Martingale
Optimization of StopOrdersDistance values : It is recommended to set parameters individually for each pair.
- For example : If this is the EURUSD currency pair and you trade on the M30 period and the average price movement in the period, for example, 50 bars = 7500 points, then set this parameter for optimization as: start 0, step 100, stop 1000.
- For example : If this is the XUGUSD currency pair and you trade on the M1 period and the average price movement in the period, for example, 50 bars = 100 points, then set this parameter for optimization so: start 0, step 10, stop 100.
- For example : you need confirmation of the opening signal, and the average price movement in the period, for example 100 bars = 1000 points, then start 0, step 50, stop 500.
Optimizing MaxOrders : In this parameter, you can specify the maximum number of knees in a series of orders, so as not to loss your deposit.
- Start = 0; Step = 1; Stop = 10;
Optimizing Martingale values : In this parameter, you can specify an increase in the lot of the next pending router.
Start = 0.1 (If Lots> Minimum lot ); Step = 0.1; Stop = 2;
- If Martin is less than 1, then each next position and its lot will be less than the previous one.
- Values less than 1 it makes sense to use only when the Lots positions is more than the minimum lot on the server.
- If Martin is more than 1, then each next position and its lot will be larger than the previous one.
- The higher the value of Martin , the more dangerous the trade adviser.
- Martingale is a very simple and dangerous strategy.
The difference from ManualTrade is that with manual accompaniment, the adviser performs the task of closing a series of orders in profit and stops the work.
Optimization for TypeofTrade = TFTrade
TF Trade -
In this mode, the Expert Advisor works in the High and Low levels set by the variables:
TFTrade_PERIOD = PERIOD_D1; - Timeframe, according to which the advisor will determine the levels of High Low
TFTrade_Num = 1; - The number of bars to determine the level.
It makes sense to optimize only the parameters: TFTrade_PERIOD, TFTrade_Num
Optimizing TFTrade_PERIOD values : This is the period by which the High and Low levels are built
- Start = Period_M1; Stop = Period_D1;
Optimization of TFTrade_Num values : The number of last bars, to determine the levels
- Start = 0; Step = 1; Stop = 10;
Options:
- trade_ - section "Trade settings".
- TypeofTrade - Choosing an Expert Advisor Trading Mode!
- StopOrderDeltaifUSE - distance for pending orders (100).
- MaxOrders - Maximum number of knees
- Magic is the magic number (777).
- StopLoss - stop loss, by default it is not used (0).
- ModifyStopLossAtOrdersopen - modify the stop-loss of the transaction to the level of opening a pending order
- TakeProfit , it is not used by default (0). If TakeProfit = -1, then TakeProfit = StopOrdersDistance
- AdjustTP - adjustment of take-profit when opening pending orders.
AdjustAfter - the number of the steps, after which there will be an adjustment. - StopDayTradingEaAfterTP - if the last position is closed by take profit, the EA stops work until the next day
- DeleteOppositeOrder - Delete the opposite order, when triggered.
- CloseOppositePositionsAfterTP - Close opposite orders \ positions if the current closed on the takeprofit.
- Slippage - slippage (0).
- MaxSpreadToNotTrade - The maximum spread at which the Expert Advisor can open the grid
MinSpreadToNotTrade - Minimal spread, at which the Expert Advisor can open the grid - LotFix - lots separated by commas to open coups, for example "0.1,0.2,0.3,0.6,0.8,1"
- MartinFix - The Martingale coefficient, separated by commas, for opening coups, for example "2,3,1,5,2,1"
- MarketWatch - the trading mode (false). At true, first positions / orders are placed without stops, then modification takes place. Suitable for some brokers.
- Lots - fixed lot (0.1).
- Martin is the Martingale ratio for the next open deal after losing (2).
- timetrade_ - section "Trade time settings".
- Open Hour is the opening hour for trades (0).
- OpenMinute - the minute of opening trades (0).
- CloseHour is the closing hour for trades (23).
- CloseMinute is the closing time of the trade (59).
- Trailing_ - section "Trailing Stop Settings".
- TrailingStopUSE - use trailing stop (false).
- IfProfTrail - break -even mode, use only for profitable positions (false).
- TrailingStop - trailing stop distance, by default used the minimum allowed (0).
- TrailingStep - the distance step (1).
- StartPointToTrail - from what level of profit in points to begin to use the trail.
- RollbackPoint - the number of rollback points to close part of the position.
- PercentLotToClose - the number of percent of the initial lot to close the position.
- StepPointToFixLevel - the number of items for fixing the next level.
- MovingInWLUSE - transfer of the position to the breakeven at the first level of the trailing stop.
- Volatility LIMIT Sets
TradebyVolatility - Take into account volatility when opening the initial order grid.
TFVolatility - Timeframe, by which we will calculate volatility.
BarVolatility - The number of bars for determining volatility.
PointVolatility - The number of items to determine volatility.
Description | MetaTrader 4 | MetaTrader 5 |
---|---|---|
Copy of deals and positions between terminals | COPYLOT MT4 | COPYLOT MT5 |
Trading panel in 1 click from the chart and keyboard | VIRTUALTRADEPAD MT4 | VIRTUALTRADEPAD MT5 |
Automatic scalper without settings | TICK HAMSTER MT4 | TICK HAMSTER MT5 |
Professional Automatic scalper, Smart Robot | TICKSNIPER MT4 | TICKSNIPER MT5 |
Universal Expert Advisor on Custom Indicators | The xCUSTOMEA MT4 | The xCUSTOMEA MT5 |
Universal Advisor on Standard Indicators | THE X MT4 | THE X MT5 |
Averager, grid, additional opening of positions on Trend and against Trend | AVERAGER MT4 | AVERAGER MT5 |
Duplicator of positions, copying positions on one terminal | DUPLICATOR MT4 | DUPLICATOR MT5 |
Automatic installation of stop loss / take profit / trailing stop | ASSISTANT MT4 | ASSISTANT MT5 |
Simulator for strategy tester | TESTERPAD MT4 | TESTERPAD MT5 |
Professional account report | EXTRAREPORTPAD MT4 | EXTRAREPORTPAD MT5 |