Download MetaTrader 5
To add comments, please log in or register
All activity at MQL5.community is clearly visible. Have a look at the Wall!
alisahin
38
alisahin 2014.12.12 16:34 
//+------------------------------------------------------------------+
//|                                                       helebi.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
bool al=false;
int alim,sat;
datetime zaman;

int i;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+

void karsilastir(double onbesortalama,double birortalama,double yediortalama,double onyediortalama,double onbesortalama2,double birortalama2,double yediortalama2,double onyediortalama2)
{

if(birortalama>onbesortalama && yediortalama>onyediortalama && yediortalama2<=onyediortalama2 && birortalama2<=onbesortalama2 && al==true )
  {
   OrderClose(sat,0.01,Ask,0,Red);
   alim=OrderSend(NULL,OP_BUY,0.01,PRICE_CLOSE,1,0,0,"aldim",0,0,Blue);
   al=false;
  
  }


if(birortalama<onbesortalama && yediortalama<onyediortalama && yediortalama2>=onyediortalama2 && birortalama2>=onbesortalama2 && al==false )
  {
   OrderClose(alim,0.01,Bid,0,Blue);
   sat=OrderSend(NULL,OP_SELL,0.01,PRICE_CLOSE,1,0,0,"sattim",0,0,Red);
   al=true;
   
  }



}








void acilis()
         {
         double toplam=0,onbesortalama,birortalama,yediortalama,onyediortalama,a,onbesortalama2,birortalama2,yediortalama2,onyediortalama2;
         for(i=15;i>0;i--)
         toplam=toplam+Close[i];
          
         onbesortalama=toplam/15.0; 
          toplam=0;  
          
          for( i=1;i>0;i--)
          toplam=toplam+Close[i];
           
           birortalama=toplam/1.0;
           toplam=0;
          
          for(i=7;i>0;i--)
            toplam=toplam+Close[i];
            
            yediortalama=toplam/7.0;
            toplam=0;
            for( i=17;i>0;i--)
            toplam=toplam+Close[i];
             onyediortalama=toplam/17.0;
            toplam=0;
            
            for( i=16;i>1;i--)
            toplam=toplam+Close[i];
            onbesortalama2=toplam/15.0;
              toplam=0;
              
              for( i=2;i>1;i--)
            toplam=toplam+Close[i];
            birortalama2=toplam/1.0;
             toplam=0;
             
                for( i=8;i>1;i--)
            toplam=toplam+Close[i];
            yediortalama2=toplam/7.0;
             toplam=0;
               for( i=18;i>1;i--)
            toplam=toplam+Close[i];
            onyediortalama2=toplam/17.0;
             toplam=0;
              
          /*  a=iMA(NULL,0,17,0,MODE_SMA,PRICE_CLOSE,2);
             Alert("onbes="+DoubleToStr(onyediortalama2)+"gercek deger"+DoubleToStr(a));  */
            
      karsilastir(onbesortalama,birortalama,yediortalama,onyediortalama,onbesortalama2,birortalama2,yediortalama2,onyediortalama2);
          
          
          
            }
         


int OnInit()
  {
//---
zaman=Time[0];
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(zaman!=Close[0])
     {
      acilis();
      
     }
   
  }
//+------------------------------------------------------------------+
alisahin
38
alisahin 2014.12.12 16:51  

Ordersend error 138 wrong? and WRONG 4051?

honest_knave
969
honest_knave 2014.12.12 17:14  
if(birortalama>onbesortalama && yediortalama>onyediortalama && yediortalama2<=onyediortalama2 && birortalama2<=onbesortalama2 && al==true )
  {
   OrderClose(sat,0.01,Ask,0,Red);
   alim=OrderSend(NULL,OP_BUY,0.01,Ask,1,0,0,"aldim",0,0,Blue);
   al=false;
  
  }


if(birortalama<onbesortalama && yediortalama<onyediortalama && yediortalama2>=onyediortalama2 && birortalama2>=onbesortalama2 && al==false )
  {
   OrderClose(alim,0.01,Bid,0,Blue);
   sat=OrderSend(NULL,OP_SELL,0.01,Bid,1,0,0,"sattim",0,0,Red);
   al=true;
   
  }
alisahin
38
alisahin 2014.12.12 17:20  
honest_knave:

 

thank you so much :) 
whroeder1
13627
whroeder1 2014.12.12 17:31  
   OrderClose(sat,0.01,Ask,0,Red);
   alim=OrderSend(NULL,OP_BUY,0.01,Ask,1,0,0,"aldim",0,0,Blue);
All predefined variables can become out of date between server calls. You must refresh them.
alisahin
38
alisahin 2014.12.13 15:49  
WHRoeder:
All predefined variables can become out of date between server calls. You must refresh them.
thanks a lot :)
/
To add comments, please log in or register