Forex Forums | ForexLasers.com


Go Back   Forex Lasers Forum > METATRADER FORUM > Expert Advisors / Robots


Need Some mql Help

Expert Advisors / Robots


Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old 10-01-2019, 22:42
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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 18:07.


Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2021, vBulletin Solutions, Inc.