How can i automaticly repeat the task of my EA when it's done can you help please thanks. - page 2

 
Stone Fletcher:

it is not working !!

Exactly.

 
Stone Fletcher:

I removed the Count variable after i tried it without doing Count==1 but just Count and still does not repeat the task it does it once a nothing after that  i dont understand what is the problem if i got the function OnClick() why it does not repeat the task ????


There may be a problem with your platform and it will not work, but your EA does not make sense anyway. With the Count variable what you are doing is counting ticks, and all other functions are only executed on the first tick.

To know if the EA is running and you have a connection to the broker you can add the following line:


int PositionIndex;
   int TotalNumberOfOrders;
   slippage=10;
   volume=0.01;
   Count++;

   Print("Count = ", Count);


If in the Experts tab, in the Terminal window, you will see messages like the ones I show you in the image, then the EA is working and receiving ticks. If so, the problem lies in the logic of your EA.




Greetings.

 
Jose Francisco Casado Fernandez:


There may be a problem with your platform and it will not work, but your EA does not make sense anyway. With the Count variable what you are doing is counting ticks, and all other functions are only executed on the first tick.

To know if the EA is running and you have a connection to the broker you can add the following line:



If in the Experts tab, in the Terminal window, you will see messages like the ones I show you in the image, then the EA is working and receiving ticks. If so, the problem lies in the logic of your EA.




Greetings.


I added the small code that you send me to my source and it did not do the count like you send me in th picture here what i got from the code :

small code added to original source code

 
Stone Fletcher:

Below is my source code when the task is done i want it to be repeated automaticly i cant find the way to do it any help will be apreciated.


Maybe try using OnTimer instead of OnTick and set it to repeat at some interval in OnInit

 
John Davis:

Maybe try using OnTimer instead of OnTick and set it to repeat at some interval in OnInit


I will try that thanks.

 
Stone Fletcher:

I will try that thanks.

Are you going to add OnInit() to your code ?

 
Stone Fletcher:

I added the small code that you send me to my source and it did not do the count like you send me in th picture here what i got from the code :


Have you kept the command Count ++ ??
Have you tried other EAs on that platform ??
Have you tried your EA on other platforms ??
Could you try this EA and see what messages appear on the Experts tab ??


//+------------------------------------------------------------------+
//|                                                   Pruebamql5.mq4 |
//|                                       Copyright 2017, Robertomar |
//|                         https://www.mql5.com/en/users/robertomar |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Robertomar"
#property link      "https://www.mql5.com/en/users/robertomar"
#property version   "1.00"
#property strict

int Count;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
   Count++;

   Print("Count = ", Count);
  }
//+------------------------------------------------------------------+
 
Jose Francisco Casado Fernandez:

Have you kept the command Count ++ ??
Have you tried other EAs on that platform ??
Have you tried your EA on other platforms ??
Could you try this EA and see what messages appear on the Experts tab ??

when i try your code the first time it did not worked the command Count++ was there.

i never try ther EA on the platform.

i never try My EA on other platform

 


here what i got from your code it worked fine :


screen shot of your code



 

well it will only work once when there are no more orders because:

TotalNumberOfOrders=OrdersTotal();
 
Marco vd Heijden:

well it will only work once when there are no more orders because:


Ok i  went step by step with my source code and i realise that the while(true) is the reason why the EA does not repeat the task so i replace it with while(ticket1==true && ticket2==true) but now it send orders NON STOP i can close all orderS and it start by itself on every tick so now i need to find a way so it send the order ONLY ONCE  instead of sending an order on each tick.

Reason: