Enum List of All pairs available

 

Hi all,

as per the object i'm trying to select the pair on wich run an EA from a drop-down menu.
I've already done this, in order to select the type of order, if is a Sell Limit or Buy Limit:

enum intOder_Type
   {
      Sell_Limit =3,//Sell Limit
      Buy_Limit =2 // Buy Limit
    };

 But i need to pass to the OrderSend function the pair for wich I want to open the position.

Do someone have ideas on how to code it?


Thanks in advance!

 
Fabio Brondo: Do someone have ideas on how to code it?

Can't be done. The list would have to be constant at compile time. Different brokers have different symbols.

Just code it to trade the current symbol and let the trader choose which charts to put it on.

 
Fabio Brondo:

Hi all,

as per the object i'm trying to select the pair on wich run an EA from a drop-down menu.
I've already done this, in order to select the type of order, if is a Sell Limit or Buy Limit:

 But i need to pass to the OrderSend function the pair for wich I want to open the position.

Do someone have ideas on how to code it?


Thanks in advance!

You'd need to have a custom properties tab after the ea is placed on the chart for this . 

As William said if its not a multisymbol ea it is not that important

 
Lorentzos Roussos #:

You'd need to have a custom properties tab after the ea is placed on the chart for this . 

As William said if its not a multisymbol ea it is not that important

Hi @Lorentzos Roussos and @William Roeder, thank you both for your feedback.
So basically it's taking the signal from the chart to wich i will enable to EA? It's correct?

Another question, to place Sell Limit and Buy Limit order is the function OrderSend correct?
From what i've found seems that it's correct if i will pass all those fields:


OrderSend()

int OrderSend (string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

Thanks for your help!

 
FabioB_94 #:

Hi @Lorentzos Roussos and @William Roeder, thank you both for your feedback.
So basically it's taking the signal from the chart to wich i will enable to EA? It's correct?

Another question, to place Sell Limit and Buy Limit order is the function OrderSend correct?
From what i've found seems that it's correct if i will pass all those fields:


OrderSend()

int OrderSend (string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

Thanks for your help!

Yeah in mt4 , but you must be careful with stop orders and also check the SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOP_LEVEL); (i think this is it) as brokers do not allow you to 

place a pending order or stop loss or take profit too close to the live price sometimes

 
Lorentzos Roussos #:

Yeah in mt4 , but you must be careful with stop orders and also check the SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOP_LEVEL); (i think this is it) as brokers do not allow you to 

place a pending order or stop loss or take profit too close to the live price sometimes

Ok, thanks for your support @Lorentzos Roussos !

I've drafted this code, but i'm getting a huge batch of errors...


This EA basically have to open multiple Selli Limit or Buy Limit, starting from the parameters placed as inputs.

//+------------------------------------------------------------------+

#property strict
//Input parameters

input int Transaction_Number; //number of transaction to be automatically placed
input int Order_ID; // Sequential Order ID
input double Starting_Price; // Starting price of the first order
input double Lots_Volume;
input int Lots_Steps; //Steps of increase or decrease for orders after the first one
input double Stop_Loss;
input double Take_Profit;

enum intOder_Type
   {
      Sell_Limit =3,//Sell Limit
      Buy_Limit =2 // Buy Limit
    };
    

input intOder_Type Transaction_Type=Buy_Limit;

input int Order_Type ;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if(Transaction_Type ==2);
   Alert("Buy Limit Order");  
   if(Transaction_Type==3);
   Alert("Sell Limit Order");

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit()
  {
//---

 }
 
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//SELL LIMIT
   if(Transaction_Type==3)
      {
        
      for(int i=1; i<=Transaction_Number; i++)
         {
              int OrderSend (Symbol,int Transaction_Type, Lots_Volume, price, int slippage=0, Stop_Loss, Take_Profit, string comment=NULL, Order_ID, datetime expiration=0, color arrow_color=CLR_NONE);
              price= price+Lots_Steps;
         }
       }
   
// BUY LIMT
   if(Transaction_Type==2)
      {
      price=price+Lots_Steps;
      for(int i=1; i<=Transaction_Number; i++)
         {
              int OrderSend (Symbol(), int Transaction_Type, Lots_Volume, price, int slippage=0, Stop_Loss, Take_Profit, string comment=NULL, Order_ID, datetime expiration=0, color arrow_color=CLR_NONE);
              price= price+Lots_Steps;
         }

  }
  }
//+------------------------------------------------------------------+

Do you have any idea of where are those errors?
Thanks a lot!

 
Fabio Brondo #:

Ok, thanks for your support @Lorentzos Roussos !

I've drafted this code, but i'm getting a huge batch of errors...


This EA basically have to open multiple Selli Limit or Buy Limit, starting from the parameters placed as inputs.

Do you have any idea of where are those errors?
Thanks a lot!

Check this correction and i'll let you write the buy limit side on your own .  ☕️

#property strict
//Input parameters

input int Transaction_Number=2; //number of transaction to be automatically placed
input int Order_ID=234;
input double Starting_Price=1.05; // Starting price of the first order <!> this will be problematic 
input double Lots_Volume=0.01;
input double Lots_Steps=0.01; //Steps of increase or decrease for orders after the first one
input double Stop_Loss=300;//points
input double Take_Profit=500;//points
input double Price_Step=400;//points

enum intOder_Type
   {
      Sell_Limit =3,//Sell Limit
      Buy_Limit =2 // Buy Limit
    };
    

input intOder_Type Transaction_Type=Buy_Limit;

input int Order_Type ;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if(Transaction_Type==2) Alert("Buy Limit Order");  
   if(Transaction_Type==3) Alert("Sell Limit Order");

   return(INIT_SUCCEEDED);
  }

void OnTick()
  {
  //this will keep placing orders constantly if not checked (and if it worked)
  //you should gate it somehow
//SELL LIMIT
   if(Transaction_Type==3)
      {
      //set the price as the starting price 
        double price=Starting_Price;
      //set the lots as the starting lots
        double lots=Lots_Volume;
      for(int i=1; i<=Transaction_Number; i++)
         {
         //stop loss for a sell is the price of the open of the sell + the size of the sl * point of symbol
         //take profit for a sell is the price of the open - the size of the tp * point of symbol
         int ticket=OrderSend(_Symbol,(ENUM_ORDER_TYPE)Transaction_Type,lots,price,1000,price+Stop_Loss*_Point,price-Take_Profit*_Point,NULL,Order_ID,0,clrRed);
             price=price+(Price_Step)*_Point;//the price step cannot be changed by the lot step but by its own step
             lots=lots+Lots_Steps;
         }
       }
   
// BUY LIMT
  /*
   if(Transaction_Type==2)
      {
      price=price+Lots_Steps;
      for(int i=1; i<=Transaction_Number; i++)
         {
              int OrderSend (Symbol(), int Transaction_Type, Lots_Volume, price, int slippage=0, Stop_Loss, Take_Profit, string comment=NULL, Order_ID, datetime expiration=0, color arrow_color=CLR_NONE);
              price= price+Lots_Steps;
         }

  }
  */
  }
 
Lorentzos Roussos #:

Check this correction and i'll let you write the buy limit side on your own .  ☕️

Here we are:
I've tried your update, first of all, thanks!

Anyway it's not placing any order unfortunately, do you have any idea on why?

I've moved it on "OnInit" in order to avoid the infinite loop of "OnTick":


#property strict
//Input parameters

input int Transaction_Number=0; //Number of transaction to be automatically placed
input int Order_ID=1;
input double Starting_Price=1.00; // Starting price of the first order <!> this will be problematic 
input double Lots_Volume=0.01;
//input double Lots_Steps=0.01; //Steps of increase or decrease for orders after the first one
input double Stop_Loss=0.300;//Stop Loss
input double Take_Profit=1.2;//Take Profit
input double Price_Step=0.050;//Price Step

enum intOder_Type
   {
      Sell_Limit =3,//Sell Limit
      Buy_Limit =2 // Buy Limit
    };
    

input intOder_Type Transaction_Type;

//input int Order_Type ;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if(Transaction_Type==2) Alert("Buy Limit Order");  
   if(Transaction_Type==3) Alert("Sell Limit Order");
  //this will keep placing orders constantly if not checked (and if it worked)
  //you should gate it somehow
//SELL LIMIT
   if(Transaction_Type==3)
      {
      //set the price as the starting price 
        double price=Starting_Price;
      //set the lots as the starting lots
        double lots=Lots_Volume;
      for(int i=1; i<=Transaction_Number; i++)
         {
         //stop loss for a sell is the price of the open of the sell + the size of the sl * point of symbol
         //take profit for a sell is the price of the open - the size of the tp * point of symbol
         int ticket=OrderSend(Symbol(),OP_SELLLIMIT,Lots_Volume,Starting_Price,0,Stop_Loss,Take_Profit,NULL,Order_ID,0,Blue);
             price=price+(Price_Step);//the price step cannot be changed by the lot step but by its own step
            // lots=lots+Lots_Steps;
         }
       }
   
// BUY LIMT
  /*
   if(Transaction_Type==2)
      {
      price=price+Lots_Steps;
      for(int i=1; i<=Transaction_Number; i++)
         {
              int OrderSend (Symbol(), int Transaction_Type, Lots_Volume, price, int slippage=0, Stop_Loss, Take_Profit, string comment=NULL, Order_ID, datetime expiration=0, color arrow_color=CLR_NONE);
              price= price+Lots_Steps;
         }

  }
  */
   return(INIT_SUCCEEDED);
  }

/*
  {

  }*/
 
Fabio Brondo #:

Here we are:
I've tried your update, first of all, thanks!

Anyway it's not placing any order unfortunately, do you have any idea on why?

I've moved it on "OnInit" in order to avoid the infinite loop of "OnTick":


The number of transactions is 0

Stop Loss for a sell should be above the open price of the sell , Take Profit for a sell should be below the open price of the sell 
 
Lorentzos Roussos #:

The number of transactions is 0

Stop Loss for a sell should be above the open price of the sell , Take Profit for a sell should be below the open price of the sell 

Yes, i've put them as a "Starting Value" to be edited in the EA once started.
By the way i've also added this in the end of the for loop:

 for(int i=1; i<=Transaction_Number; i++)
         {
         //stop loss for a sell is the price of the open of the sell + the size of the sl * point of symbol
         //take profit for a sell is the price of the open - the size of the tp * point of symbol
         int ticket=OrderSend("Symbol(),H1",OP_SELLLIMIT,Lots_Volume,Starting_Price,0,Stop_Loss,Take_Profit,NULL,Order_ID,0,Blue);
             price=price+(Price_Step);//the price step cannot be changed by the lot step but by its own step
            // lots=lots+Lots_Steps;
         if(ticket<=0) Alert("Error Open: ",GetLastError());
         }

And it's returning The error 133.

Currently on my demo account i have this Symbol:


GBPUSD,H1

This is why i've modified:

int ticket=OrderSend("Symbol(),H1",OP_SELLLIMIT,Lots_Volume,Starting_Price,0,Stop_Loss,Take_Profit,NULL,Order_ID,0,Blue);
 
Fabio Brondo #:

Yes, i've put them as a "Starting Value" to be edited in the EA once started.
By the way i've also added this in the end of the for loop:

And it's returning The error 133.

Currently on my demo account i have this Symbol:


GBPUSD,H1

This is why i've modified:

No need for the timeframe just use _Symbol 

Is the symbol tradable ?

Is the price of the sell limit above the current price ?

I think these series on youtube might be helpful


Reason: