FT_Parabolic SAR_EMA

Author: FORTRADER.RU, ����, ftyuriy@gmail.com
Profit factor:
0.90

This script is designed to automatically trade on the foreign exchange market (Forex) using a specific set of rules. It looks at price charts to identify potential buying and selling opportunities. Here's a breakdown:

  1. What it does: The script is essentially a robot that watches the Forex market and tries to make profitable trades automatically. It makes decisions based on three things:

    • Moving Averages (EMAs): These are lines that smooth out the price data over a specific period, helping to identify trends. The script uses three different EMAs with different periods (10, 25, and 50).
    • Parabolic SAR (SAR): This is another indicator that helps identify potential trend reversals and entry/exit points. The script looks at SAR values on the current timeframe and also on a 15-minute timeframe.
    • Existing Positions: The script keeps track of open buy and sell trades it has already made.
  2. How it works:

    • Initialization: When the script starts, it sets up some initial values, like the periods for the EMAs, settings for the SAR indicators, the size of trades it will make, and limits on the maximum number of simultaneous buy and sell trades.
    • Main Loop: The script constantly runs in the background, checking the current market conditions.
    • Checking for Signals: In each cycle, the script does the following:
      • Calculate Indicators: It calculates the values of the three EMAs and the two SAR indicators using the current and historical price data.
      • Identify Buy/Sell Conditions: The script then uses a combination of conditions to determine if it should buy or sell. It compares the EMA values to determine the trend and also uses the SAR values.
      • Open Orders: If all conditions are met, the script sends a command to the trading platform to open either a buy or sell order for a specific amount of currency. The script also sets stop-loss and take-profit levels. These are price levels at which the trade will be automatically closed to limit losses or secure profits.
      • Close Orders: If the EMAs shift to an unfavorable configuration the script will proceed to close existing orders if present.
    • Position Management: The script also keeps track of how many open buy and sell orders it has. It will not open new orders if it has already reached the maximum allowed number of positions.
  3. Key parameters:

    • ema1_period, ema2_period, ema3_period: These define the lookback period for calculating the three EMAs, which are used to identify the trend.
    • stepfast, stepfast15m, maximumfast: These are settings for the Parabolic SAR indicator, influencing its sensitivity to price changes.
    • SL, TP: These define the Stop Loss and Take Profit levels, which are the number of pips (a unit of price movement) away from the opening price at which the trade will be automatically closed.
    • Lots: This determines the volume of currency to trade in each order.
    • maxpos: The script will only have this many positions of each type open, 1 is a simple approach

In summary, this script is an automated trading system that uses moving averages and Parabolic SAR indicators to generate buy and sell signals. It aims to identify trends and potential reversals, opening and closing trades automatically based on predefined rules.

Orders Execution
It automatically opens orders when conditions are reachedIt Closes Orders by itself Checks for the total of open orders
Indicators Used
Parabolic Stop and Reverse systemMoving average indicator
12 Views
0 Downloads
1 Favorites
FT_Parabolic SAR_EMA
//+------------------------------------------------------------------+
//|                                                FT_Parabolic SAR_EMA.mq4 |
//|                            FORTRADER.RU, Þðèé, ftyuriy@gmail.com |
//|                          http://FORTRADER.RU, Parabolic SAR     + Ñðåäíèå |
//+------------------------------------------------------------------+
#property copyright "FORTRADER.RU, Þðèé, ftyuriy@gmail.com"
#property link      "http://FORTRADER.RU, MACD + Parabolic SAR"

/*Ðàçðàáîòàíî äëÿ 49 âûïóñêà æóðíàëà FORTRADER.Ru. Ñèñòåìà ïî ñðåäíåé è MACD. 
Îò÷åòû: http://finfile.ru/index.php/files/get/EYLOCZ45tW/sarma2.zip, http://finfile.ru/index.php/files/get/f_rINNIekN/sarma.zip
Ñåò ôàéëû:http://finfile.ru/index.php/files/get/hKV6K515_n/sar-ma-eurusd1h.set 
Îáñóæäåíèå:http://fxnow.ru/group_discussion_view.php?group_id=49&grouptopic_id=269&grouppost_id=2682#post_2682 
Àðõèâ æóðíàëà: http://www.fortrader.ru/arhiv.php
49 âûïóñê: http://www.fortrader.ru/
*/

extern int ema1_period = 10 ; 
extern int ema2_period = 25 ; 
extern int ema3_period = 50 ; 

//íàñòðîéêè ïàðàáîëèêà
extern double stepfast=0.02; 
extern double stepfast15m=0.02; 
extern double maximumfast=0.2;

 int SL=1500;
 int TP=1500;
extern int mn=1;
int err;
extern int MG=564651;
extern double Lots=0.01;
extern int maxpos=1;

int bars;
int start()
{
  if(bars!=Bars)
  {   
      bars=Bars;
      OpenPattern();
  }
return(0);
}

int okbuy,oksell;

int OpenPattern()
  {
  double op,sl,tp;
  
   //çàãðóçèì ïàðàáîëèêè
   double fastsar=iSAR(NULL,0,stepfast,maximumfast,1);
   double fastsar15=iSAR(NULL,15,stepfast15m,maximumfast,1);
  
  double ma1=iMA(NULL,0,ema1_period,0,MODE_EMA,PRICE_CLOSE,1);
  double ma2=iMA(NULL,0,ema2_period,0,MODE_EMA,PRICE_CLOSE,1);
  double ma3=iMA(NULL,0,ema3_period,0,MODE_EMA,PRICE_CLOSE,1);
  
  if(ma1<ma2 && ma1<ma3){okbuy=1;}
  if(ma1>ma2 && ma1>ma3){oksell=1;}


  if(oksell==1 && ma1<ma2 && ma1<ma3 && fastsar>Close[1] && fastsar15>Close[1] && CountPos(0)<maxpos )
  {
   op=Bid;if(SL>0){sl=Bid+SL*Point*mn;}if(TP>0){tp=Bid-TP*Point*mn;}
   err=OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(op,Digits),3,NormalizeDouble(sl,Digits),NormalizeDouble(tp,Digits),"4 FORTRADER.RU",MG,0,Red);
   if(err<0){Print("OrderSend()-  Îøèáêà OP_SELL.  op "+op+" sl "+sl+" tp "+tp+" "+GetLastError());return(-1);}
   oksell=0;
  }
  
  if(okbuy==1 && ma1>ma2 && ma1>ma3  && fastsar<Close[1] && fastsar15<Close[1]  && CountPos(1)<maxpos )
  {
   op=Ask;if(SL>0){sl=Ask-SL*Point*mn;}if(TP>0){tp=Ask+TP*Point*mn;}
   err=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(op,Digits),3,NormalizeDouble(sl,Digits),NormalizeDouble(tp,Digits),"6 FORTRADER.RU",MG,0,Red);
   if(err<0){Print("OrderSend()-  Îøèáêà OP_BUY.  op "+op+" sl "+sl+" tp "+tp+" "+GetLastError());return(-1);}
   okbuy=0;
  }
  
  if(ma1<ma2 && ma1<ma3 ){_OrderClose(1);}
  if(ma1>ma2 && ma1>ma3){_OrderClose(0);}
  
 return(err);
 }
  
//Ïðîâåðÿåì êîëè÷åñâòî ïîçèöèé.
int CountPos(int type) 
{//Îïèñàíèå http://fxnow.ru/blog.php?user=Yuriy&blogentry_id=66

int i;
int col;
int count=0 ;
for( i=0; i<=OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS)==true)
{
if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && type==1 && OrderMagicNumber()==MG ){count++;}
if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && type==0 && OrderMagicNumber()==MG ){count++;}
}
} 
return(count);
}





int _OrderClose(int type)
   {int err;

   for(int i=1; i<=OrdersTotal(); i++)          
     {
      if (OrderSelect(i-1,SELECT_BY_POS)==true) 
        {
         if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && type==1 && OrderMagicNumber()==MG )
         {
          err=OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); 
          if(err<0){Print("OrderClose()-  Îøèáêà çàêðûòèÿ OP_BUY.  OrderTicket "+OrderTicket()+" OrderLots() "+OrderLots()+" Bid "+Bid+" "+GetLastError());return(-1);}
         }
         if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && type==0 && OrderMagicNumber()==MG)
         {
          err=OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); 
          if(err<0){Print("OrderClose()-  Îøèáêà çàêðûòèÿ OP_SELL.  OrderTicket "+OrderTicket()+" OrderLots() "+OrderLots()+" Ask "+Ask+" "+GetLastError());return(-1);}
         }
        }
       }
   return(0);
   }
   

Profitability Reports

USD/CAD Oct 2024 - Jan 2025
2.75
Total Trades 15
Won Trades 7
Lost trades 8
Win Rate 46.67 %
Expected payoff 1.73
Gross Profit 40.76
Gross Loss -14.84
Total Net Profit 25.92
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
1.52
Total Trades 59
Won Trades 22
Lost trades 37
Win Rate 37.29 %
Expected payoff 1.04
Gross Profit 179.47
Gross Loss -118.19
Total Net Profit 61.28
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
1.45
Total Trades 54
Won Trades 23
Lost trades 31
Win Rate 42.59 %
Expected payoff 1.08
Gross Profit 187.09
Gross Loss -128.88
Total Net Profit 58.21
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
1.39
Total Trades 35
Won Trades 14
Lost trades 21
Win Rate 40.00 %
Expected payoff 0.74
Gross Profit 93.20
Gross Loss -67.14
Total Net Profit 26.06
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
1.20
Total Trades 58
Won Trades 19
Lost trades 39
Win Rate 32.76 %
Expected payoff 0.50
Gross Profit 172.29
Gross Loss -143.18
Total Net Profit 29.11
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
1.14
Total Trades 27
Won Trades 8
Lost trades 19
Win Rate 29.63 %
Expected payoff 0.37
Gross Profit 78.67
Gross Loss -68.81
Total Net Profit 9.86
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.08
Total Trades 58
Won Trades 18
Lost trades 40
Win Rate 31.03 %
Expected payoff 0.14
Gross Profit 106.01
Gross Loss -97.90
Total Net Profit 8.11
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.02
Total Trades 32
Won Trades 10
Lost trades 22
Win Rate 31.25 %
Expected payoff 0.04
Gross Profit 47.24
Gross Loss -46.10
Total Net Profit 1.14
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.02
Total Trades 31
Won Trades 9
Lost trades 22
Win Rate 29.03 %
Expected payoff 0.04
Gross Profit 75.06
Gross Loss -73.95
Total Net Profit 1.11
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
1.00
Total Trades 66
Won Trades 22
Lost trades 44
Win Rate 33.33 %
Expected payoff 0.00
Gross Profit 113.32
Gross Loss -113.65
Total Net Profit -0.33
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.96
Total Trades 68
Won Trades 19
Lost trades 49
Win Rate 27.94 %
Expected payoff -0.07
Gross Profit 104.30
Gross Loss -108.98
Total Net Profit -4.68
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.95
Total Trades 64
Won Trades 19
Lost trades 45
Win Rate 29.69 %
Expected payoff -0.11
Gross Profit 121.88
Gross Loss -128.80
Total Net Profit -6.92
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.93
Total Trades 62
Won Trades 20
Lost trades 42
Win Rate 32.26 %
Expected payoff -0.07
Gross Profit 54.41
Gross Loss -58.51
Total Net Profit -4.10
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.90
Total Trades 43
Won Trades 12
Lost trades 31
Win Rate 27.91 %
Expected payoff -0.10
Gross Profit 39.74
Gross Loss -44.25
Total Net Profit -4.51
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.86
Total Trades 54
Won Trades 17
Lost trades 37
Win Rate 31.48 %
Expected payoff -0.35
Gross Profit 112.44
Gross Loss -131.26
Total Net Profit -18.82
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.85
Total Trades 47
Won Trades 17
Lost trades 30
Win Rate 36.17 %
Expected payoff -0.48
Gross Profit 129.76
Gross Loss -152.49
Total Net Profit -22.73
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.83
Total Trades 64
Won Trades 22
Lost trades 42
Win Rate 34.38 %
Expected payoff -0.28
Gross Profit 86.47
Gross Loss -104.25
Total Net Profit -17.78
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.83
Total Trades 54
Won Trades 12
Lost trades 42
Win Rate 22.22 %
Expected payoff -0.29
Gross Profit 75.84
Gross Loss -91.36
Total Net Profit -15.52
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.79
Total Trades 55
Won Trades 15
Lost trades 40
Win Rate 27.27 %
Expected payoff -0.23
Gross Profit 46.90
Gross Loss -59.68
Total Net Profit -12.78
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.77
Total Trades 35
Won Trades 13
Lost trades 22
Win Rate 37.14 %
Expected payoff -0.30
Gross Profit 35.03
Gross Loss -45.43
Total Net Profit -10.40
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.74
Total Trades 65
Won Trades 19
Lost trades 46
Win Rate 29.23 %
Expected payoff -0.81
Gross Profit 151.77
Gross Loss -204.37
Total Net Profit -52.60
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.61
Total Trades 34
Won Trades 7
Lost trades 27
Win Rate 20.59 %
Expected payoff -1.08
Gross Profit 57.57
Gross Loss -94.22
Total Net Profit -36.65
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.58
Total Trades 27
Won Trades 7
Lost trades 20
Win Rate 25.93 %
Expected payoff -0.69
Gross Profit 25.96
Gross Loss -44.50
Total Net Profit -18.54
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.56
Total Trades 70
Won Trades 19
Lost trades 51
Win Rate 27.14 %
Expected payoff -0.70
Gross Profit 62.34
Gross Loss -111.26
Total Net Profit -48.92
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.55
Total Trades 79
Won Trades 21
Lost trades 58
Win Rate 26.58 %
Expected payoff -0.89
Gross Profit 84.66
Gross Loss -154.91
Total Net Profit -70.25
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.54
Total Trades 36
Won Trades 9
Lost trades 27
Win Rate 25.00 %
Expected payoff -1.05
Gross Profit 43.84
Gross Loss -81.47
Total Net Profit -37.63
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.20
Total Trades 24
Won Trades 3
Lost trades 21
Win Rate 12.50 %
Expected payoff -3.19
Gross Profit 19.48
Gross Loss -96.07
Total Net Profit -76.59
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.10
Total Trades 18
Won Trades 2
Lost trades 16
Win Rate 11.11 %
Expected payoff -1.91
Gross Profit 4.02
Gross Loss -38.31
Total Net Profit -34.29
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.03
Total Trades 18
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -2.32
Gross Profit 1.28
Gross Loss -43.10
Total Net Profit -41.82
-100%
-50%
0%
50%
100%

Comments