Ask! - page 137

 

You could accomplish this by just putting a comment like "First Trade" in the comments field then checking for it later when you want to close.

Lux

 
primajaya:
I still don't know about the logic 1st and 2nd EA to open trades...

But perhaps this can help you..

Try to combine the two ea's into one single EA..

So the EA should be has two signal to open trades:

1st signal from 1st EA and 2nd signal from the 2nd EA..

you may use OrderMagicNumber() as the identity for each open trades made by two signals...

for example:

if open trades by 1st signal then -- magic number is 1111

if open trades by 2nd signal then -- magic number is 2222

So if we want to close trade from the second signal we can use OrderMagicNumber() as identity to close:

Hope it helps...

Pj

Hi primajaya,

The 2nd EA is close trade only (not open any trades) it's "CloseTrades_After_Account_Profit_Reached" EA. Here I want to add this EA in to the 1st EA and set up it close at xxx profits.

Thanks for your help!

 
Bill FX:
Hi primajaya,

The 2nd EA is close trade only (not open any trades) it's "CloseTrades_After_Account_Profit_Reached" EA. Here I want to add this EA in to the 1st EA and set up it close at xxx profits.

Thanks for your help!

Oh.. that will more simple..

What you should do is create a function to close the trade

for example:

void closetrade()

{

for (int i=OrdersTotal()-1;i>=0;i--)

{

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

.....condition to close trade.l

{

close the trade;

}

}

}

and then you can call the function into:

int start()

{

.....bla.bla bla..

closetrade();

}

Hope it helps

Pj..

 

Can anyone help me please

hi

First thank you everyone for your hard work.

I want to know how can I program any EA to close at First, second or third TakeProfit. The EA should not trade any more after First, second or third Take profit hit.

eg Buy

Buy

Sell

Sell

T/p

NO MORE TRADING

Thank you

 

Can anyone help me please

hi

First thank you everyone for your hard work.

I want to know how can I program any EA to close at First, second or third TakeProfit. The EA should not trade any more after First, second or third Take profit hit.

eg Buy

Buy

Sell

Sell

T/p

NO MORE TRADING

Thank you

 
primajaya:
Oh.. that will more simple..

What you should do is create a function to close the trade

for example:

void closetrade()

{

for (int i=OrdersTotal()-1;i>=0;i--)

{

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

.....condition to close trade.l

{

close the trade;

}

}

}

and then you can call the function into:

int start()

{

.....bla.bla bla..

closetrade();

}

Hope it helps

Pj..

Hi primajaya,

I am not a programmer, I can not do this. Could you so kink to create this function for me ?

Thanks for your help!

 
Bill FX:
Hi primajaya,

I am not a programmer, I can not do this. Could you so kink to create this function for me ?

Thanks for your help!

What did you mean with this?

it's "CloseTrades_After_Account_Profit_Reached"

Account Profit = Now Balance - Starting Balance

or Account Profit = Order Profit

Please clarify

 
primajaya:
What did you mean with this?

it's "CloseTrades_After_Account_Profit_Reached"

Account Profit = Now Balance - Starting Balance

or Account Profit = Order Profit

Please clarify

Hi primajaya,

"CloseTrades_After_Account_Profit_Reached" is an EA (on the attach file). I want to combine this EA in to another EA.

Thanks for your help!

 

Calculate the shortest bar in a given range or TF?

Can someone tell me how to code for the shortest bar (difference between high and low per bar) within a given range of say the last 6 or 12 bars, or the shortest bar within a 30 minute or hour period?

I want to take the shortest difference and use that as a take profit in a script.

Thanks in advance

 

Straight from the help file...

int iLowest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

Returns the shift of the least value over a specific number of periods depending on type.

Lux

Reason: