View Single Post
  #1  
Old 10-01-2019, 22:42
Stinky Stinky is offline
Level 1 Lasers Member
 
Join Date: Jan 2019
Posts: 1
Default Need Some mql Help

i started whit mql and it works all fine, but why he dont open a Buy order? Only sell?

Can you help me? i become crazy^^

PHP Code:

input double Lots 
0.01;

input int TPPoints 500;
input int SLPoints 500;

input int RSIPeriods 14;
input int Top 70;
input int Bottom 30;

input int Magic 1;




int orderTicket 0

int OnInit()
  {

   return(
INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {

   
  }

void OnTick()
{
   
double rsi;
   
double rsi2
   
rsi iRSI(Symbol(), PERIOD_CURRENT,RSIPeriods,PRICE_CLOSE,0);
   
rsi2 iRSI(Symbol(), PERIOD_CURRENT,RSIPeriods,PRICE_CLOSE,0);

      if(
rsi Top
      {     
         if(
OrderSelect(orderTicket,SELECT_BY_TICKET) == true
         {
            if(
OrderType() == OP_BUY
            {
                 
bool res OrderClose(OrderTicket(),OrderLots(),Bid,1000,clrNONE);
                     
orderTicket 0;
                      
            }
         }
         
     if(
orderTicket <= 0
     {
         
orderTicket executShort();
     }
     }
      else if(
rsi2 Bottom
     {
         if(
OrderSelect(orderTicket,SELECT_BY_TICKET) == true
         {
            if(
OrderType() == OP_SELL
            {

                  
bool res OrderClose(OrderTicket(),OrderLots(),Ask,1000,clrNONE);
                     
orderTicket 0;
            }
         }
     }
           
           
     if(
orderTicket <= 0
     {
         
orderTicket executLong();
     }     
}
     
     
     
int executShort () 
   {
      
double entry Bid
      
double tp entry TPPoints Point;
      
double sl entry SLPoints Point;
   
      
int ticket;
      
ticket OrderSend(Symbol(), OP_SELL,Lots,entry,1000,sl,tp,"OP_SELL",Magic,0,clrNONE);
      return 
ticket;
   }

      
int executLong () 
   {
      
double entry Bid;
      
double tp entry TPPoints Point;
      
double sl entry SLPoints Point;
  
      
int ticket;
      
ticket OrderSend(Symbol(), OP_BUY,Lots,entry,1000,sl,tp,"OP_SELL",Magic,0,clrNONE);
      return 
ticket;
   } 
Reply With Quote