please help

 

hi

everybody

I am so newbie with mql and wrote a simple code in this code I just want my EA to open only 1 position but it opens as many as possible positions :(

please help me to solve this

I am really appreciated in advanced.

//+------------------------------------------------------------------+
//|                                                         KING.mq4 |
//|                                                         Mohammad |
//|                                         king.azadbakht@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Mohammad"
#property link      "king.azadbakht@yahoo.com"
#property version   "1.00"
#property strict
//--- input parameters
input double   BuyPoint=0.30;
input double   SellPoint=0.0;
input double   SPstoploss=0.0;
input double   BPstoploss=0.30;
input double   Lot=0.1;
input bool     trialingST=false;
input int      Smagic=456;
input int      Bmagic=123;
int i=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  
  
//---
   
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  
  bool cond=false;
  double BUY= Open[0]+BuyPoint;
  double BUY2=Low[0]+BuyPoint;
 if (i==0){
  Comment ("buystop=",BUY,"!"); }      //initial Buypoint
  i=1;

  if (BUY==Ask){cond==true;}
  if (cond==true)
 int ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Open[0]-BPstoploss,0,"expert comment",12345);
 
  if (Open[0]-0.05>Ask)
  {
  Comment ("buystop2=",BUY2,"!!");    //second Buypoint
  }
  if (Open[0]-0.05>Ask) {cond==false;}
  if (BUY2==Ask && cond==false)
  int ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Open[0]-BPstoploss,0,"expert comment",67890);

//---
 return;  
  }
//+------------------------------------------------------------------+
 
king64:

hi

everybody

I am so newbie with mql and wrote a simple code in this code I just want my EA to open only 1 position but it opens as many as possible positions :(

please help me to solve this

I am really appreciated in advanced. 

Please use the SRC button while posting parts of code. This time I'll do it for you. ;-)

 

 
Malacarne:

Please use the SRC button while posting parts of code. This time I'll do it for you. ;-)

 

oh sure

thank you

Reason: