Little stuck here with Buy Sell Conditions

 
double Buy1_1 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, 2);
      double Buy1_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, 2);
      double Buy2_1 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, 1);
      double Buy2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, 1);
      double Buy3_1 = iSAR(NULL, 0, 0.005, 0.05, 2);
      double Buy3_2 = iSAR(NULL, 0, 0.005, 0.05, 1);
      double Buy4_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 2);
      double Buy4_2 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1);

      double Sell1_1 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, 2);
      double Sell1_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, 2);
      double Sell2_1 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, 1);
      double Sell2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, 1);
      double Sell3_1 = iSAR(NULL, 0, 0.005, 0.05, 2);
      double Sell3_2 = iSAR(NULL, 0, 0.005, 0.05, 1);
      double Sell4_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 2);
      double Sell4_2 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1);
      double diIXO10=iCustom(NULL,0,"ixoah-indicator",PeriodIXO,0,0);
      double diIXO21=iCustom(NULL,0,"ixoah-indicator",PeriodIXO,1,0);
      double d22=(0);


      if (Buy1_1 > Buy1_2 && Buy2_1 >= Buy2_2 && Buy3_1 > Buy3_2 && Buy4_1 < Buy4_2 && diIXO10 > d22) Order = SIGNAL_BUY;
      
      if (Sell1_1 > Sell1_2 && Sell2_1 <= Sell2_2 && Sell3_1 > Sell3_2 && Sell4_1 > Sell4_2 && diIXO21< d22) Order = SIGNAL_SELL;


     
 
In the above code, the ea is putting only buy orders not sell orders, please help where did i go wrong, Thanks in advance
 
Vijay Akash T P: please help where did i go wrong
  1. Why did you post your MT4 question in the Root / MT5 General 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. Posting code that neither buys or sells.
 
Vijay Akash T P:
In the above code, the ea is putting only buy orders not sell orders, please help where did i go wrong, Thanks in advance

My recommendation: give better names to your variables first... e.g. instead of Buy1_1, change to X_Y_Z where X = MA/SAR/MACD, Y = moving average period, and Z = bar number.

If you do it correctly, you don't need to have two variables (one Buy and one Sell) for the same indicator value... and your condition checks for buy/sell orders will be easier to check.

 
Vijay Akash T P:
In the above code, the ea is putting only buy orders not sell orders, please help where did i go wrong, Thanks in advance

You mean to say that all these indi values can be taken in a a single variable? I kindly request you to give an example please

 
Vijay Akash T P:

You mean to say that all these indi values can be taken in a a single variable? I kindly request you to give an example please

Example:

double Buy1_1 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, 2);
double Sell1_1 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, 2);

becomes

double MA21_2 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, 2);
 
Seng Joo Thio:

Example:

Thx for your example. But if you can extend your help , can you please check whether my conditions are correct, if it wrong can you fix it. Thx in advance
 
Vijay Akash T P:
Thx for your example. But if you can extend your help , can you please check whether my conditions are correct, if it wrong can you fix it. Thx in advance
To make better understanding shall send that piece of code which calculates the signal for buy and sell
 
Vijay Akash T P:
Thx for your example. But if you can extend your help , can you please check whether my conditions are correct, if it wrong can you fix it. Thx in advance

Rename your variables, then rewrite your conditions with those new names and post here.

Show us that you're willing to help yourself by learning and trying, rather than just asking for free help...

 
Seng Joo Thio:

Rename your variables, then rewrite your conditions with those new names and post here.

Show us that you're willing to help yourself by learning and trying, rather than just asking for free help...

Sure, I want to learn 
 
I have made changes according to your advice, Where i am stuck i am unable to find out, still it is not placing sell order