What did I do wrong

 

hi guys, I'm trying to figure my way out of this programing tough.Maybe some differant eye with more experience could see what I did wrong on this script.

I wanted to create a ea that would trade in both ways and I actually encounters a major problem.

it's not doing what it is supposed to.

here is what I coded:

//+------------------------------------------------------------------+
//|                                                        stacker.mq4 |
//+------------------------------------------------------------------+

int    Magic        = 123456;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+


int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| EA program start function                                        |
//+------------------------------------------------------------------+
void start()
  //----
{
if (OrdersTotal() == 0)
   {
      OpenMore();
   }
else
   {
      CheckLoss();
   }
return(0);
}

void CheckLoss()
{

   if (AccountProfit() <= (-50 * OrdersTotal()))
      {
      OpenMore();
      }
   return(0);
   }
   
//+------------------------------------------------------------------+

   
void OpenMore()
   {
   OrderSend("CADJPY", OP_SELL, 0.1, MarketInfo("CADJPY", MODE_BID), 3, 0, 50, "", Magic, 0);
   Sleep(15000);
   OrderSend("CADJPY", OP_BUY, 0.1, MarketInfo("CADJPY", MODE_ASK), 3, 0, 50, "", Magic, 0);
   Sleep(900000);
   CheckLoss();
   }

it is supposed to open a trade in both ways with a take profit at 50 pips and no stop loss

once the account it reaches (-50$ * number of orders) it is supposed to open these 2 trades one more time

and so on and so on.

it just does not start trading or anything.

 

Read more on OrderSend


https://docs.mql4.com/trading/OrderSend


Stoploss and TakeProfit in real price, not pips

Reason: