How to get LotScalp EA to trade at 2 different times a day

 

Hello,

i try to get LotScalp EA https://www.mql5.com/en/code/10604 to trade at 2 different times a day, but one trade at once at same hour.

As default do LotScalp EA trade one time a day as defined( 7 o'clock)

 int TradeTime=7;        // Time to enter the market

so i modifyed original code ....

...........

int start()
{
  if((TimeHour(TimeCurrent())>TradeTime)) cantrade=true;  
  // check if there are open orders ...
  total=OrdersTotal();
  if(total<Orders)
  {
    // ... if no open orders, go further
    // check if it's time for trade
    if((TimeHour(TimeCurrent())==TradeTime)&&(cantrade))
    {

...........

by adding this

int start()
{
  if((TimeHour(TimeCurrent())>Time_1 ) || (TimeHour(TimeCurrent())>Time_2)) cantrade=true;  
  // check if there are open orders ...
  total=OrdersTotal();
  if(total<Orders)
  {
    // ... if no open orders, go further
    // check if it's time for trade
    if(((TimeHour(TimeCurrent())==Time_1)&&(cantrade)) || ((TimeHour(TimeCurrent())==Time_2)&&(cantrade)))
    {

and setting extern int Orders=10;   to extern int Orders=1;

and it works, if i define (Time_1=13; and Time_2=23;) EA opens two orders for 13 o'clock, but it have to open just one order and after this order closed (by TakeProfit) the next order can be opened at one of defined hours. One opened order at once and at one defined hour.


here we have one sell order at 13:00, but next sell order at 13:12 is to much

SELL order at 13:12 is to much


I hope you understand me :) and hope you can help me

thanks

 
L0rd1:

Hello,

here we have one sell order at 13:00, but next sell order at 13:12 is to much

What do you see in the original code to prevent 2 trades being opened in the same hour ?
 

nothing, i can't understand logical how it can work with this 2 lines:

if((TimeHour(TimeCurrent())>TradeTime)) cantrade=true; //here current time musst be grater than 13
and
if((TimeHour(TimeCurrent())==TradeTime)&&(cantrade)) // here current time ist equal 13
 
L0rd1:

nothing, i can't understand logical how it can work with this 2 lines:

if((TimeHour(TimeCurrent())>TradeTime)) cantrade=true; //here current time musst be grater than 13
and
if((   TimeHour   (TimeCurrent())==TradeTime)&&(cantrade)) // here current time ist equal 13

And 13:12 is which Hour ?
 

ok, so i have to check orders history for order with same date and hour to prevent 2 trades being opened in the same hour.

Reason: