System Trading

Mastering the Trailing Stop with Magic Number in MetaTrader 4
MetaTrader4
Mastering the Trailing Stop with Magic Number in MetaTrader 4

Hey traders! Let’s dive into how a trailing stop can really boost your trading game by moving the stop loss into profit territory, ensuring we keep our gains secured automatically. We’ll kick things off by setting the input parameters for our trailing stop in the code: input    bool     isTrailingStop = true;  // Enable Trailing Stop input    int       trailingStart  = 15;    // Trailing Start (pips) input    int       trailingStep   = 5;     // Trailing Step (pips) input    int       MagicNumber = 0;        // Magic Number Now, let’s set up a global variable: // Global Variable double   myPoint    = 0.0; When we run this Expert Advisor (EA), the OnInit() function will be executed for the first time, where we will validate and initialize our input variables: int OnInit()   {     if (isTrailingStop && trailingStart <= 0){       Alert ("Parameters incorrect");       return(INIT_PARAMETERS_INCORRECT);    }         myPoint     = GetPipPoint(Symbol());        return(INIT_SUCCEEDED);   } Every time there’s a price movement (tick) on the chart where this EA is active, the OnTick() function will be executed. Inside this function, we’ll call setTrailingStop(): void OnTick()   {   //---      setTrailingStop(MagicNumber);   } Now, let’s look at the setTrailingStop() function: void setTrailingStop(int magicNumber=0){    if (isTrailingStop==false) return;       int      tOrder = 0;    string   pair = "";    double   sl = 0.0, tp = 0.0;       pair = Symbol();       tOrder = OrdersTotal();    for (int i=tOrder-1; i>=0; i--){       bool hrsSelect = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);       if (OrderMagicNumber() == magicNumber && StringFind(OrderSymbol(), pair, 0) == 0 ){          if (OrderType() == OP_BUY){             if ( (Bid - (trailingStart * myPoint)) >= OrderOpenPrice()               && (Bid - ((trailingStart+trailingStep) * myPoint) >= OrderStopLoss() )               ){                sl = NormalizeDouble(Bid - (trailingStart * myPoint), Digits());                if (!OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0, clrBlue)){                   Print ("#", OrderTicket(), " failed to update SL");                }             }          }                   if (OrderType() == OP_SELL){             if ( (Ask + (trailingStart * myPoint)) <= OrderOpenPrice()               && ( (Ask + ((trailingStart+trailingStep) * myPoint) <= OrderStopLoss() ) || OrderStopLoss() == 0.0)                )         {                sl = NormalizeDouble(Ask + (trailingStart * myPoint), Digits() );                if (!OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0, clrBlue)){                   Print ("#", OrderTicket(), " failed to update SL");                }             }          }       } //end if magicNumber    }//end for } Another essential function you’ll need is GetPipPoint(): // Function GetPipPoint double GetPipPoint(string pair) {    double point= 0.0;    int digits = (int) MarketInfo(pair, MODE_DIGITS);    if(digits == 2 || digits== 3) point= 0.01;    else if(digits== 4 || digits== 5) point= 0.0001;    return(point); } Got questions? Feel free to drop them in the comments below! You can also join our trading group for more insights. Check it out here: t.me/codeMQL Don’t forget to check out our SignalForex App too! Your support means a lot, so download the app and enhance your trading experience! You can find it here: SignalForex App

2021.03.30
Mastering the 2 MA Crossing Strategy for MetaTrader 4
MetaTrader4
Mastering the 2 MA Crossing Strategy for MetaTrader 4

In this post, we're diving into how to create an Expert Advisor (EA) that utilizes the 2 MA Crossing strategy on MetaTrader 4. Let’s kick things off by defining our input variables. //--- Input Parameters input    int      period_ma_fast = 8;  // Fast MA Period input    int      period_ma_slow = 20; // Slow MA Period input    double  takeProfit  = 20.0;  // Take Profit in pips input    double  stopLoss    = 20.0;  // Stop Loss in pips input    double  lotSize     = 0.10;  // Lot Size input    double  minEquity   = 100.0;// Minimum Equity ($) input    int slippage = 3;      // Slippage input    int magicNumber = 889;  // Magic Number Next up, let’s define our global variables. These variables will be accessible to all functions within our EA. // Global Variables double  myPoint    = 0.0; int      mySlippage = 0; int      buyTicket   = 0; int      sellTicket  = 0; When the EA runs, the first function it hits is OnInit(). We often use this function to validate and initialize the global variables we’ll be using. int OnInit() {    // Validate Inputs    if (period_ma_fast >= period_ma_slow || takeProfit < 0.0 || stopLoss < 0.0 || lotSize < 0.01 || minEquity < 10) {       Alert("WARNING - Invalid input data!");       return (INIT_PARAMETERS_INCORRECT);    }       double min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);    if(lotSize<min_volume) {       string message =StringFormat("Volume is less than the allowed minimum of %.2f",min_volume);       Alert (message);       return(INIT_PARAMETERS_INCORRECT);    }       myPoint = GetPipPoint(Symbol());    mySlippage = GetSlippage(Symbol(),slippage);    return(INIT_SUCCEEDED); } As the market price fluctuates (ticks), the OnTick() function will trigger and execute all commands within this block. Within the OnTick() function, we’ll invoke several other functions. First, we’ll call the checkMinEquity() function to ensure we have enough trading equity. If our equity meets the requirement, we’ll set up a signal variable and call the NewCandle() function to recognize when a new candle forms. The getSignal() function will check both moving average indicators and return whether a crossover has occurred, signaling whether to buy or sell. Based on this signal, we’ll pass it to the transaction() function to open a buy or sell position, followed by invoking the setTPSL() function to establish the take profit and stop loss levels. If the equity doesn't meet the minimum requirement, an alert will pop up, and the EA will halt. void OnTick() {    if (checkMinEquity()) {       int signal = -1;       bool isNewCandle = NewCandle(Period(), Symbol());              signal = getSignal(isNewCandle);       transaction(isNewCandle, signal);       setTPSL();    } else {       // Stop trading due to insufficient equity       Print("EA will be stopped due to insufficient equity.");    } } Let’s take a closer look at the setTPSL() function. void setTPSL() {     int  tOrder = 0;     string  strMN = "", pair = "";     double sl = 0.0, tp = 0.0;        pair = Symbol();        tOrder = OrdersTotal();     for (int i=tOrder-1; i>=0; i--) {       bool hrsSelect = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);       strMN = IntegerToString(OrderMagicNumber());       if (StringFind(strMN, IntegerToString(magicNumber), 0) == 0 && StringFind(OrderSymbol(), pair, 0) == 0) {          if (OrderType() == OP_BUY && (OrderTakeProfit() == 0 || OrderStopLoss() == 0)) {             if (takeProfit > 0) {                tp = OrderOpenPrice() + (takeProfit * myPoint);             } else {                tp = OrderOpenPrice();             }             if (stopLoss > 0) {                sl = OrderOpenPrice() - (stopLoss * myPoint);             } else {                sl = OrderStopLoss();             }             if (OrderTakeProfit() != tp || OrderStopLoss() != sl) {                if(OrderModify(OrderTicket(), OrderOpenPrice(), sl, tp, 0, clrBlue)) {                   Print("Order modification successful!");                }             }          }          if (OrderType() == OP_SELL && (OrderTakeProfit() == 0 || OrderStopLoss() == 0)) {             if (takeProfit > 0) {                tp = OrderOpenPrice() - (takeProfit * myPoint);             } else {                tp = OrderOpenPrice();             }             if (stopLoss > 0) {                sl = OrderOpenPrice() + (stopLoss * myPoint);             } else {                sl = OrderStopLoss();             }             if (OrderTakeProfit() != tp || OrderStopLoss() != sl) {                if (OrderModify(OrderTicket(), OrderOpenPrice(), sl, tp, 0, clrRed)) {                   Print("Order modification successful!");                }             }          }       } // End of if magic number && pair     } // End of for } For those looking to connect and share knowledge, feel free to join our community on Telegram at t.me/codeMQL. If you need an app to enhance your trading experience, check out our SignalForex app available on the Play Store! SignalForex App on Play Store

2021.03.30
Unlock Trading Success with 'The Enchantress' - A Deep Learning Expert Advisor for MetaTrader 4
MetaTrader4
Unlock Trading Success with 'The Enchantress' - A Deep Learning Expert Advisor for MetaTrader 4

Hey fellow traders! 🌟 Today, I want to share my journey developing a self-adapting Expert Advisor (EA) that’s designed to elevate your trading game. Meet ‘The Enchantress’ - a deep learning system that’s all about harnessing market patterns. The inspiration for this EA came after I created another tool that focuses on static patterns, known as 'The Unreal Engine'. If you're curious, you can check it out here. Now, let’s get to the nitty-gritty. I hit a bit of a snag while testing ‘The Enchantress’ due to my computer's limitations. With a dual-core PC and just 4GB of RAM, I found it hard to fully explore the capabilities of this advanced EA. If you’re serious about testing it over the long haul, you might want to invest in a more powerful machine, or be prepared for a lengthy testing process. What does ‘The Enchantress’ do? This EA meticulously collects and analyzes every market pattern it encounters. It then opens virtual orders with stop-loss and take-profit parameters, ensuring that it pinpoints the best conditions to execute real trades. Important Note: Since this is a deep learning EA, it requires a bit of time to begin its real trading operations. Plan on running it for at least 3 to 5 months before you see it in action. And remember, always test on a strategy tester first before diving into live trading! If you decide to give ‘The Enchantress’ a spin, I’d love to hear about your results! Feel free to share your experiences here. For optimal results, I recommend testing it on a 5-digit currency pair with a minimum timeframe of H1. Best of luck, and happy trading!

2021.03.13
Creating the Easiest EA with the DeMarker Indicator for MetaTrader 4
MetaTrader4
Creating the Easiest EA with the DeMarker Indicator for MetaTrader 4

Hey fellow traders! If you’ve ever considered using an Expert Advisor (EA) to enhance your trading strategy, you’re in the right place. Today, I’m sharing my experience with a straightforward EA that I’ve developed, which I think you’ll find super useful. After reading through, I’d love for you to share your thoughts! This EA is designed to operate on a single currency pair and comes with customizable settings for timeframe, lot size, stop loss, and take profit, all easily accessible in the menu properties. extern ENUM_TIMEFRAMES TF = PERIOD_CURRENT;// Select Time Frame extern int period = 8;// Period DeMarker extern double lt = 0.01;// Lots extern int sl = 100;// Stop Loss extern int tp = 100;// Take Profit extern double OB = 0.7;// Over Sold extern double OS = 0.3;// Over Bought extern bool OPENBAR = false;// Trading on new bar open price Now, here’s a little secret: I break down the EA into three key parts: Data | TimeframeOrder ManagementCurrency Pair //+------------------------------------------------------------------+ //-- Time frame | Indicator double dmrk[5]; int signal = -1;//-- 0.buy 1.sell int hold = 0; //-- Order Management int ticket = 0; double lot = 0.0; int typ = -1; //-- Currency Pair datetime t1 = 0; bool newbar = false; bool entry = false; //+------------------------------------------------------------------+ In the OnInit() function, I set up the DeMarker indicator and check for the minimum lot size required by the broker. Here’s how it works: //+------------------------------------------------------------------+ //| Initialization void OnInit() &nbsp;&nbsp;{ &nbsp;&nbsp; ArrayInitialize(dmrk,0.0); &nbsp;&nbsp;//--- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const double test_lot = SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(lt < test_lot) lt = test_lot; &nbsp;&nbsp;} Now, let’s dive into the OnTick() function, where we calculate the DeMarker indicator and identify our buy and sell signals: //--------------------------------------------------------------------------- &nbsp;&nbsp; signal = -1; //--------------------------------------------------------------------------- //--- Calculate &nbsp;&nbsp; for(int i = 0; i < ArraySize(dmrk); i++) &nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dmrk[i] = iDeMarker(Symbol(), TF, period, i); &nbsp;&nbsp;&nbsp;&nbsp; } //--- &nbsp;&nbsp; if(dmrk[1] > OB) &nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hold = 1;// Set hold &nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp; else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(dmrk[1] < OS) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hold = -1;// Set hold &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hold = 0;// Reset hold &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp; if(hold == 1) &nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(dmrk[0] < OB && dmrk[1] > OB) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signal = OP_SELL; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp; if(hold == -1) &nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(dmrk[0] > OS && dmrk[1] < OS) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signal = OP_BUY; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp; } To execute buy and sell orders, we use the following logic: //--------------------------------------------------------------------------- &nbsp;&nbsp; if(signal != -1) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(newbar == true) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(entry == false)// Door open &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//--- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entry = true;// Set entry &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//--- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(signal == OP_BUY) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ticket = OrderSend(Symbol(), OP_BUY, lt, Ask, (int)((Ask - Bid) / Point, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sl > 0? Bid - sl * Point: 0.0, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tp > 0? Bid + tp * Point: 0.0, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EAName + ":signal= " + IntegerToString(signal) + ":hold= " + IntegerToString(hold), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EANumber, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clrBlue); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signal = -1; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//hold = 0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}// Reset &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(signal == OP_SELL) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ticket = OrderSend(Symbol(), OP_SELL, lt, Bid, (int)((Ask - Bid) / Point, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sl > 0? Ask + sl * Point: 0.0, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tp > 0? Ask - tp * Point: 0.0, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EAName + ":signal= " + IntegerToString(signal) + ":hold= " + IntegerToString(hold), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EANumber, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clrRed); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;signal = -1; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//hold = 0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}// Reset signal &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} And when it comes to closing orders... &nbsp;&nbsp; if(entry == true) // Closing &nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(OrderSelect(ticket, SELECT_BY_TICKET)) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(OrderCloseTime() == 0)//-- Order is active &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Condition to close */ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//entry = false; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(OrderCloseTime() != 0)//-- Close by manual, SL/TP, or EA &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry = false;// Reset entry &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp; }

2020.12.17
Creating a CSV File with MetaTrader 4: A Simple Guide for Traders
MetaTrader4
Creating a CSV File with MetaTrader 4: A Simple Guide for Traders

Hey there, fellow traders! I'm Lucas, and I wanted to give back to this amazing community that has taught me so much through insightful articles and discussions. As a forex and stock market investor who codes my own trading tools for personal use, I'm excited to share this contribution with you all! Today, I'm going to walk you through a simple example of how to create a CSV file for order data using MetaTrader 4. While this expert advisor is not intended for live trading just yet, it's a great way to demonstrate how you can implement this functionality in your own trading strategies. This little expert will open trades in your chosen direction, and orders can be closed virtually using the menu settings for Take Profit (TP) and Stop Loss (SL). If you set 'WriteCloseData' to true, a CSV file will be generated in your terminal, capturing essential order details such as direction, gain/loss, price, and more. When you test this expert in the strategy tester, you can find your CSV file in the following location: OpenDataFolder/tester/CSVexpert/CSVexample. The 'CSVexpert' directory will automatically be created when you start testing, along with the 'CSVexample' file that stores all your data. Once you decide to implement this functionality into your own expert or continue building upon this example for demo or live accounts, you can access the generated file from MQL4/Files/CSVexpert/CSVexample. You can rename the directory and file to whatever you like, just remember to keep the .csv extension intact. I want to emphasize again that this is purely an example of what you can achieve with this feature. Please be cautious and avoid using it for trading until you're confident in its performance! Happy trading and coding!

2020.11.14
Mastering Your Exit Strategy: A Comprehensive Guide for MetaTrader 4 Traders
MetaTrader4
Mastering Your Exit Strategy: A Comprehensive Guide for MetaTrader 4 Traders

As traders, we often focus on our entry points, but let's not forget about the importance of a solid exit strategy. The Master Exit Plan is a collection of straightforward strategies designed to help you effectively manage your open trades and pending orders. Important Note: This is not an Expert Advisor that opens trades for you—it’s all about managing what you already have on the table. Here’s a breakdown of the exit strategies you can utilize: Equity Target: This feature helps safeguard your account's equity in a conservative manner. Hard Stop-Loss: Set a fixed, visible stop-loss for every trade you enter. Hidden Stop-Loss: Implement a fixed, hidden stop-loss on your trades to minimize risk while remaining discreet. Dynamic Hard Stop-Loss: This stop-loss moves along with the price, allowing you to trade as if you have no stop-loss in place. You can dive deeper into this game-changing concept in the e-book Uncharted Stratagems: Unknown Depths of Forex Trading, which also includes more than a dozen innovative ideas worth exploring. Hidden Dynamic Stop-Loss: As the name implies, this is a concealed version of the dynamic stop-loss. Trailing Stop: This isn’t your ordinary trailing stop method. It introduces a unique twist, triggering the trailing stop only when a specific percentage of positive profit is achieved, ensuring you secure some positive pips. Trail Pending Order: This feature trails stop orders to optimize your profitable positions. By incorporating these strategies into your trading routine, you can significantly enhance your ability to exit trades effectively, protecting your profits and minimizing losses. Happy trading!

2020.11.07
Mastering the Rijfie Pyramid 1.12: A Guide for MetaTrader 4 Traders
MetaTrader4
Mastering the Rijfie Pyramid 1.12: A Guide for MetaTrader 4 Traders

Hey there, fellow traders! Today, I want to share my strategy using the Rijfie Pyramid version 1.12 with MetaTrader 4. If you're looking to fine-tune your trading game, you might find my approach helpful. Here’s the plan: Stock Selection: Start by searching for U.S. stocks priced under €20 or $20. Initial Purchase: Once the price rises above the stochastic low level, buy your first lot (0.01). Adding More: If the price dips, snag another lot (0.01). Trailing Stop: When the price climbs above your buy price plus the spread, that’s when your trailing stop kicks in. Regarding the stochastic indicators, when it crosses the level of 10, it’s time to buy a lot. Keep in mind: Max Price: No lots will be purchased above this price (max = price + spread). Low Price: No buys below the established low. Magic Number: Remember to change this for every new chart you analyze. Time Settings: Specify the hour and minute for your trades. For your profit settings, if you set it to 0, all open profitable orders will be closed at the specified closing time if Close All is set to true. Here’s how it works: For instance, if Close All is true, profit is set to 10, hour is 20:00, and minute is 55, then all open orders with a profit greater than 10 will close between 20:55 and 21:00. It's smart to look for stocks with low swap rates, such as Zynga, Nokia, and Vale. And here's a tip: setting your low price to 1 allows you to estimate your potential maximum loss. For example: With a max loss of 1% on a stock priced at €5, you risk about €500. For a stock priced at €15, your max loss would be around €1,500. Keep in mind, you only risk this if the company goes belly up. If you decide to close all trades while in the red, you're going to take a hit. You could also face losses if your broker no longer supports the stock. This is the latest version I like to use: Rijfie Pyramid version 1.12.mq4. Just a quick reminder—when using this EA, consider closing all open orders above 0 just before market close to avoid gaps the next day. With version 1.10, you can close profitable trades before the market closes by setting Close All to true along with your desired hour and minute. In the new version 1.12, you can adjust the percentage by setting Steplevel1. For instance, setting it at 1 means 1% and at 5 means 5%. At the end of the day, you'll notice some losses, but that's just part of the testing process. Happy trading, and may your charts always be green!

2020.10.26
Unlocking Success: The DreamBot Trading Robot for MetaTrader 4
MetaTrader4
Unlocking Success: The DreamBot Trading Robot for MetaTrader 4

Introduction Hey traders! If you're diving into the world of automated trading, you might have come across the DreamBot for MetaTrader 4. Now, let's be clear: this isn't a magic bullet or some kind of holy grail that will instantly make you rich. But what it can do is help streamline your trading process and take some of the guesswork out of your strategy. In this post, we're going to explore how DreamBot works, its features, and whether it’s a good fit for your trading style. What is DreamBot? DreamBot is an Expert Advisor designed for MetaTrader 4, which means it can automate your trading strategies based on specific algorithms. For those of you who prefer to kick back while the robot does the heavy lifting, this could be a game-changer! Key Features of DreamBot Automated Trading: Set it and forget it! DreamBot executes trades on your behalf based on pre-set criteria. User-Friendly Interface: You don’t need to be a tech wizard to get started. The setup is straightforward and intuitive. Backtesting Options: Test your strategies against historical data to see how they might perform in real market conditions. Customizable Settings: Tailor the bot’s parameters to match your trading style and risk tolerance. Before you jump in, remember that while DreamBot can make trading more efficient, it’s not foolproof. No robot can guarantee success in the unpredictable world of trading. Is DreamBot Right for You? If you’re a trader looking to automate your strategies but still want to maintain control over your trades, DreamBot might just be worth a shot. It can complement your trading approach, but always keep an eye on the market and adjust your strategies as needed. In conclusion, while DreamBot isn’t the holy grail of trading, it certainly has the potential to enhance your trading experience on MetaTrader 4. As with any trading tool, do your research, test it out, and see how it fits with your trading goals.

2020.10.22
Unlock Trading Success with MarketsMaster EA for MetaTrader 4
MetaTrader4
Unlock Trading Success with MarketsMaster EA for MetaTrader 4

Are you ready to take your trading to the next level? The MarketsMaster EA is an Expert Advisor designed specifically for MetaTrader 4, equipped with four reliable signals derived from six powerful indicators. Whether you’re trading Forex, indices, or metals, this EA can be tailored to your needs with the right parameters. Available in both English and Spanish, this tool is versatile enough to fit any trader's style. From my experience, it shines on timeframes from M15 to H1. However, any timeframe can yield profits if your strategy aligns with the market conditions. You have the flexibility to open orders with fixed lots or use a percentage of your account balance based on your risk appetite. The MarketsMaster EA operates using a combination of indicators like Volumes, PSAR, Stochastic, Bull and Bear Power, ATR, and MFI. It’s all about finding the right mix that works for your trading strategy. Profit management is handled through trailing stops, allowing you to maximize gains. For multiple open orders, profits can be taken in either monetary terms or as a percentage of your balance. Just a quick tip: if you don’t activate the loss percentage, it’s like setting it to 100%—so keep that in mind! Before you dive into backtesting, I recommend setting up the indicators on your chart first. Check the minimum volumes for trends and assess which indicators work best together across different timeframes. This will streamline your backtesting process and help you optimize your parameters. Also, consider evaluating the average price movement per trade to better set your trailing profit value. A friendly reminder: Don’t forget to add URLs under Tools / Options / Expert Advisors. Ensure you activate "Allow WebRequest for listed URL" and include both URLs for news updates. Just a heads up—news cannot be fetched for indices and metals, so avoid activating it for those, as it can disrupt other EAs on your charts. If anyone is interested in translating this to MQL5, that would be fantastic! I’m still getting the hang of MQL5 myself. If you do, please send me a copy! 😉

2020.10.04
First Previous 2 3 4 5 6 7 8 9 10 11 12 Next Last