ASC_EXP_v1[1][1].0-H1





//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
extern double Lots = 1.0;
extern int    OrderPoint = 5;
extern int    SafePoint = 15;
extern int    TakeProfit = 30;
//extern int    StopLoss = 0;
extern int    TrailingStop = 25;
extern string IndicatorName = "ASCTrend1sig";
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init ()  { return(0); }
int deinit() { Comment(""); return(0); }

int start()
{
  double Dn,Up;
  double PriceBuyOrder,PriceSelOrder,PriceBuy,PriceSel,PriceOrder;
  int TicketBuyOrder,TicketSelOrder;
  int i,cnt,SLoss,Order,OrderBuy,OrderSel,Pos,PosBuy,PosSel;

  Order=0; OrderBuy=0; OrderSel=0; Pos=0; PosBuy=0; PosSel=0;
  TicketBuyOrder=0; TicketSelOrder=0; PriceBuyOrder=0; PriceSelOrder=0; PriceBuy=0; PriceSel=0;
  for(cnt=0; cnt<OrdersTotal(); cnt++)
  {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_BUYSTOP)  { OrderBuy++; TicketBuyOrder=OrderTicket(); PriceBuyOrder=OrderOpenPrice(); }
      if(OrderType()==OP_SELLSTOP) { OrderSel++; TicketSelOrder=OrderTicket(); PriceSelOrder=OrderOpenPrice(); }
      if(OrderType()==OP_BUY)      { PosBuy++; PriceBuy=OrderOpenPrice(); }
      if(OrderType()==OP_SELL)     { PosSel++; PriceSel=OrderOpenPrice(); }
    }
  }
  Order = OrderBuy+OrderSel;
  Pos = PosBuy+PosSel;

  Dn=iCustom(NULL,0,IndicatorName,0,1);
  Up=iCustom(NULL,0,IndicatorName,1,1);

	if(Order<2 /*&& Pos<2*/)
  {
    if(Up!=0 && OrderBuy==0 /*&& PosBuy==0*/)
    {
      PriceOrder=High[1]+OrderPoint*Point+(Ask-Bid);
      OrderSend(Symbol(),OP_BUYSTOP,Lots,PriceOrder,3,Low[1]-OrderPoint*Point,PriceOrder+TakeProfit*Point,"BuyOrder",255,0,CLR_NONE);
      PlaySound("expert.wav");
      return(0);
    }

    if(Dn!=0 && OrderSel==0 /*&& PosSel==0*/)
    {
      PriceOrder=Low[1]-OrderPoint*Point;
      OrderSend(Symbol(),OP_SELLSTOP,Lots,PriceOrder,3,High[1]+OrderPoint*Point+(Ask-Bid),PriceOrder-TakeProfit*Point,"SelOrder",255,0,CLR_NONE);
      PlaySound("expert.wav");
      return(0);
    }
  }

  for(cnt=0; cnt<OrdersTotal(); cnt++)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_BUY)
      {
	      if(SafePoint!=0 && Bid>OrderOpenPrice()+SafePoint*Point && (OrderStopLoss()<OrderOpenPrice() || OrderStopLoss()==0))
       	{ OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point,OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }

       	if(OrderSel!=0 && OrderStopLoss()!=PriceSelOrder && OrderStopLoss()<OrderOpenPrice())
       	{ OrderModify(OrderTicket(),OrderOpenPrice(),PriceSelOrder,OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }

       	if(OrderSel!=0 && OrderStopLoss()>OrderOpenPrice()+2*Point)
       	{ OrderDelete(TicketSelOrder); PlaySound("expert.wav"); return(0); }

	      if(OrderStopLoss()>OrderOpenPrice() && OrderStopLoss()<Bid-TrailingStop*Point)
       	{ OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-TrailingStop*Point,Digits),OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }
      }

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

       	if(OrderBuy!=0 && OrderStopLoss()!=PriceBuyOrder && OrderStopLoss()>OrderOpenPrice())
       	{ OrderModify(OrderTicket(),OrderOpenPrice(),PriceBuyOrder,OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }

       	if(OrderBuy!=0 && OrderStopLoss()<OrderOpenPrice()-2*Point)
       	{ OrderDelete(TicketBuyOrder); PlaySound("expert.wav"); return(0); }

        if(OrderStopLoss()<OrderOpenPrice() && OrderStopLoss()>Ask+TrailingStop*Point) 
       	{ OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+TrailingStop*Point,Digits),OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }
   		}
 	 	}
	}
	
  return(0);
}





Sample





Analysis



Market Information Used:

Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:


Indicators Used:




Custom Indicators Used:
IndicatorName

Order Management characteristics:
Checks for the total of open orders

It automatically opens orders when conditions are reached
It can change open orders parameters, due to possible stepping strategy

Other Features:

It plays sound alerts