MAcross-EXP

Price Data Components
Series array that contains open time of 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
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
49.00 %
Total Trades 455
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -13.47
Gross Profit 5857.00
Gross Loss -11986.00
Total Net Profit -6129.00
-100%
-50%
0%
50%
100%
MAcross-EXP
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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 = "MAcross";
datetime OrderTime;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init ()  { return(0); }
int deinit() { Comment(""); return(0); }

int start()
{
  double Dn,Up;
  double PriceBuyOrder,StopLossBuyOrder,TimeOpenBuyOrder,PriceSelOrder,StopLossSelOrder,TimeOpenSelOrder,PriceBuy,PriceSel,PriceOrder;
  double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)*Point;
  int ticket,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(); StopLossBuyOrder=OrderStopLoss(); TimeOpenBuyOrder=OrderOpenTime(); if(TimeOpenBuyOrder>OrderTime) OrderTime=TimeOpenBuyOrder; }
      if(OrderType()==OP_SELLSTOP) { OrderSel++; TicketSelOrder=OrderTicket(); PriceSelOrder=OrderOpenPrice(); StopLossSelOrder=OrderStopLoss(); TimeOpenSelOrder=OrderOpenTime(); if(TimeOpenSelOrder>OrderTime) OrderTime=TimeOpenSelOrder; }
      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 && Time[0]>OrderTime+Period()*60)
  {
    if(Up!=0 && OrderBuy==0 && PosBuy==0)
    {
      PriceOrder=High[1]+OrderPoint*Point+(Ask-Bid);
      if(Ask>PriceOrder-StopLevel) PriceOrder=Ask+OrderPoint*Point+(Ask-Bid);
      ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,PriceOrder,3,Low[1]-OrderPoint*Point,PriceOrder+TakeProfit*Point,"BuyOrder_ASC",255,0,CLR_NONE);
      if(ticket!=0)
      {
        OrderTime=Time[0];
        PlaySound("expert.wav");
      }
      return(0);
    }

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

  for(cnt=0; cnt<OrdersTotal(); cnt++)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()==Symbol())
    {
      if(OrderBuy!=0 && OrderSel!=0)
      {
        if(TimeOpenBuyOrder<TimeOpenSelOrder) { OrderDelete(TicketBuyOrder); return(0); }
        if(TimeOpenBuyOrder>TimeOpenSelOrder) { OrderDelete(TicketSelOrder); return(0); }
      }

      if(OrderType()==OP_BUY)
      {
	      if(SafePoint!=0 && Bid>OrderOpenPrice()+SafePoint*Point && (OrderStopLoss()<OrderOpenPrice() || OrderStopLoss()==0))
       	{ ModifyStopLoss(OrderOpenPrice()+Point); return(0); }

       	if(OrderSel!=0)
       	{
         	if(Bid>StopLossSelOrder)
         	{ OrderDelete(TicketSelOrder); PlaySound("expert.wav"); return(0); }

       	  if(SafePoint==0 && OrderStopLoss()!=PriceSelOrder)
         	{ ModifyStopLoss(PriceSelOrder); return(0); }
        }
	      else if(OrderStopLoss()>OrderOpenPrice() && OrderStopLoss()<Bid-TrailingStop*Point)
       	{ ModifyStopLoss(Bid-TrailingStop*Point); PlaySound("expert.wav"); return(0); }
      }

      if(OrderType()==OP_SELL)
      {
	      if(SafePoint!=0 && Ask<OrderOpenPrice()-SafePoint*Point && (OrderStopLoss()>OrderOpenPrice() || OrderStopLoss()==0))
       	{ ModifyStopLoss(OrderOpenPrice()-Point); return(0); }

       	if(OrderBuy!=0)
       	{
         	if(Ask<StopLossBuyOrder)
         	{ OrderDelete(TicketBuyOrder); PlaySound("expert.wav"); return(0); }

       	  if(SafePoint==0 && OrderStopLoss()!=PriceBuyOrder)
         	{ ModifyStopLoss(PriceBuyOrder); PlaySound("expert.wav"); return(0); }
        }
        else if(OrderStopLoss()<OrderOpenPrice() && OrderStopLoss()>Ask+TrailingStop*Point) 
       	{ ModifyStopLoss(Ask+TrailingStop*Point); PlaySound("expert.wav"); return(0); }
   		}
 	 	}
	}
	
  return(0);
}
//************************************************************************************************
void ModifyStopLoss(double StopLoss)
{
  OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(StopLoss,Digits),OrderTakeProfit(),0,CLR_NONE);
  PlaySound("expert.wav");
  return(0);
}
//************************************************************************************************

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 ---