Exp - Swing Pendulum or Swing Algorithm

Exp - Swing Pendulum or Swing Algorithm

21 June 2019, 12:58
Vladislav Andruschenko
0
3 260

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.







There are three types of opening pending orders in our advisor!

  1. Auto-opening after installation (  Instant opening AutoTrade )
  2. Opening and maintenance after manual opening (  Manual opening ManualTrade )
  3. 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!

  1. Auto-open after installation,
  2. Opening and maintenance after a manual opening
  3. 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:

  1. At startup, the advisor sets two Buy Stop and Sell Stop orders at a distance of StopOrderDeltaifUSE from the current price.
  2. If Buy Stop worked, Sell Stop is deleted and set on its place Sell Stop with BuyStop * Martin lot.
  3. If Sell Stop is triggered, Buy Stop is deleted and on its place is installed  Buy Stop with the Sell Stop * Martin lot.
  4. If the position receives a loss, then the current series is considered not closed! And the advisor continues work with the algorithm!
  5. 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:

  1. On startup, the Expert Advisor waits until the user opens the position from our  EAPADPRO panel.
  2. 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
  3. If Buy is open, is set Sell Stop with Buy * Martin lot.
  4. If Sell is open, is installed Buy Stop with the Sell * Martin lot.
  5. If the position receives a loss, then the current series is considered not closed! And the advisor continues to work with the algorithm!
  6. If the position received a take-profit, then the position is closed and everything starts again.
  7. 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:

  1. At startup, the Expert Advisor calculates the HIGH and LOW levels according to the set TimeFrame.
  2. 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
  3. If Buy Stop worked, Sell Stop is deleted and is set in its place Sell Stop with BuyStop * Martin lot.
  4. If Sell Stop is triggered, Buy Stop is deleted and  is installed in its place Buy Stop with the Sell Stop * Martin lot.
  5. If the position receives a loss, then the current series is considered not closed! And the advisor continues to work with the algorithm!
  6. 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.

  1. 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.
  2. 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.
  3. 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.

  1. 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;

  1. If  Martin is less than 1, then each next position and its lot will be less than the previous one.
  2. Values ​​less than 1 it makes sense to use only when the  Lots    positions is more than the minimum lot on the server.
  3. If  Martin is more than 1, then each next position and its lot will be larger than the previous one.
  4. The higher the value of  Martin , the more dangerous the trade adviser.
  5. 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

  1. Start = Period_M1; Stop = Period_D1;

Optimization of  TFTrade_Num  values  : The number of last bars, to determine the levels

  1. Start = 0; Step = 1; Stop = 10;

Options:

  1. trade_ - section "Trade settings".
  2. TypeofTrade - Choosing an Expert Advisor Trading Mode!
  3. StopOrderDeltaifUSE - distance for pending orders (100).
  4. MaxOrders - Maximum number of knees
  5. Magic is the magic number (777).
  6. StopLoss - stop loss, by default it is not used (0).
  7. ModifyStopLossAtOrdersopen - modify the stop-loss of the transaction to the level of opening a pending order
  8. TakeProfit , it is not used by default (0). If TakeProfit = -1, then TakeProfit = StopOrdersDistance
  9. AdjustTP - adjustment of take-profit when opening pending orders. 
    AdjustAfter - the number of the steps, after which there will be an adjustment.
  10. StopDayTradingEaAfterTP - if the last position is closed by take profit, the EA stops work until the next day
  11. DeleteOppositeOrder - Delete the opposite order, when triggered.
  12. CloseOppositePositionsAfterTP - Close opposite orders \ positions if the current closed on the takeprofit.
  13. Slippage - slippage (0).
  14. 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
  15. LotFix - lots separated by commas to open coups, for example "0.1,0.2,0.3,0.6,0.8,1"
  16. MartinFix - The Martingale coefficient, separated by commas, for opening coups, for example "2,3,1,5,2,1"
  17. MarketWatch - the trading mode (false). At true, first positions / orders are placed without stops, then modification takes place. Suitable for some brokers.
  18. Lots - fixed lot (0.1).
  19. Martin is the Martingale ratio for the next open deal after losing (2).
  20. timetrade_ - section "Trade time settings".
  21. Open Hour is the opening hour for trades (0).
  22. OpenMinute - the minute of opening trades (0).
  23. CloseHour is the closing hour for trades (23).
  24. CloseMinute is the closing time of the trade (59).
  25. Trailing_ - section "Trailing Stop Settings".
  26. TrailingStopUSE - use trailing stop (false).
  27. IfProfTrail - break -even mode, use only for profitable positions (false).
  28. TrailingStop - trailing stop distance, by default used the minimum allowed (0).
  29. TrailingStep - the distance step (1).
  30. StartPointToTrail - from what level of profit in points to begin to use the trail.
  31. RollbackPoint - the number of rollback points to close part of the position.
  32. PercentLotToClose - the number of percent of the initial lot to close the position.
  33. StepPointToFixLevel - the number of items for fixing the next level.
  34. MovingInWLUSE - transfer of the position to the breakeven at the first level of the trailing stop.
  35. 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.


Examples of work: 



You can also download my other products:
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






Share it with friends: