errors in my ea

To add comments, please log in or register
mo798ua
66
mo798ua  

hi guys i wrote this ea and i have a lot of errors for some reason i dont know i used to define my function outside oftick() errorless but for the first time i get error because defining functions can some one help please

//+------------------------------------------------------------------+
//|                                                     kjexpert.mq4 |
//|                                   Copyright 2019, MOHAMMEDJAFFAR |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MOHAMMEDJAFFAR"
#property link      ""
#property version   "1.00"
#property strict
 extern double kj=52;
 extern int StopLoss=50;
 extern int TakeProfit=10;
 extern double lots=0.05;
 double kijun_sen=iIchimoku(NULL,0,9,kj,52,MODE_KIJUNSEN,1)
 bool isitoktotrade()
{
int maxorders=1;
if(OrdersTotal()<=maxorders)
{return true;}
else {return false;};
}
//******************
 bool priceabovekj()
 {
 if(iClose(Symbol(),0,1)>kijun_sen && iOpen(Symbol(),0,1)>kijun_sen)
 {
 return true;
 }
 else {return false;}
 }
 //***********************
 bool buysetup()
 {
 if(iClose(Symbol(),0,1)>kijun_sen && iOpen(Symbol(),0,1)>kijun_sen)
 {
 return true;
 }
 else {return false;}
 }
//***********************
bool pricebellowkj()
 {
 if(iClose(Symbol(),0,1)<kijun_sen && iOpen(Symbol(),0,1)<kijun_sen)
 {
 return true;
 }
 else {return false;}
 }

//***********************
bool sellsetup()
 {
 if(iClose(Symbol(),0,1)<kijun_sen && iOpen(Symbol(),0,1)<kijun_sen)
 {
 return true;
 }
 else {return false;}
 }
void OnTick()
{
///****************BUY**************************
   if(buysetup()==true)
   {
   OrderSend(Symbol(), OP_BUY,lots, Ask, 10*10, Bid-StopLoss*Point*10, Bid+TakeProfit*Point*10, "My 1st Order!");
   }
///***************CHEAK IF PRICE IS STILL ABOVE KJ***********************  
      while(priceabovekj()==true)
   {
   
   }//keep looping until priceabovekj is false
  
  
///****************SELL**************************  
if(sellsetup()==true)
   {
   OrderSend(Symbol(), OP_SELL,lots, Ask, 10*10, Bid-StopLoss*Point*10, Bid+TakeProfit*Point*10, "My 1st Order!");
   }
///***************CHEAK IF PRICE IS STILL BELLOW KJ***********************  
      while(pricebellowkjkj()==true)
   {
   
   }//keep looping until pricebellowkj is false

}   
Files:
error.PNG 19 kb
Edwin Artunduaga
2231
Edwin Artunduaga  
//+------------------------------------------------------------------+
//|                                                     kjexpert.mq4 |
//|                                   Copyright 2019, MOHAMMEDJAFFAR |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MOHAMMEDJAFFAR"
#property link      ""
#property version   "1.00"
#property strict
 extern double kj=52;
 extern int StopLoss=50;
 extern int TakeProfit=10;
 extern double lots=0.05;
 double kijun_sen=iIchimoku(NULL,0,9,kj,52,MODE_KIJUNSEN,1); //<----- semicolon
 bool isitoktotrade()
{
int maxorders=1;
if(OrdersTotal()<=maxorders)
{return true;}
else {return false;};
}
//******************
 bool priceabovekj()
 {
 if(iClose(Symbol(),0,1)>kijun_sen && iOpen(Symbol(),0,1)>kijun_sen)
 {
 return true;
 }
 else {return false;}
 }
 //***********************
 bool buysetup()
 {
 if(iClose(Symbol(),0,1)>kijun_sen && iOpen(Symbol(),0,1)>kijun_sen)
 {
 return true;
 }
 else {return false;}
 }
//***********************
bool pricebellowkj()
 {
 if(iClose(Symbol(),0,1)<kijun_sen && iOpen(Symbol(),0,1)<kijun_sen)
 {
 return true;
 }
 else {return false;}
 }

//***********************
bool sellsetup()
 {
 if(iClose(Symbol(),0,1)<kijun_sen && iOpen(Symbol(),0,1)<kijun_sen)
 {
 return true;
 }
 else {return false;}
 }
void OnTick()
{
///****************BUY**************************
   if(buysetup()==true)
   {
   OrderSend(Symbol(), OP_BUY,lots, Ask, 10*10, Bid-StopLoss*Point*10, Bid+TakeProfit*Point*10, "My 1st Order!");
   }
///***************CHEAK IF PRICE IS STILL ABOVE KJ***********************  
      while(priceabovekj()==true)
   {
   
   }//keep looping until priceabovekj is false
  
  
///****************SELL**************************  
if(sellsetup()==true)
   {
   OrderSend(Symbol(), OP_SELL,lots, Ask, 10*10, Bid-StopLoss*Point*10, Bid+TakeProfit*Point*10, "My 1st Order!");
   }
///***************CHEAK IF PRICE IS STILL BELLOW KJ***********************  
      while(pricebellowkj()==true) // <---- function must be pricebellowkj() not pricebellowkjkj()
   {
   
   }//keep looping until pricebellowkj is false

} 
Line 14 and 79, see comments.
mo798ua
66
mo798ua  
Edwin Artunduaga:
This the same cod of mine
William Roeder
20233
William Roeder  
  1.  double kijun_sen=iIchimoku(NULL,0,9,kj,52,MODE_KIJUNSEN,1); //<----- semicolon
     bool isitoktotrade(){ …
    Global and static variables work exactly the same way in MT4/MT5/C/C++.
    1. They are initialized once on program load.
    2. They don't update unless you assign to them.
    3. In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5 (or MT4 with strict which you should always use.)

      MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:

      1. Terminal starts.
      2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
      3. OnInit is called.
      4. For indicators OnCalculate is called with any existing history.
      5. Human may have to enter password, connection to server begins.
      6. New history is received, OnCalculate called again.
      7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
    4. Unlike indicators, EAs are not reloaded on chart change so you must reinitialize them, if necessary.
                external static variable - Inflation - MQL4 programming forum

  2.  if(iClose(Symbol(),0,1)>kijun_sen && iOpen(Symbol(),0,1)>kijun_sen)
     {
     return true;
     }
     else {return false;}
    Simplify your code.
              Increase Order after stoploss - MQL4 programming forum № 3

  3.       while(priceabovekj()==true)
       {
       
       }//keep looping until priceabovekj is false
    
    This means you can't use the tester. It also will peg your CPU at max. Do not loop. Return from OnTick and reevaluate on the next tick.

Edwin Artunduaga
2231
Edwin Artunduaga  
mo798ua:
This the same cod of mine

it is not, see comments in line 14 and 79

To add comments, please log in or register