Author: Müller Peter
Profit factor:
0.00

This script is an automated trading scanner designed for the MetaTrader 4 platform. Its primary purpose is to monitor market conditions and execute trades based on specific technical indicators. Below is a non-technical breakdown of how the logic functions:

Core Trading Logic

The system operates by checking the market every time a new price candle forms. It focuses on identifying high-probability entry points using a "Moving Average Crossover" strategy.

When the software identifies a crossover between a "Fast" moving average (which reacts quickly to price changes) and a "Slow" moving average (which reflects long-term trends), it triggers a trade signal. This is a classic method used to determine when momentum is shifting in either an upward or downward direction.

Execution Process

Once the software detects a valid signal from the moving averages, it follows these steps:

  • Direction Identification: The script automatically determines whether to "Buy" or "Sell" by comparing the calculated Take Profit (TP) and Stop Loss (SL) levels. If the target profit is higher than the stop loss, it initiates a Buy order; otherwise, it initiates a Sell order.
  • Order Placement: It automatically calculates the correct market price (Ask for buys, Bid for sells) and sends the order to the broker with a predefined lot size.
  • Risk Management: Every trade is launched with specific safety boundaries—a Stop Loss to limit potential losses and a Take Profit to secure gains.

Advanced Indicator Integration

While the primary execution is driven by moving averages, the script includes a sophisticated framework for several other major technical indicators. These are available as modular "signals" within the system:

  • Momentum & RSI: Used to measure the speed of price movements and identify "overbought" or "oversold" conditions.
  • MACD: Helps in identifying changes in the strength, direction, and momentum of a trend.
  • Bollinger Bands: Provides a visual representation of market volatility, helping the system understand if price movement is reaching an extreme.

Performance Monitoring

The script features a built-in diagnostic tool. Upon starting, it calculates and prints out a performance summary based on historical data, showing the success rate of the signals, the total points gained, and any consecutive losses encountered. This allows users to see how the logic has performed before relying on it for live trading.

Key User Controls

The logic is highly customizable through several input parameters:

  • Sensitivity: You can adjust the speeds of the Moving Averages (Fast vs. Slow).
  • Thresholds: You can set specific levels for RSI and Momentum to filter out "noisy" signals.
  • Trade Parameters: Users can manually define the lot sizes, profit targets, and risk limits to suit different account sizes.
Price Data Components
Orders Execution
It automatically opens orders when conditions are reached
11 Views
0 Downloads
0 Favorites
Signaltest
ÿþ//+------------------------------------------------------------------+

//|                                                      Scanner.mq4 |

//|                        Copyright 2021, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Müller Peter"

#property link      "https://www.mql5.com/en/users/mullerp04/seller"

#property version   "1.00"

#property strict

#include <SignalClass.mqh>



input int TP_Points = 50;

input int SL_Points = 400;

input double BaseLotSize = 0.01;

input int MomentumPeriod = 14;

input int MomBuyLevel = 110;

input int MomSellLevel = 90;

input int Slow_Movingaverage = 55;

input int Fast_Movingaverage = 10;

input int MACD_SlowPeriod = 26;

input int MACD_FastPeriod = 12;

input int MACD_SignalPeriod = 9;

input int BollingerPeriod = 20;

input int BollingerDeviation = 2;

input int RSIPeriod = 14;

input int RSIBuyLevel = 30;

input int RSISellLevel = 70;

input bool TradeWithTrend = false;







MomentumSignal MomSig(_Symbol,PERIOD_CURRENT,MomentumPeriod,TP_Points*Point(),SL_Points*Point(),MomBuyLevel,MomSellLevel);

MACrossover MASignal(_Symbol,PERIOD_CURRENT,Slow_Movingaverage,Fast_Movingaverage,MODE_SMA,TP_Points*Point(),SL_Points*Point());

RSISignal RsiSig(_Symbol,PERIOD_CURRENT,RSIPeriod,RSIBuyLevel,RSISellLevel,TP_Points*Point(),SL_Points*Point());

MACDSignal MACDSig(_Symbol,PERIOD_CURRENT,MACD_FastPeriod,MACD_SlowPeriod,MACD_SignalPeriod,TP_Points*Point(),SL_Points*Point());

BollingerSignal BBSig(_Symbol,PERIOD_CURRENT,BollingerPeriod,BollingerDeviation,TP_Points*Point(),SL_Points*Point());



int OnInit()

{   

   if(SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP) == 0.001) 

      Decimal = 3;

   if(SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP) == 1)

      Decimal = 0;

   double PointsGained;

   int ConsecLosses;

   Print("signal entry success rate: "+ DoubleToStr(MACDSig.WinRate(1000,PointsGained,ConsecLosses)));

   Print(DoubleToStr(PointsGained) + " Points gained, Consecutive losses: "+ DoubleToStr(ConsecLosses));

   

   return(INIT_SUCCEEDED);

}



void OnTick()

{

   if(!IsNewCandle())   

      return;

   

   double TP,SL;

   if(MASignal.Entry(0,TP,SL)) // Entry at current (0).th bar? if so what is the tp and sl

   {

      int cmd;

      double Price;

      if(TP > SL)    // if tp  > sl  this has to be a buy trade

      {

         cmd = OP_BUY;

         Price = SymbolInfoDouble(_Symbol,SYMBOL_ASK);

      }

      else 

      {

         cmd = OP_SELL;

         Price = SymbolInfoDouble(_Symbol,SYMBOL_BID);

      }

      if(OrderSend(_Symbol,cmd,BaseLotSize,Price,50,SL,TP) == -1)

         PrintFormat("Could not open order Error code: %d",GetLastError());

   }

}







Comments