SupportResistTrader

Author: Copyright � 2008, Gryb Alexander
Profit factor:
0.35
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
9 Views
1 Downloads
0 Favorites
SupportResistTrader

//+------------------------------------------------------------------+
//|                                           SupportResistTrade.mq4 |
//|                                 Copyright © 2008, Gryb Alexander |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Gryb Alexander"
#property link      ""
 
extern int numBars  = 55;
extern int maPeriod = 500;
extern int Lots     = 1;
extern double   TrailingStop = 5;
 
 
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,Lots,Ask,3,support,0);
  }
  if(trendType=="bearish")
  {
    if(Bid<support)  OrderSend(Symbol(),OP_SELL,Lots,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

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%
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%
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%
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%
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%
AUD/USD Jul 2025 - Sep 2025
0.39
Total Trades 340
Won Trades 327
Lost trades 13
Win Rate 96.18 %
Expected payoff -14.96
Gross Profit 3280.00
Gross Loss -8367.00
Total Net Profit -5087.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.22
Total Trades 198
Won Trades 188
Lost trades 10
Win Rate 94.95 %
Expected payoff -25.79
Gross Profit 1466.39
Gross Loss -6572.78
Total Net Profit -5106.39
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.60
Total Trades 1332
Won Trades 1180
Lost trades 152
Win Rate 88.59 %
Expected payoff -7.32
Gross Profit 14385.17
Gross Loss -24140.81
Total Net Profit -9755.64
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.26
Total Trades 144
Won Trades 130
Lost trades 14
Win Rate 90.28 %
Expected payoff -33.94
Gross Profit 1730.64
Gross Loss -6618.00
Total Net Profit -4887.36
-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%

Comments