ea_daytripper_03

Author: Ron Thompson
Profit factor:
0.66

This script is designed to automatically trade on the Forex market based on a moving average indicator. Here's the breakdown:

Overall Goal: The script aims to identify potential buying or selling opportunities by comparing the current price of an asset to its moving average. It then automatically places trades based on these signals.

User-Defined Settings: The script starts by allowing the user to customize a few key parameters:

  • Lots: This determines the size of the trades the script will make. It's essentially how much of your account balance you're willing to risk on each trade.
  • MovingAvg: This is the period for calculating the moving average. A larger number means the average is calculated over a longer period, making it smoother and less sensitive to short-term price fluctuations.
  • filter: This setting acts as a buffer zone around the moving average. The price has to move a certain distance beyond the moving average before the script considers it a valid signal. This helps to avoid false signals caused by minor price fluctuations.
  • TakeProfit: This sets the price at which an open trade will automatically close with a profit. It's a way to lock in gains once the price moves in your favor.
  • StopLoss: This sets the price at which an open trade will automatically close to limit your losses if the price moves against you.

How it Works:

  1. Initialization: The script starts by initializing all of its user configurations

  2. Checking the Market: Before placing any trades, the script performs a few checks:

    • Account Balance: Ensures there's enough available money in your trading account to place the trade.
    • Market History: Verifies that there's enough historical data available to calculate the moving average properly.
    • Market Activity: Checks if a new price bar has been formed, preventing the script from placing redundant orders
  3. Calculating the Moving Average: The script calculates a moving average (MA) using the asset's opening prices and the period specified by the user. It calculates not just the current MA but also the MA from the previous time period.

  4. Generating Trading Signals: It compares the current moving average to the previous moving average. If the current moving average is above the previous one (plus the filter buffer), it signals a potential "buy" opportunity. If the current moving average is below the previous one (minus the filter buffer), it signals a potential "sell" opportunity.

  5. Managing Existing Trades: Before placing new trades, the script checks if there are any existing trades open for the same asset. If there are, and a counter-indicator signal is generated (called CCI), it closes those trades to realize any accumulated gains or minimize losses.

  6. Setting Take Profit and Stop Loss: Before sending a trade, the script calculates take profit and stop loss levels based on user-defined pip value.

  7. Placing Orders: Based on the "buy" or "sell" signals, the script automatically places orders to buy or sell the asset. It sets the trade size according to the "Lots" parameter and includes the specified Stop Loss and Take Profit levels to manage risk and potential profits.

In Summary: The script automates trading decisions based on the relationship between the current price and its moving average. It uses user-defined settings to customize the trading strategy, manage risk, and define profit targets. It essentially takes away the need for manual monitoring and order placement, allowing the script to trade automatically according to the set rules.

Price Data Components
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Moving average indicatorCommodity channel index
10 Views
0 Downloads
0 Favorites
ea_daytripper_03
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+-------------------+
//| 1MA Expert        |
//+-------------------+
#property copyright "Ron Thompson"
#property link      "http://www.lightpatch.com/forex"

// User Input
extern double Lots = 0.1;
extern double MovingAvg=10;
extern double filter=0;
extern int   TakeProfit=0;
extern int   StopLoss=0;

// Global scope
      double barmove0 = 0;
      double barmove1 = 0;
       int  risingcnt = 0;
       int fallingcnt = 0;
       int periodcnt  = 0;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|

int init()
  {
   return(0);
  }


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


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {

   int     cnt=0;
   double  cMA=0, pMA=0;
   double p=Point();
   double slA,slB,tpA,tpB;
   double cCI=0;
      
   bool    rising=false;
   bool   falling=false;

   // Error checking
   if(AccountFreeMargin()<(1000*Lots))        {return(0);}
   if(Bars<100)                               {return(0);}
   if(barmove0==Open[0] && barmove1==Open[1]) {return(0);}

   // bars moved, update current position
   barmove0=Open[0];
   barmove1=Open[1];
   
   cMA=iMA(Symbol(), 0, MovingAvg, 0, MODE_LWMA, PRICE_OPEN, 0);
   pMA=iMA(Symbol(), 0, MovingAvg, 0, MODE_LWMA, PRICE_OPEN, 1);
   cCI=iCCI(Symbol(), 0, 30, 1,0);

   if (pMA+(filter*p)<cMA) {rising=true;  falling=false;}
   if (pMA-(filter*p)>cMA) {rising=false; falling=true;}
   
   for(cnt=0;cnt<OrdersTotal();cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol()==Symbol())
        {
         if (OrderType()==0)
           {
            //bought=true;
            if (cCI<0) OrderClose(OrderTicket(),Lots,Bid,0,White);
           }
         if (OrderType()==1) 
           {
            //sold=true;
            if (cCI>0) OrderClose(OrderTicket(),Lots,Ask,0,Red);
           }

        }
     }

   if (TakeProfit==0)
     {
      tpA=0;
      tpB=0;
     }
      else
     {
      tpA=Ask+(p*TakeProfit);
      tpB=Bid-(p*TakeProfit);
     }
     
   if (StopLoss==0)
     {
      slA=0;
      slB=0;
     }
      else
     {
      slA=Ask-(p*StopLoss);
      slB=Bid+(p*StopLoss);
     }
     

   if (rising)  
     {
      OrderSend(Symbol(),OP_BUY,Lots,Ask,3,slA,tpA,"1MA Buy",11123,0,White);
     }
   if (falling)
     {
      OrderSend(Symbol(),OP_SELL,Lots,Bid,3,slB,tpB,"1MA Sell",11321,0,Red);
     }

   return(0);
  }

Profitability Reports

GBP/AUD Jul 2025 - Sep 2025
0.63
Total Trades 1391
Won Trades 385
Lost trades 1006
Win Rate 27.68 %
Expected payoff -5.46
Gross Profit 13194.23
Gross Loss -20785.26
Total Net Profit -7591.03
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.50
Total Trades 149
Won Trades 21
Lost trades 128
Win Rate 14.09 %
Expected payoff -1430.73
Gross Profit 211199.80
Gross Loss -424379.00
Total Net Profit -213179.20
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.21
Total Trades 738
Won Trades 124
Lost trades 614
Win Rate 16.80 %
Expected payoff -13.31
Gross Profit 2630.30
Gross Loss -12450.50
Total Net Profit -9820.20
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.57
Total Trades 1311
Won Trades 375
Lost trades 936
Win Rate 28.60 %
Expected payoff -7.41
Gross Profit 13082.28
Gross Loss -22801.42
Total Net Profit -9719.14
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.75
Total Trades 2184
Won Trades 644
Lost trades 1540
Win Rate 29.49 %
Expected payoff -4.05
Gross Profit 26703.94
Gross Loss -35556.09
Total Net Profit -8852.15
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.14
Total Trades 517
Won Trades 113
Lost trades 404
Win Rate 21.86 %
Expected payoff -18.77
Gross Profit 1619.13
Gross Loss -11320.95
Total Net Profit -9701.82
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.90
Total Trades 3064
Won Trades 887
Lost trades 2177
Win Rate 28.95 %
Expected payoff -1.14
Gross Profit 30537.40
Gross Loss -34034.60
Total Net Profit -3497.20
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
1.02
Total Trades 3065
Won Trades 863
Lost trades 2202
Win Rate 28.16 %
Expected payoff 0.34
Gross Profit 55471.60
Gross Loss -54416.40
Total Net Profit 1055.20
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.61
Total Trades 1284
Won Trades 296
Lost trades 988
Win Rate 23.05 %
Expected payoff -7.20
Gross Profit 14584.25
Gross Loss -23834.90
Total Net Profit -9250.65
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.77
Total Trades 1955
Won Trades 591
Lost trades 1364
Win Rate 30.23 %
Expected payoff -4.92
Gross Profit 32079.69
Gross Loss -41704.89
Total Net Profit -9625.20
-100%
-50%
0%
50%
100%

Comments