Ask! - page 74

 
WNW:
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.

The code is here (on the first page of this thread https://www.mql5.com/en/forum/174194 ).

Besides there is EA in elite section with account protection coded.

1. MA_ExpertProfit.mq4: it is the same EA but it will close the orders in s/l or t/p only.

2. MA_ExpertProfit_all.mq4: it will close the order on s/l or t/p, or on the other crossing signal. This EA should work on particular account only. Just change the line "int Account = 111111;" to your account number inside the code. For example your account is 1235463. So this line should be like this:

int Account = 1235463;

3. MA_ExpertProfit_noacc.mq4: it is the same with item # 2. But without any account and it may work in any account (i mean account in Metatrader).

If you are not elite member so I may post the codes here but it is very well-known subject described here in public: https://www.mql5.com/en/forum/174194

More difficult is to create the licence number, set the broker,

UserVerification(Confirmed)

and so on.

As I know some coders are very professional with this priotecting issues so you may see them from this thread https://www.mql5.com/en/forum/174194

 

Magic Number

int j,totalbuy;

totalbuy=OrdersTotal();

for(j=0;j<totalbuy;j++)

OrderSelect(j, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderSymbol()==Symbol())

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);

return(0);

}

How do you reference the magic number in the above close. Likewise, in a order to buy?? Thank you in advance for responding!

Dave

<<<

 
int j,totalbuy;

totalbuy=OrdersTotal();

for(j=0;j<totalbuy;j++)

OrderSelect(j, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber() == Magic)

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);

return(0);

}
 

Thanks for responding!!

Dave

 

Question on Logic Flow

How do I bounce around between logic statements if it turns out that I have to loop back to a certain earlier logic statement until a condition is met, and if it is met then I will have to branch to another even earlier logic statement??

I know in simple basic, I would use a goto statement.

Dave <<<
 

Color changing in ObjectCreate Statement

I am trying to change the profit display color from Lime to Red based upon the profit of the tickets. I have run into the reserved words Lime and Red and cannot figure out how to get these colors changed in the ObjectSetText statement.

string Lime;

string Red;

string PlusMinusColor = "";[/PHP]

if (BuyProfit+SellProfit>=0) PlusMinusColor=Lime;

if (BuyProfit+SellProfit<0) PlusMinusColor=Red;[/PHP]

[PHP]

Profit1=BuyProfit+SellProfit;
[PHP] ObjectSetText("Profit1", DoubleToStr(Profit1,2), 16, "Arial",PlusMinusColor );

Can somebody help me on this??

Dave <<<

Thanks for all the help - I really mean it!

 

Showing Profit or Loss in Big Letters On Graph

I figured it out!

 
double BP(j)=0,BP=0,SP=0;[/PHP]

[PHP]int j,TotalOrders;

TotalOrders=OrdersTotal();

for(j=0;j<TotalOrders;j++)

OrderSelect(j, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber() == OrderID && OrderCloseTime() == 0)

{

BP(j) = OrderProfit() + OrderSwap() + OrderCommission();//BuyProfit - GETTING ERRORS ABOUT BP(j)

}

else

if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber() == OrderID && OrderCloseTime() == 0)

{

SP(j)= OrderProfit() + OrderSwap() + OrderCommission();//SellProfit - GETTING ERRORS ABOUT SP(j).

}

BuyProfit=BuyProfit+BP(j); // GETTING ERRORS!

SellProfit=SellProfit+SP(j); // GETTING ERRORS!

return(0);

I tried at coding this, but as one can see I have it not quite right.

Can one of you fine coders lend me a hand at fixing this????

Dave <<<
 
1Dave7:
double BP(j)=0,BP=0,SP=0;[/php][php]int j,TotalOrders;

TotalOrders=OrdersTotal();

for(j=0;j<TotalOrders;j++)

OrderSelect(j, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber() == OrderID && OrderCloseTime() == 0)

{

BP(j) = OrderProfit() + OrderSwap() + OrderCommission();//BuyProfit - GETTING ERRORS ABOUT BP(j)

}

else

if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber() == OrderID && OrderCloseTime() == 0)

{

SP(j)= OrderProfit() + OrderSwap() + OrderCommission();//SellProfit - GETTING ERRORS ABOUT SP(j).

}

BuyProfit=BuyProfit+BP(j); // GETTING ERRORS!

SellProfit=SellProfit+SP(j); // GETTING ERRORS!

return(0);

I tried at coding this, but as one can see I have it not quite right.

Can one of you fine coders lend me a hand at fixing this????

Dave <<<

If you wanted "BP" to be an array, then you have to use brackets "[ ]" not paranthesis "( )" as in:

BP[j]

... not ...

BP(j)

... which looks like a function call.

 

Profit problem.

Something simple that I need help on.

double EntryPoint = 1.000;

int MiniLots = 1;

Currency Closed at .880

I have tried the following to get a profit value without success:

Profit=EntryPoint*MiniLots - ( I have tried minus Ask, Bid, Close[0]) *100;

All I get is Profit=0.00 when I should get Profit=12.00. I are confused?

I would not be amazed that the answer is because the Market is Closed??

What say you as to what my problem is with this???

Dave <<<
Reason: