How to make only one trade per day?

 

HI!

When I use OrderSend it makes a lot of trades but I want to make only one per day, means that a trade to be done everyday.

Tried different methods but no result.

Please help.

 

hi

you can use a limitation like this at top of your EA:

total=orderstotal()

if(total<1)

{

..............(your EA)

.

.

A.M

 

U can use "ordersendtime()" to check if there is already a trade today.

 
aminkam:

hi

you can use a limitation like this at top of your EA:

total=orderstotal()

if(total<1)

{

..............(your EA)

.

.

A.M

thanks, but this code will make only one trade in a day but I want everyday...

I can use a method like if today is day of month 1 then, if 2 then, if 3 the, etc.. but it's to complicated I want to simplify.

 
alexvorn2 wrote >>

HI!

When I use OrderSend it makes a lot of trades but I want to make only one per day, means that a trade to be done everyday.

Tried different methods but no result.

Please help.

Hi

try this

datetime PreviousBar;
---------------------------------------

if(SignalBUY=="true"&&NewBar())

Ticket=OrderSend(Symbol(),OP_BUYxxxxxxxxxxxxxxxxxxxxxxx
------------------------------------------------------------------
if(SignalSELL=="true"&&NewBar())

Ticket=OrderSend(Symbol(),OP_SELLxxxxxxxxxxxxxxxxxxx
-------------------------------------------------------------------
to close open orders either opened sell or buy


if (PreviousBar<Time[0] || (your exit signal according to your indicators))
OrderClose(OrderTicket(),OrderLots(),Bid,3);


--------------------------------------------------------------
//---------allow one action per bar
put this at end of program before the return() command


bool NewBar()
{
if(PreviousBar<Time[0])
{
PreviousBar=Time[0];
return(true);
}
return(false);
}

 
samirgham:

Hi

try this

datetime PreviousBar;
---------------------------------------

if(SignalBUY=="true"&&NewBar())

Ticket=OrderSend(Symbol(),OP_BUYxxxxxxxxxxxxxxxxxxxxxxx
------------------------------------------------------------------
if(SignalSELL=="true"&&NewBar())

Ticket=OrderSend(Symbol(),OP_SELLxxxxxxxxxxxxxxxxxxx
-------------------------------------------------------------------
to close open orders either opened sell or buy


if (PreviousBar<Time[0] || (your exit signal according to your indicators))
OrderClose(OrderTicket(),OrderLots(),Bid,3);


--------------------------------------------------------------
//---------allow one action per bar
put this at end of program before the return() command


bool NewBar()
{
if(PreviousBar<Time[0])
{
PreviousBar=Time[0];
return(true);
}
return(false);
}

ok thanks, I will try your code but I'm not getting into it :|

 
alexvorn2 wrote >>

thanks, but this code will make only one trade in a day but I want everyday...

I can use a method like if today is day of month 1 then, if 2 then, if 3 the, etc.. but it's to complicated I want to simplify.

hi

you have a sterategy that want if uses in oneday only one position open or want open position everyday and close at that day on specific time?what is your sterategy exactly?

A.M

 
aminkam:

hi

you have a sterategy that want if uses in oneday only one position open or want open position everyday and close at that day on specific time?what is your sterategy exactly?

A.M

everyday at a specific time of course ;)

 

hi

if specif time is determined correctly there is no problem.for example time(11:32:20 for open ) and (23:56:10 for close):

if(timehour(timecurrent())==11&&timeminute(timecurrent())==32&&timeseconds(timecurrent())==20)

{

ordersend(.....

..

.

}

like this order for close position.

Reason: