Ask! - page 73

 

IN the following code, it is to delete my 2 pending orders:

OrderDelete(ticket1);

OrderDelete(ticket2);

Can someone just please write how to close open positions as simple as this?

Thank you,

---Julia---

 

Hi traders,

what is the code way for writing "triggered",like,ie.,

if buy_stop "triggered", then sell_stop deleted...something like that

---JULIA---

 

Hey traders,

I have this Ea, almost done, thanks to my wonderful forex-tsd traders, and when i run it, it only trades 1 time, is there a code that will keep the ea running more than 1 time, preferably like unlimited times?

Thanks,

---Julia---

 

it seems that his thread begins to smell a Dan's one...

 

Why isn't this in the EA Section

This is about EA's and should be in the EA section.

Thanks ND for the move

 

Detect the last result

Hello,

I create an EA.. i want to detect my last profitable/loss closed order, is this possible to accomplish ?

Thanks

Vic

 
veematics:
Hello,

I create an EA.. i want to detect my last profitable/loss closed order, is this possible to accomplish ?

Thanks

Vic

Look at here: https://www.mql5.com/en/forum/177667

Edit: Sorry, this does not answer your question.

Yes, it is possible, here is a example code:

datetime LastProfit=0, LastLoss=0;

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

{

if(!OrderSelect(i, SELECT_BY_POS)) continue;

if(OrderSymbol() != Symbol()) continue;

if(OrderMagicNumber() != Magic) continue;

if(OrderCloseTime() > LastProfit && OrderProfit() >= 0)

{

LastProfit = OrderCloseTime();

LastProfitTicket = OrderTicket();

}

if(OrderCloseTime() > LastLoss && OrderProfit() < 0)

{

LastLoss = OrderCloseTime();

LastLossTicket = OrderTicket();

}

}

// Now do what you want with both tickets

 
Benjimang:
Hi everyone!

I have used the Expert Advisor Builder at sufx.com to create an EA. It has two limitations that I am trying to get rid of:

1. only opens 1 trade at a time. I can get it to have two trades open at once, but I can't get it to open a buy order and a sell order simultaneously.

2. seems to take sell orders as a preference over buy orders. This wouldn't really be an issue if problem number 1 was solved.

Here is the peice of code that seems to be holding me up:

//Check position

bool IsTrade = False;

for (int i = 0; i < Total; i ++) {

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if (OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {

IsTrade = True;

if (OrderType() == OP_BUY) {

//Close

Any suggestions? I'd like to let it open as many trades as possible, and be able to open buy and sell orders simultaneously if the indicators say so.

Cheers for the help,

Benjimang

PLEASE, does ANYONE know what to do with the above code? Have I identified the right piece of code here? Surely someone must know something...?

 
Benjimang:
PLEASE, does ANYONE know what to do with the above code? Have I identified the right piece of code here? Surely someone must know something...?

This is wrong, both buy orders and sell orders are mixed :

if (OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {

IsTrade = True;[/PHP]

You should have something like this :

[PHP]

bool IsSellTrade = false;

bool IsBuyTrade = false;

for(...

...

if (OrderType() == OP_SELL) IsSellTrade = true;

if (OrderType() == OP_Buy) IsBuyTrade = true;

Of course when you test to open a trade, you must test separately IsSellTrade and IsBuyTrade.

 

Security - Encoding Account Number

I want to run my EAs from a VPS.

For security purposes I want to encode my brokerage account number and upload the compiled version.

Can someone please describe the code to add?

Thanks.