TradersPowerExpert_v1.2_eurusd

Download script
Author: Copyright � 2006, Forex-TSD.com
Profit factor:
7924.12

TradersPowerExpert_v1 Logic Overview

This document provides a non-technical explanation of the logic used by the TradersPowerExpert_v1 automated trading script. The system is designed to identify trading opportunities based on historical price ranges and manage active trades through several safety and profit-taking mechanisms.


1. Core Strategy: Price Range Analysis

The robot determines its entry points by analyzing the "bullish" and "bearish" behavior of the market over a specific number of previous days (defined by the TradersPeriod parameter).

  • Data Collection: It looks back at the high, low, and opening prices of recent days to calculate how much the market moved in favor of buyers (Bulls) versus sellers (Bears).
  • Averaging: It calculates the average move for both Bulls and Bears over that period.
  • Entry Logic:
    • Buy Orders: The script places a "Buy Stop" order at a specific distance above today's opening price, based on the average bullish movement.
    • Sell Orders: The script places a "Sell Stop" order at a specific distance below today's opening price, based on the average bearish movement.
  • Spread Adjustment: The system automatically accounts for the "spread" (the difference between the buy and sell price offered by the broker) to ensure the orders are placed accurately.

2. Trade Management & Safety Features

The script includes several automated functions to protect capital and manage active positions:

  • Money Management: If enabled, the script automatically calculates the trade size (Lot size). It looks at your account balance, a chosen risk factor, and the maximum allowed loss per lot to determine how much you should trade.
  • Time Filters: You can specify which days of the week the robot is allowed to open new trades.
  • Automatic Closures:
    • Time-Based: The script can automatically close trades after a certain number of days have passed since they were opened (unless they are already in profit).
    • Cleanup: At the start of a new trading day, it is designed to delete any leftover pending orders from the previous session.
  • Trade Conflict Prevention: The system monitors active trades. If you have a Buy position open, it will automatically cancel any "Sell Stop" orders (and vice versa) to prevent contradictory positions from being taken simultaneously.

3. Profit Protection Mechanisms

The script uses three distinct methods to secure profits:

  • Break-Even: This moves the Stop Loss of an active trade to the entry price (or slightly beyond it into profit) once the trade reaches a specific milestone. It does this in "steps"—as the price moves further in your favor, the stop loss follows it upward/downward.
  • Trailing Stop: If enabled, the script will move the Stop Loss automatically behind the price as it moves in your favor. This allows the trade to run as long as possible while locking in gains if the market suddenly reverses.
  • Initial Stop Loss: The script can calculate and place an initial safety net (Stop Loss) at the moment a trade is opened, based on a percentage of the average daily range.

4. Execution Summary

The robot operates by scanning the market during specific hours to check if it should enter a trade. If no trades are currently open, it performs its calculations on historical data and places Buy/Sell Stop orders. Once a trade is triggered, it continuously monitors that trade to adjust stop losses (Break-Even or Trailing) and ensures that the position is closed according to your pre-defined time limits or profit targets.

Price Data Components
Series array that contains open time of each bar
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
16 Views
0 Downloads
0 Favorites
TradersPowerExpert_v1.2_eurusd
//+------------------------------------------------------------------+
//|                                        TradersPowerExpert_v1.mq4 |
//|                                  Copyright © 2006, Forex-TSD.com |
//|                         Written by IgorAD,igorad2003@yahoo.co.uk |   
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |                                      
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link      "http://www.forex-tsd.com/"

#include <stdlib.mqh>
//#include <Tracert.mqh>

//---- input parameters
extern string     Expert_Name = "---- TradersPowerExpert_v1 ----";

extern int        Magic=1007;
extern int        Slippage=6;

extern bool       Trace = false;           // Trace Switch

extern string     Main_Parameters = " Trade Volume & Trade Method";
extern double     Lots = 1;
extern bool       TrailingStop   = false;     // Trailing Stop Switch   
extern bool       InitialStop    = true;      // Initial Stop Switch
extern int        TimeZone       = 1;   

extern string     Data = " Input Data ";
extern int        TradersPeriod  = 4; 
extern double     BuyPercent     = 160;      // Percent from Daily Range for BUY 	
extern double     SellPercent    = 200;      // Percent from Daily Range for SELL
extern double     StopPercent    = 200;      // Percent from Daily Range for StopLoss
extern int        TradePeriod    = 5;       // Max days in trade 
extern double     BreakEven      = 85;       // BreakEven Level in pips
extern double     BreakEvenGap   = 8;       // Pips when BreakEven will be reached

extern string     Trade   =  " Trade Days of Week";
extern int        Monday         = 1;      // Day of the Week for Trade
extern int        Tuesday        = 1;
extern int        Wednesday      = 1;
extern int        Thursday       = 1;
extern int        Friday         = 1;

extern string     MM_Parameters = " MoneyManagement by L.Williams ";
extern bool       MM=false;                 // ÌÌ Switch
extern double     MMRisk=0.1;              // Risk Factor
extern double     LossMax=1466;             // Maximum Loss by 1 Lot


int      i,k,cnt=0, ticket, mode=0, digit=0, wenum=0, OrderOpenDay, Kz;
double   high,low, close[], open, range, Bulls,Bears,
         AvgBulls,AvgBears, SumBulls,SumBears,TodayOpen,spread=0, Profit=0;
double   smin=0, smax=0, BuyStop=0, SellStop=0, Lotsi=0, rates_h1[][6];
bool     BuyInTrade=false, SellInTrade=false;
datetime StartTime, prevwe=0;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//---- 

//----
   return(0);
  }
// ---- Money Management
double MoneyManagement ( bool flag, double Lots, double risk, double maxloss)
{
   double Lotsi=Lots;
	    
   if ( flag ) Lotsi=NormalizeDouble(Lots*AccountFreeMargin()*risk/maxloss,1);   
     
   if (Lotsi<0.1) Lotsi=0.1;  
   return(Lotsi);
}   

// Closing of Pending Orders      
void PendOrdDel()
{
    int total=OrdersTotal();
    for (int cnt=total-1;cnt>=0;cnt--)
    { 
      OrderSelect(cnt, SELECT_BY_POS,MODE_TRADES);   
      
        if ( OrderSymbol()==Symbol() && OrderMagicNumber()==Magic  )     
        {
        int mode=OrderType();
        
        bool result = false;
          switch(mode)
          {
            
            case OP_BUYSTOP   : {result = OrderDelete( OrderTicket() ); Print(" PendBUY"); }
          
            case OP_SELLSTOP  : {result = OrderDelete( OrderTicket() ); Print(" PendSELL"); }
          if(!result)
            {
            Print("OrderSend failed with error #",GetLastError());
            return(0);
            }
          //Print(" cnt=",cnt, " total=",total," MODE = ",mode," Ticket=",OrderTicket()  );                       
          }
         }
      } 
  return;
  }    

// 

void CloseOrdbyTime()
{
     int total=OrdersTotal();
     
     for (cnt=0;cnt<total;cnt++)
     { 
        OrderSelect(cnt, SELECT_BY_POS);   
        mode=OrderType();
        if ( mode <= OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
        { 
          datetime OpenTime=StrToTime(TimeToStr(OrderOpenTime(),TIME_DATE));
          datetime CurnTime=StrToTime(TimeToStr(CurTime(),TIME_DATE)); 
          int weekday=TimeDayOfWeek(OrderOpenTime());
          if (weekday <=5 && DayOfWeek()==1 && CurnTime > prevwe && CurnTime > OpenTime) {wenum =wenum + 1; prevwe = CurnTime;}      
          //if (OrderOpenDay <= 5 && DayOfWeek()>0) 
          int CalcBars=TradePeriod+2*wenum; 
          //else CalcBars=TradePeriod;
         
            if ((CurTime()-OpenTime)>=PERIOD_D1*CalcBars*60 || OrderProfit()>0)
            {
              if (mode==OP_BUY )
			     OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Yellow);
			     if (mode==OP_SELL)
			     OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
            }
        }
    }

}       
 
// ---- 
void TrailStops()
{        
    int total=OrdersTotal();
    for (cnt=0;cnt<total;cnt++)
    { 
     OrderSelect(cnt, SELECT_BY_POS);   
     mode=OrderType();    
        if ( OrderSymbol()==Symbol() && OrderMagicNumber()==Magic ) 
        {
            if ( mode==OP_BUY && smin > OrderStopLoss() )
            {
            Profit=0;
			   OrderModify(OrderTicket(),OrderOpenPrice(),smin,Profit,0,LightGreen);
			   return(0);
            }
           if ( mode==OP_SELL && smax < OrderStopLoss())
            {
            Profit=0;
   		   OrderModify(OrderTicket(),OrderOpenPrice(),smax,Profit,0,Yellow);	    
            return(0);
            }    
        }
    }   
} 

void SellOrdOpen()
{		     

		  double SellPrice=TodayOpen - AvgBears * SellPercent/100.0 - spread;
		  
		  if (InitialStop) SellStop=SellPrice + StopPercent*AvgBears/100.0; else SellStop=0;
        Profit=0;
	       
		  ticket = OrderSend(Symbol(),OP_SELLSTOP,Lotsi,
		                     NormalizeDouble(SellPrice,digit),
		                     Slippage,
		                     NormalizeDouble(SellStop,digit),
		                     Profit,"SELL",Magic,0,Red);
    

        OrderOpenDay  = DayOfWeek();   
        
        SellInTrade=false;            
        Kz=1;     
            if(ticket<0)
            {
            Print("OrderSend failed with error #",GetLastError());
            return(0);
            }
}

void BuyOrdOpen()
{		     

		  double BuyPrice =TodayOpen + AvgBulls*BuyPercent/100.0  + spread;
		  if (InitialStop) BuyStop = BuyPrice - StopPercent*AvgBulls/100.0; else BuyStop=0;
        Profit=0;
		 
		  ticket = OrderSend(Symbol(),OP_BUYSTOP ,Lotsi,
		                     NormalizeDouble(BuyPrice ,digit),
		                     Slippage,
		                     NormalizeDouble(BuyStop ,digit),
		                     Profit,"BUY",Magic,0,Blue);
                
        
        OrderOpenDay  = DayOfWeek();
        BuyInTrade=false;            
        Kz=1;    
            if(ticket<0)
            {
            Print("OrderSend failed with error #",GetLastError());
            return(0);
            }
}      

void ExtraOrdDel()
{
    int total = OrdersTotal();
    for (cnt=0;cnt<total;cnt++)
    { 
      OrderSelect(cnt, SELECT_BY_POS);   
      mode=OrderType();
        if ( OrderSymbol()==Symbol() && OrderMagicNumber()==Magic )     
        {
            if (mode==OP_BUY  && !BuyInTrade ) BuyInTrade =true;
            if (mode==OP_SELL && !SellInTrade) SellInTrade=true;
            
            if (mode == OP_SELLSTOP && BuyInTrade )
            { OrderDelete(OrderTicket()); SellInTrade=false; Print(" ExtraSell"); }
            if (mode == OP_BUYSTOP && SellInTrade )
            { OrderDelete(OrderTicket()); BuyInTrade=false; Print(" ExtraBuy"); }
    
	     }
	 }        
}

// ---- Scan Trades
int ScanTrades()
{   
   int total = OrdersTotal();
   int numords = 0;
      
   for(cnt=0; cnt<total; cnt++) 
   {        
   OrderSelect(cnt, SELECT_BY_POS);            
   if(OrderSymbol() == Symbol() && OrderType()>=OP_BUY && OrderMagicNumber() == Magic) 
   numords++;
   }
   return(numords);
}

datetime OrderOpenDate()
{
   int total = OrdersTotal();
   datetime date;
   for(cnt=0; cnt<total; cnt++) 
   {        
   OrderSelect(cnt, SELECT_BY_POS);            
   if(OrderSymbol() == Symbol() && OrderType()>=OP_BUY && OrderMagicNumber() == Magic) 
   date = StrToTime(TimeToStr(OrderOpenTime(),TIME_DATE));
   }
   return(date);
}  

void BreakEvenStop()
{        
   
    for (cnt=0;cnt<OrdersTotal();cnt++)
    { 
     OrderSelect(cnt, SELECT_BY_POS);   
     int mode=OrderType();    
        if ( OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) 
        {
            if ( mode==OP_BUY )
            {
               if ( Bid-OrderOpenPrice() > 0 ) 
               {Kz = MathFloor((Bid-OrderOpenPrice())/(BreakEven*Point));
                if (Kz < 1) Kz=1;} 
			         else Kz = 1;
			       // Print(" Buy Kz=",Kz); 
               //BuyStop = OrderStopLoss();
			         if (Bid-OrderOpenPrice() > Kz*BreakEven*Point) 
			            {
			            BuyStop=OrderOpenPrice()+((Kz-1)*BreakEven+BreakEvenGap)*Point;
			            
			            OrderModify(OrderTicket(),OrderOpenPrice(),
			                        NormalizeDouble(BuyStop, digit),
			                        OrderTakeProfit(),0,LightBlue);
			            
			            //Kz=Kz+1;
			            return(0);
			            }
			      
			   }
            if ( mode==OP_SELL )
            {
               if ( OrderOpenPrice()-Ask > 0 ) 
               {Kz = MathFloor((OrderOpenPrice()-Ask)/(BreakEven*Point));
                if (Kz < 1) Kz=1;}  
			         else Kz = 1;
			        // Print(" Sell Kz=",Kz);
               //SellStop = OrderStopLoss();
                  if (OrderOpenPrice()-Ask > Kz*BreakEven*Point) 
			            {
			            SellStop=OrderOpenPrice()-((Kz-1)*BreakEven+BreakEvenGap)*Point;
			            
			            OrderModify(OrderTicket(),OrderOpenPrice(),
			                        NormalizeDouble(SellStop, digit),
			                        OrderTakeProfit(),0,Orange);
			            
			            //DrawStops("SellStop",SellStop,Orange);
			            //Kz=Kz+1;
			            return(0);
			            }
               
            }
        }   
    } 
}	                    
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
   if(Bars < 1) {Print("Not enough bars for this strategy"); return(0);}
  
   //if ( Trace ) SetTrace();
  
   string   TimeTrade = "00:00";
   StartTime  = StrToTime(TimeTrade) + TimeZone*3600;
  
   if(Hour() >= TimeZone && Hour() <= TimeZone+1)
   {
     if ( OrderOpenDate() < StrToTime(TimeToStr( StartTime,TIME_DATE))) 
     { PendOrdDel(); if( TradePeriod > 0 )CloseOrdbyTime(); }
        if(ScanTrades()<1)
        {
      
         spread= MarketInfo(Symbol(),MODE_SPREAD)*Point;
         digit  = MarketInfo(Symbol(),MODE_DIGITS);
         Lotsi = MoneyManagement ( MM, Lots, MMRisk, LossMax);
         if (TrailingStop) InitialStop=true; 
   
         ArrayCopyRates(rates_h1, Symbol(), PERIOD_H1);
         TodayOpen = rates_h1[0][1];
         SumBulls=0;SumBears=0;
            for (k=TradersPeriod;k>=1;k--)
            {
            open = rates_h1[k*24][1];
            high=0; low=10000000;
               for (i=24;i>=1;i--)
               {
               high = MathMax( high, rates_h1[i+(k-1)*24][3]);
               low  = MathMin( low , rates_h1[i+(k-1)*24][2]);      
               
               }   
               
            range =(high-low); 
            Bulls = high - open;
            Bears = open - low;
            SumBulls += Bulls;
            SumBears += Bears; 
            //Print(" Bulls=",high,"Bears=",low);
            }
      
         AvgBulls = SumBulls/TradersPeriod;
         AvgBears = SumBears/TradersPeriod;
         //Print(" high=",AvgBulls,"low=",AvgBears);
         smin = Bid - StopPercent*AvgBears/100.0;
         smax = Ask + StopPercent*AvgBulls/100.0;
      
   
         if ( Monday   == 1 ) if(DayOfWeek()==1){BuyOrdOpen(); SellOrdOpen();}
         if ( Tuesday  == 1 ) if(DayOfWeek()==2){BuyOrdOpen(); SellOrdOpen();}
         if ( Wednesday== 1 ) if(DayOfWeek()==3){BuyOrdOpen(); SellOrdOpen();} 
         if ( Thursday == 1 ) if(DayOfWeek()==4){BuyOrdOpen(); SellOrdOpen();} 
         if ( Friday   == 1 ) if(DayOfWeek()==5){BuyOrdOpen(); SellOrdOpen();}
        }
      
    }
   ExtraOrdDel();
   if (BreakEven > 0) BreakEvenStop(); 
   if (TrailingStop) TrailStops(); 
 return(0);
}//int start
//+------------------------------------------------------------------+





Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
16 reports
EUR/USD Jul 2025 - Sep 2025
126769.06
Total Trades 127
Won Trades 124
Lost trades 3
Win Rate 97.64 %
Expected payoff 880389.19
Gross Profit 111810311.00
Gross Loss -882.00
Total Net Profit 111809429.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
3.90
Total Trades 22
Won Trades 19
Lost trades 3
Win Rate 86.36 %
Expected payoff 101.41
Gross Profit 2999.00
Gross Loss -768.00
Total Net Profit 2231.00
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
2.46
Total Trades 35
Won Trades 32
Lost trades 3
Win Rate 91.43 %
Expected payoff 57.97
Gross Profit 3417.45
Gross Loss -1388.64
Total Net Profit 2028.81
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
2.41
Total Trades 18
Won Trades 16
Lost trades 2
Win Rate 88.89 %
Expected payoff 113.84
Gross Profit 3507.45
Gross Loss -1458.37
Total Net Profit 2049.08
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
2.25
Total Trades 20
Won Trades 16
Lost trades 4
Win Rate 80.00 %
Expected payoff 46.12
Gross Profit 1661.17
Gross Loss -738.74
Total Net Profit 922.43
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
1.37
Total Trades 23
Won Trades 19
Lost trades 4
Win Rate 82.61 %
Expected payoff 21.36
Gross Profit 1815.46
Gross Loss -1324.18
Total Net Profit 491.28
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.82
Total Trades 41
Won Trades 35
Lost trades 6
Win Rate 85.37 %
Expected payoff -9.21
Gross Profit 1763.75
Gross Loss -2141.34
Total Net Profit -377.59
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.69
Total Trades 26
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -30.23
Gross Profit 1790.00
Gross Loss -2576.00
Total Net Profit -786.00
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.65
Total Trades 34
Won Trades 25
Lost trades 9
Win Rate 73.53 %
Expected payoff -31.76
Gross Profit 2007.00
Gross Loss -3087.00
Total Net Profit -1080.00
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.53
Total Trades 16
Won Trades 10
Lost trades 6
Win Rate 62.50 %
Expected payoff -64.96
Gross Profit 1176.89
Gross Loss -2216.20
Total Net Profit -1039.31
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.49
Total Trades 26
Won Trades 19
Lost trades 7
Win Rate 73.08 %
Expected payoff -47.50
Gross Profit 1179.00
Gross Loss -2414.00
Total Net Profit -1235.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.36
Total Trades 31
Won Trades 27
Lost trades 4
Win Rate 87.10 %
Expected payoff -42.71
Gross Profit 737.00
Gross Loss -2061.00
Total Net Profit -1324.00
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.33
Total Trades 20
Won Trades 14
Lost trades 6
Win Rate 70.00 %
Expected payoff -57.30
Gross Profit 574.00
Gross Loss -1720.00
Total Net Profit -1146.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.24
Total Trades 31
Won Trades 18
Lost trades 13
Win Rate 58.06 %
Expected payoff -101.58
Gross Profit 975.00
Gross Loss -4124.00
Total Net Profit -3149.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.18
Total Trades 22
Won Trades 16
Lost trades 6
Win Rate 72.73 %
Expected payoff -65.73
Gross Profit 307.00
Gross Loss -1753.00
Total Net Profit -1446.00
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.10
Total Trades 23
Won Trades 15
Lost trades 8
Win Rate 65.22 %
Expected payoff -107.47
Gross Profit 271.52
Gross Loss -2743.27
Total Net Profit -2471.75
-100%
-50%
0%
50%
100%

Comments