Author: xxx
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Moving average indicator
1 Views
0 Downloads
0 Favorites
TrendS
//+------------------------------------------------------------------+
//|                                                       TrendS.mq4 |
//|                                      Copyright © 2006, xxx |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "xxx"
#property link      "http://www.xxx.ru/"


extern double    LotsIfNoMM=0.1;
extern int       StopLoss=50;
extern int       Slip=5;
extern int       MM_Mode=0;
extern int       MM_Risk=40;

double Opentrades,orders,first,mode,Ilo,sym,b,tmp,GridCellPoint,OpenOrderStopLoss;
double b4signal,Signal,Triggerline,b4Triggerline,Nowsignal,NowTriggerline,sl,LastOpByExpert,LastBarChecked;
int cnt,cnt2,OpenPosition,notouchbar,PendingOrderTicket,OpenOrderTicket; 
bool test;


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//---- 


//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  
//return(0);
   
   //if ( ! IsTesting() ) Comment(" Trailingstop    ",  b, "\n","      Tick no. ", iVolume(NULL,0,0),"\n"," Lots    ",Ilo);


  

   if (MM_Mode < 0)  {
   Ilo = MathCeil(AccountBalance()*MM_Risk/10000)/10;
     if (Ilo > 100) {  
     Ilo = 100;  
     }
   } else {
   Ilo = LotsIfNoMM;
   }
   if (MM_Mode > 0)  
    {
   Ilo = MathCeil(AccountBalance()*MM_Risk/10000)/10;
    if (Ilo > 1)  
    {
    Ilo = MathCeil(Ilo);
    }
    if (Ilo < 1)  
    {
    Ilo = 1;
    }
    if (Ilo > 100)  
    {  
     Ilo = 100;  
     }
   }
 	      
Opentrades=0;
for (cnt=0;cnt<OrdersTotal();cnt++) 
   {
   if ( OrderSelect (cnt, SELECT_BY_POS) == false )  continue;
   if ( OrderSymbol()==Symbol()) 
      {
      Opentrades=Opentrades+1;
      }
   }

if (Opentrades!=0)
   {
   if (OrderType()==OP_BUY) 
      {
      if (Bid>=iHigh(Symbol(),0,Highest(Symbol(),0,MODE_HIGH,6,1)))
         {
         OrderClose(OrderTicket(),OrderLots(),Bid,Slip,Red); 
         Opentrades--;
         }
      }
      else if (OrderType()==OP_SELL)
      {
      if (Bid<=iLow(Symbol(),0,Lowest(Symbol(),0,MODE_LOW,6,1)))
         {
         OrderClose(OrderTicket(),OrderLots(),Ask,Slip,Red); 
         Opentrades--;
         }
      }
   }

if (Opentrades==0)
   {
   
   if (iMA(Symbol(),0,6,0,MODE_EMA,PRICE_CLOSE,1)>iMA(Symbol(),0,12,0,MODE_SMA,PRICE_CLOSE,1) && Bid<=iLow(Symbol(),0,Lowest(Symbol(),0,MODE_LOW,6,1)))
      {
      OrderSend(Symbol(),OP_BUY,Ilo,Ask,Slip,Ask-StopLoss*Point,0,"CP",0,0,Blue);
      }
      
   if (iMA(Symbol(),0,6,0,MODE_EMA,PRICE_CLOSE,1)<iMA(Symbol(),0,12,0,MODE_SMA,PRICE_CLOSE,1) && Bid>=iHigh(Symbol(),0,Highest(Symbol(),0,MODE_HIGH,6,1)))
      {
      OrderSend(Symbol(),OP_SELL,Ilo,Bid,Slip,Bid+StopLoss*Point,0,"CP",0,0,Blue);
      }
  
   }

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