I will write an advisor free of charge - page 17

 
Hello, I've started to learn MQL4 and started with the MACD Sample Expert Advisor. I have it all sorted out. I think I got it all figured out, but I cannot make it work on my Demo for several currency pairs at once. If there is already an open position in the terminal (manually or by Expert Advisor) it won't work. I don't have enough knowledge, please advise me what I should add or fix.
 
igor.malish:
Hello, I started to learn MQL4 and started using the MACD Sample Expert Advisor. I have parsed it out. I think I got it all sorted out, but I cannot make it work as a demo Expert Advisor on more than one symbol at the same time. If there is already an open position in the terminal (manually or by Expert Advisor) it won't work. I've tried everything I know. I don't have enough knowledge, please advise me what to add or correct.

MACD Sample is not designed to trade on multiple instruments

total=OrdersTotal();

   if(total<1)

     {...
In this condition, it is practically forbidden to open trades, if at least one, for any instrument has already been opened.
 
dimeon:

MACD Sample is not designed to trade on multiple instruments

This condition practically prohibits opening trades if at least one, for any instrument, is already open.
I had a similar problem, but for one trade per day. I.e. the condition is not only OrdersTotal(), but also from the history of closed ones.
 
Is there any way to link OrdersTotal, OrderSymbol and OrderMagicNumber?
 
igor.malish:
Is there any way to link OrdersTotal, OrderSymbol and OrderMagicNumber?
Silly question.
 
Greetings. Can anyone adapt my EA to the new mql? (#property strict) It's developing and its functionality is improving but the language it's written in is outdated. This Expert Advisor is a later modification of ZigZaHod v1.1 and it needs minimal changes so that I can master and modify it. I am ready to be deeply involved in it. I lack understanding of what needs to be redone.
 

Help fix the bug: The idea is that the EA should work once a day, when the new day starts. 1am. should open two pending orders on a high and low

I mean the candlestick that closed at 00:00. I shouldn't do anything else until the next day. What am I doing wrong ?


extern string Times = "Time";
extern int StartHour    = 1;
extern int TakeProfit   = 50;
extern int StopLoss     = 50;
extern int Lots         = 1;

void OnTick()
{ 
   static bool IsFirstTick = true;
   static int ticket = 0;
   int h=TimeHour(TimeCurrent());
   Alert("TimeHor: ", h);
   if(Hour() == StartHour)
   {
    if (IsFirstTick == true)
      IsFirstTick - false;
      
      bool res;
      res= OrderSelect(ticket, SELECT_BY_TICKET);
      if(res == true)
      { 
         if(OrderCloseTime() == 0)
         {
            bool res2;
            res2 = OrderClose(ticket, Lots, OrderClosePrice(), 10);
            
            if(res2 == false)
            {
               Alert("Error Closing Order #", ticket);
               }
         }   
      }
       if(Open[0] < Open[StartHour])
      {
         ticket = OrderSend(Symbol(), OP_BUYLIMIT, Lots, High[1],10, Low[1]-StopLoss*Point, High[1]+TakeProfit*Point,"Set bu ForexRobot");
         if(ticket < 0)
         {
           Alert("Error Sending Order!");
         }  
       }
       else
       {
         ticket = OrderSend(Symbol(), OP_SELLLIMIT, Lots, Low[1],10, High[1]+StopLoss*Point, Low[1]+TakeProfit*Point,"Set bu ForexRobot");
         if(ticket < 0)
         {
           Alert("Error Sending Order!");
         } 
    }   
}
 
MIR_KAZAN:

Help fix the bug: The idea is that the EA should work once a day, when the new day starts. 1am. should open two pending orders on a high and low

I mean the candlestick that closed at 00:00. I shouldn't do anything else until the next day. What am I doing wrong ?


When pasting code, please use the embedded capabilities of the forum:paste code correctly on the forum
 
barabashkakvn:
When pasting code, please use the built-in features of the forum:Insert code correctly in the forum
Got it.
 
MIR_KAZAN:

Help fix the bug: The idea is that the EA should work once a day, when the new day starts. at 1 am. should open two pending orders on the high and low

That is, a candlestick that closed at 00:00. Should not do anything else until the next day. What am I doing wrong ?


There is an error:

      IsFirstTick - false;

It should be =

Reason: