• 概述
  • 评论
  • 评论

MicroTrendCheckerMT5

MicroTrendChecker signal indicator tracks symbol price movements on the terminal chart. While there is no trend, it returns Ask levels by points value up and Bid levels by points value down.


Input Parameters

  • MaxSpread – maximum spread (it is recommended to set the parameter above the average symbol spread). The parameter is necessary for filtering spread widening during news releases.
  • *wits – first indicator parameter (positive integer value of 1 or higher);
  • *body – second indicator parameter (positive integer value of 1 or higher). In most cases, it exceeds *wits value;
  • *sense – third indicator parameter (positive integer value of 1 or higher);
  • *points – indent from the current price in points (Ask/Bid);
  • *delta – trend/flat evaluation value (fractional value of 0.001 or higher);
  • tracker – price tracking mode switcher (true/false). If true, the indicator buffers never have empty values (EMPTY_VALUE). If false, empty values usually appear in the indicator buffers during a trend, while new indicator labels on the chart are not displayed when a bar is forming.


Example of using the indicator in an Expert Advisor code

input int _MaxSpread=30;
input int     _size0=2; //*wits
input int     _size1=21;//*body
input int     _size2=2; //*sense
input int     _point=10;//*points
input double  _dlt=1;   //*delta
input bool _track=true;

int    Handle_s;     // handle of mTCheck  for sellstop_orders
double Val_s[];      // array of mTCheck for sellstop_orders
int    Handle_b;     // handle of mTCheck  for buystop_orders
double Val_b[];      // array of mTCheck for buystop_orders
//
int OnInit()
  {

   return(INIT_SUCCEEDED);
  }
//
void OnDeinit(const int reason)
  {

  }
//
void OnTick()
  {

   if(PositionsTotal()>0)TreilingPositions();

   if(PositionsTotal()<1 && OrdersTotal()<1)
     {
      YourTradeFunc(_SellStopValue());
      YourTradeFunc(_BuyStopValue());
     }

   if(PositionsTotal()<1 && OrdersTotal()>0)
     {
      ModifyOrder(_SellStopValue());
      ModifyOrder(_BuyStopValue());
     }

   if(PositionsTotal()>0 && OrdersTotal()>0)
     {
      DeleteOrders();
     }

  }
//
double _SellStopValue()
  {
   double res;
   int    i,k=Bars(Symbol(),0);

   Handle_s=iCustom(Symbol(),Period(),"microTrendChecker",_MaxSpread,_size0,_size1,_size2,_point,_dlt,_track);
   if(Handle_s<0)
     {
      Print("Error: ",GetLastError());
     }
   ArraySetAsSeries(Val_s,true);
   CopyBuffer(Handle_s,1,0,100,Val_s);

   for(i=0; i<k; i++)
     {
      res=Val_s[i];

      if(res!=EMPTY_VALUE)
        {
         return(res);
        }
     }
   return(0);
  }
//
double _BuyStopValue()
  {
   double res;
   int    i,k=Bars(Symbol(),0);

   Handle_b=iCustom(Symbol(),Period(),"microTrendChecker",_MaxSpread,_size0,_size1,_size2,_point,_dlt,_track);
   if(Handle_b<0)
     {
      Print("Error: ",GetLastError(),"!!");
     }
   ArraySetAsSeries(Val_b,true);
   CopyBuffer(Handle_b,0,0,100,Val_b);

   for(i=0; i<k; i++)
     {
      res=Val_b[i];

      if(res!=EMPTY_VALUE)
        {
         return(res);
        }
     }
   return(0);
  }


Additionally

The indicator is used in USDCatch Expert Advisor.

无评论