← Назад к списку файлов

firebird v0.63 [ea].mq4

Поиск по коду файла

extern int MA_length = 10;
extern int MA_timeframe = 30;              // hdb did I add this ? lol
extern int MAtype=0;//0=close, 1=HL		 
extern double Percent = 0.1;
extern int TradeOnFriday =1; // >0 trades on friday
extern int slip = 100;//exits only
extern double Lots = 1;
extern int TakeProfit = 30;
extern int Stoploss = 2000;// total loss on all open positions in pips

extern int PipStep = 30;//if position goes this amount of pips against you add another.
extern double IncreasementType =0;//0=just add every PipStep,  >0 =OrdersToal()^x *Pipstep
extern int MagicNumber=12345;

double Stopper=0;
double KeepStopLoss=0;
double KeepAverage;
double dummy;
double spread=0;
double CurrentPipStep;
int    OrderWatcher=0;

int start()
{
      // код доступен только после оплаты
   }
double PriceTarget;
double AveragePrice;
int OpeningDay;

CurrentPipStep=PipStep;
if(IncreasementType>0)
  {
  CurrentPipStep=MathSqrt(OrdersTotal())*PipStep;
  CurrentPipStep=MathPow(OrdersTotal(),IncreasementType)*PipStep;
  } 

int Direction=0;//1=long, 11=avoid long, 2=short, 22=avoid short
if (Day()!=5 || TradeOnFriday >0)
{
   int cnt=0, total;
   int myTotal =0;                     // hdb
   total=OrdersTotal();
   if(total==0) OpeningDay=DayOfYear();

    for(cnt=0;cnt<total;cnt++)
     {
     if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==MagicNumber) )    // hdb - only symbol and magic 
      {
       OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
       double LastPrice=OrderOpenPrice();
       myTotal = myTotal +1;           // hdb - count of relevant trades
      }
    }

datetime orderclosetime;
string   rightnow;
int      rightnow2;
int      TheHistoryTotal=HistoryTotal();
int      difference;
int      flag=0;
   for(cnt=0;cnt<TheHistoryTotal;cnt++) 
    {
    if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)==true)
       {
        if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==MagicNumber) )       // hdb - only symbol and magic 
            {
               orderclosetime=OrderCloseTime();
               rightnow=Year()+"-"+Month()+"-"+Day()+" "+Hour()+":"+Minute()+":"+Seconds();
               rightnow2=StrToTime(rightnow);
               difference=rightnow2-orderclosetime;
               if(Period()*60*2>difference) 
                  { // At least 2 periods away!
                   flag=1;   // Throw a flag
                   break;
                  }
              }
         }
     }

if(flag!=1) 
{   

OrderWatcher=0;

total=OrdersTotal();  
for(cnt=(total-1);cnt>=0;cnt--){
   OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

   if ( OrderSymbol()==Symbol()) // && (OrderMagicNumber()==MagicNumber) )  // hdb - only symbol and magic
   {
           LastPrice=OrderOpenPrice();
           Comment("LastPrice= ",DoubleToStr(LastPrice, 10));

           break;
    } 
}

if(MAtype==0)
   {

   double myMA =iMA(NULL,MA_timeframe,MA_length,0,MODE_SMA,PRICE_OPEN,0);

   if((myMA*(1+Percent/100))<Bid && Direction!=22 && (Bid>=(LastPrice+(CurrentPipStep*Point))||total==0)) // Go SHORT -> Only sell if >= 30 pips above previous position entry	
 	  {
      OrderSend(Symbol(),OP_SELL,Lots,Bid,slip,Bid+(Stoploss*Point),Bid-(TakeProfit*Point),0,0,Red);
      OrderWatcher=1;
      Direction=2;
     }   
   if((myMA*(1-Percent/100))>Ask && Direction!=11 && (Ask<=(LastPrice-(CurrentPipStep*Point))||total==0)) // Go LONG -> Only buy if >= 30 pips below previous position entry	 
     {
      OrderSend(Symbol(),OP_BUY,Lots,Ask,slip,Ask-(Stoploss*Point),Ask+(TakeProfit*Point),0,0,Blue);
      OrderWatcher=1;
      Direction=1;
     } 
   }     

if(MAtype==1)
  {
   if((iMA(NULL,MA_timeframe,MA_

Показано первые 50% кода (символов: 5384)

Как получить полную версию?

Введите ваш email и нажмите кнопку, чтобы перейти к оплате.