Questions from Beginners MQL5 MT5 MetaTrader 5 - page 665

 
fxsaber:
There is something wrong with setting the expiry.

Thank you. I have managed to open positions on gold, but have encountered an error in my class when working with orders - array overflow - this has never happened in MetaTrader 4.

fxsaber:
Watching the tester's history through the converted MT4 script from 2006. It shows everything as conveniently as MT4.

Is this script available in the public domain?

 
-Aleks-:

Is this script in the public domain?

It's the poor guy who hasn't been noticed.

Forum on trading, automated trading systems and strategy testing

MetaEditor build 1463

fxsaber, 2016.11.04 19:12

Here is my story in MT5 representation

I have an excellent understanding of trades, position, order. I write complex pretzels in pure MQL5. But this is the story view I can't digest at all. My head is spinning. I cannot ask simple questions I haven't even thought about in MT4.

So I converted the 2006 script, and it shows the same story like this

Everything is right in the palm of my hand. It is clear and elementary! Immediately clear who, where, when and to what extent. You can see all the connections, etc.


 

Thanks! Only thing is, I'm dumb as to where to take it to get the report - threw it on the last chart, got the live trading report...

 
-Aleks-:

Thank you! Only thing is, I'm confused as to where to take it to get the report - threw it on the last chart, got the live trading report...

Do you need it for the tester?
 
fxsaber:
For a tester?
For a tester would be good - I'm honestly still shocked by the tester in five - I think the interface is flawed...
 
-Aleks-:
For a tester it wouldn't be bad - I'm honestly still shocked by the tester in Five - I think it's just a flaw in the interface...
Take it from here, starting with OnTester.
 
fxsaber:
Take it from here, starting with OnTester.
Thank you, I will try it out.
 

Good day to all!

I want to test one idea on MT-4, but MT-4 is not a multicurrency tester, and MQL5 language is still difficult for me to understand,

Please advise whether it is technically possible to do the following.

At one and the same time, for example at 00:00:00 I open two buy orders with the same parameters but for different instruments.

I want to close these orders at Take Profit (only at TP, but at SL) according to one of the two conditions, or precisely according to the one that first that will occur on the market.

THE FIRST ORDER CLOSING CONDITION

One of the orders which have been closed first reaches TP level (the second order remains open after the first one has been closed)

If the first condition triggers on one order, the second condition is canceled completely.

THE SECOND CONDITION IS TO CLOSE THE ORDERS ON TR

Both orders must be closed simultaneously when the total profit of the account(AccountProfit( ) = $20 (for example: 10+10, or 15+5, or 17+3, etc.).


These conditions for closing orders can be mutually exclusive.

THE FIRST MUTUALLY EXCLUSIVE

If one order reaches the TP level (first condition), the account profit will not be equal to $20 (second condition), since the other order can show a negative value when the first order reaches the TP level.

SECOND CONDITION

If the second condition triggers, the first condition cannot be met, since one of the two orders (or both orders) will not reach the TP level

QUESTION .

Despite the mutual exclusions:

1 Will one of the orders close at the TP

2 Will both orders be closed if AccountProfit( )==20

I may be wrong in my code to solve my problem.

I would be very grateful if you could make the required changes, if my task can in principle be solved.

Thank you.

int ot;
double X ;
int Ticket;
int Ticket1;

int start()                                            
{
X = AccountProfit( )   ;
ot = OrdersTotal();
if(ot ==1)
if( Hour()== 0&& Minute()==0 )
{
Ticket=OrderSend("GBPUSD",OP_BUY,0.1,Ask,1,Bid-400*Point,Bid+200*Point,"jfh",123 );
Ticket1=OrderSend("EURUSD",OP_BUY,0.1,Ask,1,Bid-400*Point,Bid+200*Point,"jfh",123 );
}                                          

if(X >20.0)
OrderClose(Ticket,0.1,Bid,3,Red);
OrderClose(Ticket1,0.1,Bid,3,Red);
return;
}



 
ANDREY:

..............

QUESTION

Notwithstanding the mutual exclusions:

1 Will one of the orders be closed at the TP

2 Will both orders be closed if AccountProfit( )==20

I may be wrong in my code to solve my problem.

I would be very grateful if you could make the required changes, if my task can in principle be solved.

Thank you.

SL and TP are used in manual trading.

In automatic trading, it would be better to use close conditions instead of SL and TP and open orders with SL=0 and TP=0.

In your case these are separate conditions for closing profitable and losing orders.

You can use any of these conditions in your Expert Advisor, as they say any of your desires will be fulfilled according to your order.

 
new-rena:

SL and TP are used in manual trading.

In automatic trading, it is advisable to use close conditions instead of SL and TP, and open orders with SL=0 and TP=0.

In your case these are separate conditions for closing profitable and losing orders.

The Expert Advisor may contain any conditions, as they say - any of your wishes will be fulfilled according to your order.

Thank you very much.

I am trying to study MQL5 but it certainly looks similar to MQL4, but it has many differences that are still difficult to find in my brain.

If it's not too much trouble, could you rewrite my code for MQL5 and compare it for me to start understanding the difference (for now I only see the difference, but do not understand it).

Thank you.

Reason: