Navigation:Home > Content >

Tral.mq4

Time: 2013-02-07 | Download file:Tral.mq4

//+------------------------------------------------------------------+
//|                Trailing Stop   "разнокалиберный"                 |
//+------------------------------------------------------------------+
extern int StopLoss  = 50; // 
extern int Trailing  = 50; //кол-во пунктов для трала
extern int SafeMoney = 20; //кол-во пунктов для безубытка

int init ()  { return(0); }
int deinit() { return(0); }

int start()
{
  double SLoss;

  for(int cnt=0; cntOrderOpenPrice()+SafeMoney*Point && (OrderStopLoss()<=OrderOpenPrice() || OrderStopLoss()==0))
        { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point,OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }

        if(Trailing!=0)
        {
 					SLoss=Bid-Trailing*Point;
 					if(SLoss>OrderOpenPrice() && SLoss>OrderStopLoss()+Point)
          { OrderModify(OrderTicket(),OrderOpenPrice(),SLoss,OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }
				}
			}

      if(OrderType()==OP_SELL)
      {
        if(SafeMoney!=0 && Ask=OrderOpenPrice() || OrderStopLoss()==0))
        { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point,OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }

        if(Trailing!=0)
        {
 					SLoss=Ask+Trailing*Point;
 					if(SLoss        

Recommend