Limit number of orders in the same Candle

 

Hi, im having a problem on limiting the numbers of the Orders that my EA makes in the same candle. I attached the print showing my problem.

I want to do something like:

input int max_orders_per_candle = 2;

if(TradeSignal==true && orders_in_actual_candle<max_orders_per_candle)

{

//now i execute the trade order

}

How can i do it?

Files:
 
le0max12:

Hi, im having a problem on limiting the numbers of the Orders that my EA makes in the same candle. I attached the print showing my problem.

I want to do something like:

input int max_orders_per_candle = 2;

if(TradeSignal==true && orders_in_actual_candle<max_orders_per_candle)

{

//now i execute the trade order

}

How can i do it?

Try creating a candle counter, then decrement the max_orders whenever an order is sent. Like this:

void some_function()
{
        if(!new_candle)         // if no new candle is formed
        {
                if(max_orders_pc!=0)
                {
                        //execute your code;
                        //then decrement the max_orders_pc
                        max_orders_pc -=1;
                }
                else return; // maximum orders are depleted. Wait for next candle.
        }
        else    // if a new candle is formed
        {
                //reset max_orders_pc back to 2
                max_orders_pc =2;
        }
}

bool new_candle()
        {
        ***code here, or find new candle code in the forum.
        return true;
}

Best of luck!