SupportResistTrade

Author: Copyright � 2008, Gryb Alexander
Profit factor:
0.36
Price Data Components
Series array that contains the lowest prices of each barSeries array that contains the highest prices of each bar
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
Indicators Used
Moving average indicator
7 Views
0 Downloads
0 Favorites
SupportResistTrade
//+------------------------------------------------------------------+
//|                                           SupportResistTrade.mq4 |
//|                                 Copyright © 2008, Gryb Alexander |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Gryb Alexander"
#property link      ""

extern int numBars = 55;

extern int maPeriod = 500;


double support;
double resist;
string trendType;
int timeFrame = 1;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
    ObjectCreate("lineSupport",OBJ_HLINE,0,0,0);
    ObjectSet("lineSupport",OBJPROP_COLOR,Blue);
    
    ObjectCreate("lineResist",OBJ_HLINE,0,0,0);
    ObjectSet("lineResist",OBJPROP_COLOR,Red);
    
    ObjectCreate("lblTrendType",OBJ_LABEL,0,0,0,0,0);
    ObjectSet("lblTrendType",OBJPROP_XDISTANCE,50);
    ObjectSet("lblTrendType",OBJPROP_YDISTANCE,50);
    ObjectSetText("lblTrendType","TrendType",14,"Tahoma",Red);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
    ObjectsDeleteAll();
    
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
  MarketAnalize();
  if(OrdersTotal()==0)
   CheckForOpen();
  else
   CheckForClose();
//----
   return(0);
  }

void MarketAnalize()
{
  // Îïðåäåëÿåì ëèíèè ïîääåðæêè\ñîïðîòèâëåíèÿ
  support = 10000;
  resist = 0;  
  for(int k = 1;k<=numBars;k++)
  {
   if(support>iLow(Symbol(),timeFrame,k))
     support = iLow(Symbol(),timeFrame,k);
   if(resist<iHigh(Symbol(),timeFrame,k))
     resist = iHigh(Symbol(),timeFrame,k);
  }   
  ObjectSet("lineSupport",OBJPROP_PRICE1,support);
  ObjectSet("lineResist",OBJPROP_PRICE1,resist);
  
  // Îïðåäåëÿåì ñîñòîÿíèå ðûíêà: ìåäâåäè èëè áûêè
  double ma = iMA(Symbol(),0,maPeriod,0,MODE_EMA,PRICE_OPEN,0);
  
  if(Open[0]>ma)
  {
    trendType = "bullish";
  }
  if(Open[0]<ma)
  {
    trendType = "bearish";
  }
  

  ObjectSetText("lblTrendType",trendType);
  
  //Èòîãî: åñòü ëèíèè ïîääåðæêè\ñîïðîòèâëåíèÿ
  //       îïðåäåëåíî ñîñòîÿíèå ðûíêà(áû÷èé\ìåäâåæèé)
}

void CheckForOpen()
{

  if(trendType=="bullish")
  {
    if(Ask>resist) OrderSend(Symbol(),OP_BUY,1,Ask,3,support,0);
  }
  if(trendType=="bearish")
  {
    if(Bid<support)  OrderSend(Symbol(),OP_SELL,1,Bid,3,resist,0);
  }
}
void CheckForClose()
{
 OrderSelect(0,SELECT_BY_POS);
 if(OrderProfit()>0)
 {
   if(OrderType()==OP_BUY)
   {
     if(Bid<support) OrderClose(OrderTicket(),OrderLots(),Bid,3);
   }
   if(OrderType()==OP_SELL)
   { 
      if(Ask>resist)  OrderClose(OrderTicket(),OrderLots(),Ask,3);
   }
 }
//Trailing
 if(OrderType()==OP_BUY)
 {
   if((Ask>OrderOpenPrice()+Point*20)&&(OrderStopLoss()<(OrderOpenPrice()+Point*10)))
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point*10,OrderTakeProfit(),0,Blue);
   if((Ask>OrderOpenPrice()+Point*40)&&(OrderStopLoss()<(OrderOpenPrice()+Point*20)))
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point*20,OrderTakeProfit(),0,Blue);    
   if((Ask>OrderOpenPrice()+Point*60)&&(OrderStopLoss()<(OrderOpenPrice()+Point*30)))
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point*30,OrderTakeProfit(),0,Blue);
 }
 if(OrderType()==OP_SELL)
 {
   if((Bid<OrderOpenPrice()-Point*20)&&(OrderStopLoss()>(OrderOpenPrice()-Point*10)))
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point*10,OrderTakeProfit(),0,Blue);     
   if((Bid<OrderOpenPrice()-Point*40)&&(OrderStopLoss()>(OrderOpenPrice()-Point*20)))
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point*20,OrderTakeProfit(),0,Blue);     
   if((Bid<OrderOpenPrice()-Point*60)&&(OrderStopLoss()>(OrderOpenPrice()-Point*30)))
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point*30,OrderTakeProfit(),0,Blue);     
 }
}
//+------------------------------------------------------------------+

Profitability Reports

USD/CAD Oct 2024 - Jan 2025
2.51
Total Trades 180
Won Trades 179
Lost trades 1
Win Rate 99.44 %
Expected payoff 5.63
Gross Profit 1686.58
Gross Loss -672.42
Total Net Profit 1014.16
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.76
Total Trades 108
Won Trades 99
Lost trades 9
Win Rate 91.67 %
Expected payoff -3.23
Gross Profit 1080.00
Gross Loss -1429.00
Total Net Profit -349.00
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.69
Total Trades 120
Won Trades 112
Lost trades 8
Win Rate 93.33 %
Expected payoff -4.30
Gross Profit 1130.00
Gross Loss -1646.00
Total Net Profit -516.00
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.58
Total Trades 1276
Won Trades 1132
Lost trades 144
Win Rate 88.71 %
Expected payoff -7.64
Gross Profit 13567.87
Gross Loss -23317.92
Total Net Profit -9750.05
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.53
Total Trades 246
Won Trades 241
Lost trades 5
Win Rate 97.97 %
Expected payoff -9.20
Gross Profit 2510.00
Gross Loss -4774.00
Total Net Profit -2264.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.50
Total Trades 249
Won Trades 242
Lost trades 7
Win Rate 97.19 %
Expected payoff -10.37
Gross Profit 2540.00
Gross Loss -5121.00
Total Net Profit -2581.00
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.43
Total Trades 638
Won Trades 479
Lost trades 159
Win Rate 75.08 %
Expected payoff -15.38
Gross Profit 7256.00
Gross Loss -17068.00
Total Net Profit -9812.00
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.43
Total Trades 657
Won Trades 530
Lost trades 127
Win Rate 80.67 %
Expected payoff -14.73
Gross Profit 7201.00
Gross Loss -16877.00
Total Net Profit -9676.00
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.43
Total Trades 781
Won Trades 633
Lost trades 148
Win Rate 81.05 %
Expected payoff -12.49
Gross Profit 7320.44
Gross Loss -17072.39
Total Net Profit -9751.95
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.41
Total Trades 293
Won Trades 271
Lost trades 22
Win Rate 92.49 %
Expected payoff -10.27
Gross Profit 2087.11
Gross Loss -5096.19
Total Net Profit -3009.08
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.38
Total Trades 601
Won Trades 447
Lost trades 154
Win Rate 74.38 %
Expected payoff -16.35
Gross Profit 5911.00
Gross Loss -15737.00
Total Net Profit -9826.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.36
Total Trades 309
Won Trades 296
Lost trades 13
Win Rate 95.79 %
Expected payoff -17.40
Gross Profit 2970.00
Gross Loss -8348.00
Total Net Profit -5378.00
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.35
Total Trades 447
Won Trades 332
Lost trades 115
Win Rate 74.27 %
Expected payoff -21.27
Gross Profit 5157.59
Gross Loss -14663.09
Total Net Profit -9505.50
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.32
Total Trades 298
Won Trades 210
Lost trades 88
Win Rate 70.47 %
Expected payoff -32.30
Gross Profit 4619.00
Gross Loss -14245.00
Total Net Profit -9626.00
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.32
Total Trades 245
Won Trades 220
Lost trades 25
Win Rate 89.80 %
Expected payoff -14.15
Gross Profit 1656.02
Gross Loss -5122.09
Total Net Profit -3466.07
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.31
Total Trades 228
Won Trades 221
Lost trades 7
Win Rate 96.93 %
Expected payoff -17.52
Gross Profit 1780.07
Gross Loss -5775.26
Total Net Profit -3995.19
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.28
Total Trades 154
Won Trades 140
Lost trades 14
Win Rate 90.91 %
Expected payoff -30.87
Gross Profit 1856.05
Gross Loss -6609.56
Total Net Profit -4753.51
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.26
Total Trades 159
Won Trades 144
Lost trades 15
Win Rate 90.57 %
Expected payoff -34.78
Gross Profit 1966.46
Gross Loss -7495.76
Total Net Profit -5529.30
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.25
Total Trades 379
Won Trades 319
Lost trades 60
Win Rate 84.17 %
Expected payoff -25.40
Gross Profit 3171.38
Gross Loss -12797.49
Total Net Profit -9626.11
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.24
Total Trades 212
Won Trades 202
Lost trades 10
Win Rate 95.28 %
Expected payoff -23.67
Gross Profit 1555.87
Gross Loss -6573.49
Total Net Profit -5017.62
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.18
Total Trades 222
Won Trades 178
Lost trades 44
Win Rate 80.18 %
Expected payoff -43.59
Gross Profit 2126.00
Gross Loss -11802.00
Total Net Profit -9676.00
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.15
Total Trades 203
Won Trades 167
Lost trades 36
Win Rate 82.27 %
Expected payoff -39.98
Gross Profit 1473.77
Gross Loss -9590.23
Total Net Profit -8116.46
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.10
Total Trades 111
Won Trades 49
Lost trades 62
Win Rate 44.14 %
Expected payoff -86.71
Gross Profit 1104.48
Gross Loss -10729.83
Total Net Profit -9625.35
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.04
Total Trades 109
Won Trades 40
Lost trades 69
Win Rate 36.70 %
Expected payoff -85.03
Gross Profit 390.74
Gross Loss -9659.44
Total Net Profit -9268.70
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.02
Total Trades 12
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -372.67
Gross Profit 110.00
Gross Loss -4582.00
Total Net Profit -4472.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.01
Total Trades 4
Won Trades 3
Lost trades 1
Win Rate 75.00 %
Expected payoff -1412.50
Gross Profit 50.00
Gross Loss -5700.00
Total Net Profit -5650.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.01
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 66.67 %
Expected payoff -983.67
Gross Profit 20.00
Gross Loss -2971.00
Total Net Profit -2951.00
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.01
Total Trades 65
Won Trades 10
Lost trades 55
Win Rate 15.38 %
Expected payoff -148.56
Gross Profit 79.17
Gross Loss -9735.84
Total Net Profit -9656.67
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.01
Total Trades 100
Won Trades 7
Lost trades 93
Win Rate 7.00 %
Expected payoff -96.65
Gross Profit 78.58
Gross Loss -9743.72
Total Net Profit -9665.14
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 181
Won Trades 146
Lost trades 35
Win Rate 80.66 %
Expected payoff -5836.23
Gross Profit 1770.00
Gross Loss -1058128.00
Total Net Profit -1056358.00
-100%
-50%
0%
50%
100%

Comments