RobotPowerM5_meta4V1

Author: Copyright � 2005

Okay, here's a breakdown of what this MetaTrader script does, explained in plain language:

This script is designed to automatically trade on the Forex market using the MetaTrader platform. Think of it as a little robot that's watching the market and making buy or sell decisions based on a few simple rules.

Here's the basic idea:

  1. It uses Indicators: The robot uses a couple of indicators called "Bulls Power" and "Bears Power". These indicators are like tools that help it to analyse how strong are buyers and sellers in the market.
  2. It checks for Trading Opportunities:
    • The robot looks at the readings from the "Bulls Power" and "Bears Power" indicators. When these readings reach a certain state, the robot will look to open a trade.
    • The robot checks if is a good time to buy or sell and decides if the moment is right.
  3. It Manages Open Trades: If the robot already has a trade open, it checks how it's doing. If the trade is making a profit, the robot might adjust the "stop loss" to lock in some of those gains.
  4. It Places Orders: If the robot detects a potential trade, it will send an order to the market to either buy or sell.
    • It sets a "stop loss" (an automatic exit point if the trade goes the wrong way)
    • It sets a "take profit" (an automatic exit point when the trade reaches a desired profit level).
  5. It repeats: The robot keeps repeating steps 2-4 as long as it is activated in the MetaTrader platform.

Here are some other important things this script does:

  • Configuration: The script has a few settings you can adjust, like:
    • How much money to risk on each trade.
    • How far to set the "trailing stop" (a feature that automatically moves the stop loss as the trade becomes more profitable).
    • The desired profit target.
  • Error Handling: It checks if there are enough funds in the account to make a trade. If not, it prints a message and doesn't place the order.
  • Notifications: It can print messages to the screen when it makes a trade.

In short, this script is a simple automated trading system that tries to find profitable opportunities in the Forex market based on "Bulls Power" and "Bears Power" indicators and the script has a few basic risk management features.

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
Indicators Used
Bulls Power indicator Bears Power indicatorIndicator of the average true range
2 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
48.00 %
Total Trades 802
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -11.23
Gross Profit 8453.00
Gross Loss -17460.00
Total Net Profit -9007.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
37.00 %
Total Trades 516
Won Trades 198
Lost trades 318
Win Rate 0.38 %
Expected payoff -17.47
Gross Profit 5297.00
Gross Loss -14310.00
Total Net Profit -9013.00
-100%
-50%
0%
50%
100%
RobotPowerM5_meta4V1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                      RobotBB.mq4 |
//|                               Copyright © 2005,          Company |
//|                                          http://                 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005"
#property link      "http://www.funds.com"

// A reliable expert, use it on 5 min charts (GBP is best) with 150/pips profit limit. 
// . No worries, check the results 
extern int BullBearPeriod=5;
extern double lots         = 1.0;           // 
extern double trailingStop = 15;            // trail stop in points
extern double takeProfit   = 150;            // recomended  no more than 150
extern double stopLoss     = 45;             // do not use s/l
extern double slippage     = 3;

extern string nameEA       = "DayTrading";  // EA identifier. Allows for several co-existing EA with different values

double bull,bear;
//double stochHistCurrent, stochHistPrevious, stochSignalCurrent, stochSignalPrevious;
//double sarCurrent, sarPrevious, momCurrent, momPrevious;
double realTP, realSL,b,s,sl,tp;
bool isBuying = false, isSelling = false, isClosing = false;
int cnt, ticket;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() {
   return(0);
}

//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() {
   return(0);
}

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
   // Check for invalid bars and takeprofit
   if(Bars < 200) {
      Print("Not enough bars for this strategy - ", nameEA);
      return(-1);
   }
   calculateIndicators();                      // Calculate indicators' value   
   
   // Control open trades
   int totalOrders = OrdersTotal();
   int numPos = 0;
   for(cnt=0; cnt<totalOrders; cnt++) {        // scan all orders and positions...
      OrderSelect(cnt, SELECT_BY_POS);         // the next line will check for ONLY market trades, not entry orders
      if(OrderSymbol() == Symbol() && OrderType() <= OP_SELL ) {   // only look for this symbol, and only orders from this EA      
         numPos++;
         if(OrderType() == OP_BUY) {           // Check for close signal for bought trade
               
            if(trailingStop > 0) {             // Check trailing stop
               if(Bid-OrderOpenPrice() > trailingStop*Point) {
                  if(OrderStopLoss() < (Bid - trailingStop*Point))
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-trailingStop*Point,OrderTakeProfit(),0,Blue);
               }
            }
         } else {                              // Check sold trade for close signal
            
            if(trailingStop > 0) {             // Control trailing stop
               if(OrderOpenPrice() - Ask > trailingStop*Point)
                {
                  if(OrderStopLoss() == 0 || OrderStopLoss() > Ask + trailingStop*Point)
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+trailingStop*Point,OrderTakeProfit(),0,Red);
               }           
            } 
         }
      }
   }
   
   // If there is no open trade for this pair and this EA
   if(numPos < 1) {   
      if(AccountFreeMargin() < 1000*lots) {
         Print("Not enough money to trade ", lots, " lots. Strategy:", nameEA);
         return(0);
      }
      if(isBuying && !isSelling && !isClosing) {  // Check for BUY entry signal
         sl = Ask - stopLoss * Point;
         tp = Bid + takeProfit * Point;
         
        // ticket = OrderSend(OP_BUY,lots,Ask,slippage,realSL,realTP,nameEA,16384,0,Red);  // Buy
         //OrderSend(OP_BUY,lots,Ask,slippage,realSL,realTP,0,0,Red);
         OrderSend(Symbol(),OP_BUY,lots,Ask,slippage,sl,tp,nameEA+CurTime(),0,0,Green);
         Comment(sl);
         if(ticket < 0)
            Print("OrderSend (",nameEA,") failed with error #", GetLastError());
         prtAlert("Day Trading: Buying"); 
      }
      if(isSelling && !isBuying && !isClosing) {  // Check for SELL entry signal
          sl = Bid + stopLoss * Point;
          tp = Ask - takeProfit * Point;
        // ticket = OrderSend(NULL,OP_SELL,lots,Bid,slippage,realSL,realTP,nameEA,16384,0,Red); // Sell
         OrderSend(Symbol(),OP_SELL,lots,Bid,slippage,sl,tp,nameEA+CurTime(),0,0,Red);
         if(ticket < 0)
            Print("OrderSend (",nameEA,") failed with error #", GetLastError());
         prtAlert("Day Trading: Selling"); 
      }
   }
   return(0);
}

void calculateIndicators() {    // Calculate indicators' value   
 

   bull = iBullsPower(NULL,0,BullBearPeriod,PRICE_CLOSE,1);
   bear = iBearsPower(NULL,0,BullBearPeriod,PRICE_CLOSE,1);
Comment("bull+bear= ",bull + bear);
   //sarCurrent          = iSAR(NULL,0,0.02,0.2,0);           // Parabolic Sar Current
   //sarPrevious         = iSAR(NULL,0,0.02,0.2,1);           // Parabolic Sar Previuos
   //momCurrent          = iMomentum(NULL,0,14,PRICE_OPEN,0); // Momentum Current
  // momPrevious         = iMomentum(NULL,0,14,PRICE_OPEN,1); // Momentum Previous
   
  
   b = 1 * Point + iATR(NULL,0,5,1) * 1.5;
   s = 1 * Point + iATR(NULL,0,5,1) * 1.5;
   // Check for BUY, SELL, and CLOSE signal
  // isBuying  = (sarCurrent<=Ask && sarPrevious>sarCurrent && momCurrent<100 && macdHistCurrent<macdSignalCurrent && stochHistCurrent<35);
  // isSelling = (sarCurrent>=Bid && sarPrevious<sarCurrent && momCurrent>100 && macdHistCurrent>macdSignalCurrent && stochHistCurrent>60);
    isBuying  = (bull+bear>0);
    isSelling = (bull+bear<0);

   isClosing = false;
}

void prtAlert(string str = "") {
   Print(str);
   //Alert(str);
   //SpeechText(str,SPEECH_ENGLISH);
   // SendMail("Subject EA",str);
}

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

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---