whats the problem

 
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
input bool ma3_use=true;
input int period_1=12;
input int period_2=32;
input int period_3=200;
input string symbol="EURUSD";
input string variable_name0 = "---Separator---"; 
input double lots=0.02;
input double stoploss=100;
input double take_profit=100;
input int slippage=500;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
bool signal_sell=false;
bool signal_buy=false;
double high=iHigh(symbol,PERIOD_D1,1);
double low=iLow(symbol,PERIOD_D1,1);
double close=iClose(symbol,PERIOD_D1,1);
double pp=(high+low+close)/3;
double ma_1=iMA(symbol,PERIOD_M15,period_1,0,1,6,0);
double ma_2=iMA(symbol,PERIOD_M15,period_2,0,1,6,0);
double ma_3=iMA(symbol,PERIOD_M15,period_3,0,0,6,0);
double close_15=iClose(symbol,PERIOD_M15,1);
double open_15=iOpen(symbol,PERIOD_M15,1);

if(ma3_use==true)
{
if(ma_1>ma_2>ma_3)
signal_buy=true;
}
else if(ma3_use==false)
{
if(ma_1>ma_2)
signal_buy=true;
}
   if(signal_buy==true&&open_15<pp&&close_15>pp)//signal_buy pp
{
if(OrdersTotal()<1)
RefreshRates();
int ticket=OrderSend(symbol,OP_BUY,lots,close_15,slippage,close_15-stoploss*Point,close_15+take_profit*Point);
}

  }

this is the part of my code that has problem..... the idea is simply if a 15 min candle closes above the pp line it has to open a buy order it simply doesnt open it.....i have similar conditions for sell order but that works... i changed the price and sl and tp and used RefreshRates and even changed slippage it doesnt work... whats the problem

 
saman89200: . the idea is simply if a 15 min candle closes a
  1. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Where do you check for a new bar?
  3. You can't buy at the close price of a bar (close_15,) only at the current market price (Ask.)

  4. Check your return codes for errors, report them and you would know why. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.

  5. if(OrdersTotal()<1)
    Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
              Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
              MagicNumber: "Magic" Identifier of the Order - MQL4 Articles

  6. Don't double post!
              General rules and best pratices of the Forum. - General - MQL5 programming forum

 
saman89200:

this is the part of my code that has problem..... the idea is simply if a 15 min candle closes above the pp line it has to open a buy order it simply doesnt open it.....i have similar conditions for sell order but that works... i changed the price and sl and tp and used RefreshRates and even changed slippage it doesnt work... whats the problem

Try changing this:

OrderSend(symbol,OP_BUY,lots,Ask,slippage,close_15-stoploss*Point,close_15+take_profit*Point)

And check Experts / Journal tabs of the Terminal for error messages.