У нас вы можете посмотреть бесплатно IADX Trailing Stop Expert Advisor and Source Code (download for your own AI codebase) или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
Get MUCH more on AI Trading Tutorial: https://aitradingtutorial.com Download Source Code: https://mqlstreaming.s3.eu-west-1.ama... Download this Video: https://mqlstreaming.s3.eu-west-1.ama... In this video we are going to create an Expert Advisor that uses the ADX indicator to identify strong trends and automatically opens positions when the trend direction is confirmed. The system will also implement a trailing stop mechanism based on recent highs and lows to protect profits while allowing winning trades to run. Let's see how we can do that. We start Metaeditor by clicking the little icon or pressing F4. This opens the Metaeditor window where we can create our new Expert Advisor. We begin by including the Trade class from the standard library. This provides us with simplified trading methods like PositionOpen and PositionModify that make it easier to manage trades without having to deal with the lower level OrderSend functions. Next we instantiate a CTrade object called Trade. This object will handle all our trading operations including opening positions, modifying existing ones, and closing trades. The CTrade class provides a convenient interface for these operations. Now we define our strategy configuration parameters. These are all adjustable in the EA properties window when we attach it to a chart. LookbackBars determines how many historical candles we use to calculate recent highs and lows - this ranges from 1 to 1000 candles. MinCandlesBack specifies the minimum age for a valid high or low point, ensuring we don't use very recent extreme points that might be noise. This parameter ranges from 5 to 50 candles. TrailingOffset provides a safety margin for our trailing stop, measured in points from 1 to 20. ADXPeriod sets the period for our ADX indicator calculation, ranging from 8 to 50. Finally, ADXThreshold determines what level of ADX we consider strong enough to indicate a trending market, with values from 15 to 50. We then declare our global variables and handles. The adxHandle will store the handle for our ADX indicator once it's created. We have three arrays to store the indicator data: adxBuffer for the main ADX values, plusDIBuffer for the positive directional indicator values, and minusDIBuffer for the negative directional indicator values. The priceData array will hold our OHLC price information. Moving to the OnInit function, this is executed once when the Expert Advisor starts. Here we create the ADX indicator handle using the iADX function. We pass the current symbol _Symbol, the H1 timeframe PERIOD_H1, and our ADXPeriod parameter. We then configure all our arrays as time series using ArraySetAsSeries. This means the newest data will be at index 0, which is more intuitive for trading logic. We apply this configuration to all our arrays: adxBuffer, plusDIBuffer, minusDIBuffer, and priceData. The function returns INIT_SUCCEEDED to indicate successful initialization. The OpenBuyPosition function handles opening long positions. We first get the current ask price using SymbolInfoDouble with _Symbol and SYMBOL_ASK. Then we use Trade.PositionOpen to execute the buy order. The parameters are: _Symbol for the financial instrument, ORDER_TYPE_BUY for a long position, 0.10 for the position size which equals 10 micro lots, askPrice for the entry price at the current ask, 0 for the initial stop loss which means no stop loss is set, 0 for take profit which is also disabled, and ADX Position as the position comment. Similarly, the OpenSellPosition function handles opening short positions. We get the current bid price using SymbolInfoDouble with _Symbol and SYMBOL_BID. The Trade.PositionOpen parameters are: _Symbol for the instrument, ORDER_TYPE_SELL for a short position, 0.10 for 10 micro lots, bidPrice for the entry at current bid, 0 for no stop loss, 0 for no take profit, and ADX Position as the comment. The OnTick function is our main price update function that runs on every tick. First we retrieve historical price data using CopyRates. We pass _Symbol, PERIOD_H1, starting from candle 0, for LookbackBars number of candles, into our priceData array. Then we copy the ADX indicator values using CopyBuffer. We copy the main ADX values into adxBuffer, the positive DI values into plusDIBuffer, and the negative DI values into minusDIBuffer. We then check our position status. We initialize hasOpenPosition as false and currentPositionType as POSITION_TYPE_BUY. We loop through all positions using PositionsTotal, getting each position's ticket with PositionGetTicket. We use PositionSelectByTicket to select the position and check if it matches our symbol. If we find an open position, we set hasOpenPosition to true and store the position type.