I have a problem in writing the function, please help me.

 

hi friends I have a problem writing my expert advisor in mql4. The expert that I wrote contains three buffers of external indicators and I want it to wait whenever buffers one and three exceed zero until only the second buffer exceeds zero in the next candlesticks, and if it is positive, it waits until only the first buffer exceeds zero in the next candlesticks. should exceed zero and open a buy position whenever the third condition occurs. Please correct this function for me:   

//+------------------------------------------------------------------+
//|                                               part of the ea.mq4 |
//|                                                  Copyright 2022, |
//|                                           ezady.mohsen@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022,"
#property link      "ezady.mohsen@yahoo.com"
#property version   "1.00"
#property strict

//+------------------------------------------------------------------+
//|  Check for Signal                                                |
//+------------------------------------------------------------------+
void DefinePosition()
  {
   static datetime candle_counter = 0;  //this is candle time controller
   if(candle_counter!=Time[0])
     {
      double buffer1 = iCustom(_Symbol,0,"my indicator",0,1);
      double buffer2 = iCustom(_Symbol,0,"my indicator",1,1);
      double buffer3 = iCustom(_Symbol,0,"my indicator",2,1);

      //+------------------------------------------------------------------+
      //|         buy position conditions                                  |
      //+------------------------------------------------------------------+
      bool condition1 = buffer1>0 && buffer2==0 && buffer3>0;
      bool condition2 = buffer1==0 && buffer2>0 && buffer3==0;
      bool condition3 = buffer1>0 && buffer2==0 && buffer3==0;

        {
         if(condition1==true && TotalOpenedTrades()<MaxOpenedTrade)
           {
            if(condition2==true)
              {
               if(condition3==true)
                 {
                  ActivatePosition(OP_BUY, buffer1);
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
 
mohsssen eze: hi friends I have a problem writing my expert advisor in mql4. The expert that I wrote contains three buffers of external indicators and I want it to wait whenever buffers one and three exceed zero until only the second buffer exceeds zero in the next candlesticks, and if it is positive, it waits until only the first buffer exceeds zero in the next candlesticks. should exceed zero and open a buy position whenever the third condition occurs. Please correct this function for me:

Attach your code using the code button if you need help

 

Please EDIT your post and use the CODE button when you insert code.

Code button in editor

 
Fernando Carreiro #:Please EDIT your post and use the CODE button when you insert code.

This is part of the ea. Thank you 🙏🏻😊
Files:
 
mohsssen eze #: This is part of the ea. Thank you 🙏🏻😊

If you want help you need to show the code, properly formatted, as requested by Fernando.

Attaching the mq4 is fine, but very few people will take the time to download it and check it. Me neither.

 
mohsssen eze #: This is part of the ea Thank you 🙏🏻😊

I have edited your post and inserted it for you for easier viewing.

The file attachment is great for large code files but for short examples of code use the method explained above.

 
Fernando Carreiro #:

I have edited your post and inserted it for you for easier viewing.

The file attachment is great for large code files but for short examples of code use the method explained above.

You are very patient and kind to do so
 
@Alain Verleyen #: You are very patient and kind to do so
The OP made an effort to attach the file. It was not ideal, but I still considered it an effort on their part, so I met them half-way by editing it.
 
Fernando Carreiro #:
The OP made an effort to attach the file. It was not ideal, but I still considered it an effort on their part, so I met them half-way by editing it.
And now he created a new topic...
A function with three consecutive conditions
A function with three consecutive conditions
  • 2023.04.15
  • www.mql5.com
hi friends I have a problem writing my expert advisor in mql4...
 
@mohsssen eze, please don't double post. I have removed your other thread.
 
Is the answer to my question really so difficult for programmers that they don't have the ability to solve it?🤦🏻‍♂️
Reason: