Price Data Components
Series array that contains open prices of each barSeries array that contains close prices for each barSeries array that contains the highest prices of each barSeries array that contains the lowest 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
Parabolic Stop and Reverse systemRelative strength index
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
32.00 %
Total Trades 4677
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.92
Gross Profit 4333.40
Gross Loss -13334.50
Total Net Profit -9001.10
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
32.00 %
Total Trades 3303
Won Trades 918
Lost trades 2385
Win Rate 0.28 %
Expected payoff -2.73
Gross Profit 4207.40
Gross Loss -13209.70
Total Net Profit -9002.30
-100%
-50%
0%
50%
100%
SAR_RSI_1H
//+------------------------------------------------------------------+
//|                                                         MTS                                |
//|                                              Goal: Follow SAR with RSI         |
//|                                              Timeframe: Start with H1          |
//|                                              Author: FrankC                          |
//+---------------------------------------------------------------------------+

extern double TakeProfit = 40;
extern double Lots = 1;
extern double TrailingStop = 20;
extern double StopLoss = 40;
//+------------------------------------------------------------------+
//|                                                                                    |
//+------------------------------------------------------------------+
int start()
  {
   int cnt, ticket, total,CurrentTrades=0;
   int risk=3;
   double O,C,H,L,O1,C1,H1,L1,O2,C2,H2,L2,sl,sarNow,sarBefore,rsiNow,rsiBefore,lotMM;
   int  maxTrades=6, maxTradesPerPair=1;
   double marg=2*Point;
   datetime prevtime=0;
     
// initial data checks

   if(Bars<100)
     {
      Print("bars less than 100");
      return(0);  
     }
   if(TakeProfit<10)
     {
      Print("TakeProfit less than 10");
      return(0);  // check TakeProfit
     }
     
//Define the beginning of a new bar
if(prevtime == Time[0]) return(0);
prevtime = Time[0];

     sarNow = iSAR(NULL,0,0.05,0.5,0);
     sarBefore = iSAR(NULL,0,0.05,0.5,1);
     rsiNow = iRSI(NULL,0,14,PRICE_CLOSE,0);
     rsiBefore = iRSI(NULL,0,14,PRICE_CLOSE,1);

	  O=iOpen(NULL,0,0);   
	  C=iClose(NULL,0,0);
	  H=iHigh(NULL,0,0);
	  L=iLow(NULL,0,0);
	  
	  O1=iOpen(NULL,0,1);
	  C1=iClose(NULL,0,1);
	  H1=iHigh(NULL,0,1);
	  L1=iLow(NULL,0,1);
	  
	  O2=iOpen(NULL,0,2);
	  C2=iClose(NULL,0,2);
	  H2=iHigh(NULL,0,2);
	  L2=iLow(NULL,0,2);

// ==================================================  ===============================
// PYRAMIDING - LINEAR
// Money Management risk exposure compounding
// ==================================================  ===============================
  lotMM = (MathCeil(AccountBalance() * risk / 10000) / 10);

  if (lotMM < 0.1) lotMM = Lots;
  if (lotMM > 1.0) lotMM = MathCeil(lotMM);


//============ Check for open orders =====================================
 total=OrdersTotal();
 
 if (total < 6)
 {
 for(cnt=0;cnt<total||total<1;cnt++)
  {
   OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
   if(OrderSymbol() != Symbol())
    {
 
    if(AccountFreeMargin()<(1000*Lots))
     {
      Print("We have no money. Free Margin = ", AccountFreeMargin());
      return(0);  
     }      
// ===== check for long position (BUY) possibility

      if((C > sarBefore+marg) && (rsiNow > 50) && (rsiNow > rsiBefore) && (sarNow < O)) 
       {
         ticket=OrderSend(Symbol(),OP_BUY,lotMM,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"MTS",86731,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES  ))  Comment("BUY order opened : ",OrderOpenPrice());
           }
         else Print("Error opening BUY order : ",GetLastError()); 
         return(0); 
        }  // end of if for BUY position
       
        
// ===== check for short position (SELL) possibility

      if((C < sarBefore+marg) && (rsiNow < 50) && (rsiNow < rsiBefore) && (sarNow > O))
        {
         ticket=OrderSend(Symbol(),OP_SELL,lotMM,Bid,3,Ask+  StopLoss*Point,Bid-TakeProfit*Point,"MTS",86731,0,Red);  
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES  )) Comment("SELL order opened : ",OrderOpenPrice());
           }
         else Print("Error opening SELL order : ",GetLastError()); 
         return(0); 
        } // end of if for SHORT position
              
      return(0); 
  }        
 } 
} // end of it total < 6
    
//============ ORDER MANAGEMENT ===============================

   for(cnt=0;cnt<total||total<1;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol() == Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // long position is opened
           {
            // should it be closed?
            if((C < sarBefore+marg) || (rsiNow < 50))
                {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet)  ; // close position
                 return(0); // exit
                }
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
         else // go to short position
           {
            // should it be closed?
            if((C > sarBefore+marg) || (rsiNow > 50))
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet)  ; // close position
               return(0); // exit
              }
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           } 
          }
        }
   return(0);
 
} // end of int start() 

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---