Profit factor:
0.00
Price Data Components
Series array that contains close prices for each bar
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
Indicators Used
Moving average indicatorStochastic oscillator
1 Views
0 Downloads
0 Favorites
Get trend
//+------------------------------------------------------------------+
//|                                                    Get trend.mq4 |
//|                                                                  |
//|                                          http://www.fortrader.ru |
//+------------------------------------------------------------------+
#property link      "http://www.fortrader.ru"
//---- input parameters
extern int       porog = 50;
extern int       per_MA1 = 200;
extern int       per_MA2 = 200;
extern int       per_Stoh_slow = 14;
extern int       per_Stoh_fast = 14;
extern int       TakeProfit = 570;
extern int       StopLoss = 30;
extern int       TrailingStop = 200;
extern double       Lots = 0.1;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
// Îáúÿâëÿåì ïåðåìåííûå
int total, cnt;
double MA1, MA2, Stoh_slow, Stoh_fast, Stoh_fast_prew, price_M15, price_H1;
int err;

// Âû÷èñëÿåì íà÷àëüíûå ïàðàìåòðû èíäèêàòîðîâ äëÿ ïîèñêà óñëîâèé âõîäà

  MA1 = iMA(NULL,PERIOD_M15,per_MA1,8,MODE_SMMA,PRICE_MEDIAN,1);
  MA2 = iMA(NULL,PERIOD_H1,per_MA2,8,MODE_SMMA,PRICE_MEDIAN,1);
  
  Stoh_slow = iStochastic(NULL,PERIOD_M15,per_Stoh_slow,3,3,MODE_SMA,0,MODE_SIGNAL,1);
  Stoh_fast = iStochastic(NULL,PERIOD_M15,per_Stoh_fast,3,3,MODE_SMA,0,MODE_MAIN,1);
  Stoh_fast_prew = iStochastic(NULL,PERIOD_M15,per_Stoh_fast,3,3,MODE_SMA,0,MODE_MAIN,2);
  
  price_M15 = iClose(NULL,15,1);
  //Print(" price_M15 = ", price_M15);
  price_H1 = iClose(NULL,60,1);
  
  total=OrdersTotal();

  // Ïðîâåðêà ñðåäñòâ
  if(AccountFreeMargin()<(1000*Lots))
     {
       Print("We have no money. Free Margin = ", AccountFreeMargin());   
       return(0);  
     }
  
  // Ïðîâåðêà óñëîâèé äëÿ ñîâåðøåíèÿ ñäåëêè
  if(price_M15<MA1 && price_H1<MA2 && (MA1-price_M15)<=porog*Point)
     {
       if(Stoh_slow<20 && Stoh_fast<20 && Stoh_fast_prew<Stoh_slow && Stoh_fast>Stoh_slow)
          {
            Print("BUY ðàçíèöà (MA1-price_M15) = ",(MA1-price_M15)," MA1 = ", MA1," price_M15 = ", price_M15);
            OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"Ïîêóïàåì",16384,0,Green);
          }
     }

  if(price_M15>MA1 && price_H1>MA2 && (price_M15-MA1)<=porog*Point)
     {
       if(Stoh_slow>80 && Stoh_fast>80 && Stoh_fast_prew>Stoh_slow && Stoh_fast<Stoh_slow)
          {
            Print("Sell ðàçíèöà (price_M15-MA1) = ",(price_M15-MA1)," MA1 = ", MA1," price_M15 = ", price_M15);
            OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point,"Ïðîäàåì",16385,0,Red);
          }
     }
     
  for(cnt=total-1;cnt>=0;cnt--)
     {
       OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
       if(OrderType()==OP_BUY)
         {
           if(TrailingStop>0)  
             {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop) // Bid - öåíà ïîêóïêè
                 {
                   if(OrderStopLoss()<Bid-Point*TrailingStop)
                     {
                       OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
                       return(0);
                     }
                 }
             }
         }
       if(OrderType()==OP_SELL)
         {
           if(TrailingStop>0)  
             {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))  // Ask - öåíà ïðîäàæè
                 {
                   if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                     {
                       OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                       return(0);
                     }
                 }
             }
         }
  
     }

   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Profitability Reports

USD/CAD Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%

Comments