100 pips Mod

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
Profit factor:
0.00

This automated trading script is designed to manage market positions by analyzing price trends and automatically executing trades based on predefined technical criteria. Its primary goal is to identify entry points, manage active trades to protect profits, and ensure the account remains within safe operational limits.

Core Operational Logic

1. Pre-Trade Validation Before any actions are taken, the script performs a series of "safety checks" to ensure the trading environment is suitable. It verifies that there is enough historical data available on the chart and confirms that the profit targets set by the user meet minimum requirements. Additionally, it checks your account balance to ensure there is sufficient available margin to open a new trade based on your chosen lot size.

2. Market Analysis & Entry Signals The script continuously monitors the relationship between the current market price and moving averages. It looks for specific price actions to determine the "direction" of the market:

  • Buy Signals: If the closing price falls below a specific moving average, the script identifies an upward trend potential and initiates a "Buy" order.
  • Sell Signals: If the closing price rises above a specific moving average, it identifies a downward trend and initiates a "Sell" order.

3. Trade Execution and Management Once a signal is identified, the script automatically opens a position with your specified lot size. It calculates the necessary "Take Profit" levels automatically to target a specific gain.

A key feature of this script is its Trailing Stop functionality. This means that as a trade moves into profitability, the script dynamically adjusts the stop-loss price:

  • For a winning Buy position, the stop-loss moves up as the price rises.
  • For a winning Sell position, the stop-loss moves down as the price falls. This logic is designed to "lock in" profits, ensuring that if the market suddenly reverses, you keep a portion of the gains rather than letting a winning trade turn into a loss.

4. User Experience Features The script includes several quality-of-life features for the user:

  • Visual Feedback: It provides real-time comments on the chart indicating the current market direction.
  • Audio Alerts: If enabled, the script can provide an audible notification whenever a trade modification occurs.
  • Trade Constraints: It includes built-in logic to ensure that it does not open multiple redundant positions simultaneously, focusing on managing one active trade at a time per symbol.
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
Miscellaneous
It plays sound alerts
8 Views
0 Downloads
0 Favorites
100 pips Mod
//+------------------------------------------------------------------+
//|                                               100 pips a day.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

extern double lTakeProfit = 31;
extern double sTakeProfit = 35;
extern double lTrailingStop = 22;
extern double sTrailingStop = 19;
extern double Stoploss = 0;
extern color clOpenBuy = Blue;
extern color clCloseBuy = Aqua;
extern color clOpenSell = Red;
extern color clCloseSell = Violet;
extern color clModiBuy = Blue;
extern color clModiSell = Red;
extern string Name_Expert = "Generate from Gordago";
extern int Slippage = 2;
extern bool UseSound = False;
extern string NameFileSound = "alert.wav";
extern double Lots = 1;


void deinit() {
   Comment("Starting ....");
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start(){
   if(Bars<100){
      Print("bars less than 100");
      return(0);
   }
   if(lTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }
   if(sTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }

   double diClose0=iClose(NULL,5,0);
   double diMA1=iMA(NULL,5,7,0,MODE_SMA,PRICE_OPEN,0);
   double diClose2=iClose(NULL,5,0);
   double diMA3=iMA(NULL,5,6,0,MODE_SMA,PRICE_OPEN,0);

   if (diClose0<diMA1)
      Comment("Direction = UP"); 
   if (diClose2>diMA3)      
      Comment("Direction = DN");

   if(AccountFreeMargin()<(1000*Lots)){
      Print("We have no money. Free Margin = ", AccountFreeMargin());
      return(0);
   }
   if (!ExistPositions()){

      if ((diClose0<diMA1)){
         OpenBuy();
         return(0);
      }

      if ((diClose2>diMA3)){
         OpenSell();
         return(0);
      }
   }
   TrailingPositionsBuy(lTrailingStop);
   TrailingPositionsSell(sTrailingStop);
   return (0);
}

bool ExistPositions() {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol()) {
return(True);
}
} 
} 
return(false);
}
void TrailingPositionsBuy(int trailingStop) { 
   for (int i=0; i<OrdersTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol()) { 
            if (OrderType()==OP_BUY) { 
               if (Bid-OrderOpenPrice()>trailingStop*Point) { 
                  if (OrderStopLoss()<Bid-trailingStop*Point) 
                     ModifyStopLoss(Bid-trailingStop*Point); 
               } 
            } 
         } 
      } 
   } 
} 
void TrailingPositionsSell(int trailingStop) { 
   for (int i=0; i<OrdersTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol()) { 
            if (OrderType()==OP_SELL) { 
               if (OrderOpenPrice()-Ask>trailingStop*Point) { 
                  if (OrderStopLoss()>Ask+trailingStop*Point || 
OrderStopLoss()==0)  
                     ModifyStopLoss(Ask+trailingStop*Point); 
               } 
            } 
         } 
      } 
   } 
} 
void ModifyStopLoss(double ldStopLoss) { 
   bool fm;
   fm = OrderModify(OrderTicket(),OrderOpenPrice
(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE); 
   if (fm && UseSound) PlaySound(NameFileSound); 
} 

void OpenBuy() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 
   ldLot = GetSizeLot(); 
//-----Changes by Adil
   if (Stoploss > 0)
      ldStop = GetStoploss_Buy();
   else
      ldStop = Stoploss; 
//-----Changes by Adil
   ldTake = GetTakeProfitBuy(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol
(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,0,0,clOpenBuy); 
   if (UseSound) PlaySound(NameFileSound); 
} 
void OpenSell() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 
   ldLot = GetSizeLot(); 
//------Changes by Adil
   if (Stoploss > 0)
      ldStop = GetStoploss_Sell();
   else
      ldStop = Stoploss;   
//-----Changes by Adil
   ldTake = GetTakeProfitSell(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol
(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,0,0,clOpenSell); 
   if (UseSound) PlaySound(NameFileSound); 
} 
string GetCommentForOrder() { return(Name_Expert); } 
double GetSizeLot() { return(Lots); } 
double GetTakeProfitBuy() { return(Ask+lTakeProfit*Point); } 
double GetTakeProfitSell() { return(Bid-sTakeProfit*Point); }
//-----Changes by Adil
double GetStoploss_Buy()  { return(Ask+Stoploss*Point); }
double GetStoploss_Sell() { return(Bid-Stoploss*Point); }  
//-----Changes by Adil

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
3 reports
GBP/USD Oct 2024 - Jan 2025
0.00
Total Trades 1
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -7913.00
Gross Profit 0.00
Gross Loss -7913.00
Total Net Profit -7913.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00
Total Trades 1
Won Trades 0
Lost trades 1
Win Rate 0.00 %
Expected payoff -6316.00
Gross Profit 0.00
Gross Loss -6316.00
Total Net Profit -6316.00
-100%
-50%
0%
50%
100%
USD/CHF Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%

Comments