Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 342
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I don't get it here...
The lot size should increase exponentially (with multiplier 2) if a second unidirectional order is opened.
This is the result.
then like this
you get a result like this
Then that's it.
Thanks, I get the idea... I've got it figured out.
what is that line for?
datetime o;
Here's another question. I have a trailing order. When 1 unidirectional order is open, everything works fine, if more, it doesn't work for some reason. Why?
{
for(int i = 0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
{
if (OrderType() == OP_BUY)
{
if(Bid - OrderOpenPrice() > TrailingStop*Point)
{
if (OrderStopLoss() < Bid - (TrailingStop + TrailingStep)*Point)
{
SL = NormalizeDouble(Bid - TrailingStop*Point,Digits);
if (OrderStopLoss() !=SL)
OrderModify(OrderTicket(),OrderOpenPrice(),SL,0,0);
}
}
}
if (OrderType() == OP_SELL)
{
if(OrderOpenPrice() - Ask > TrailingStop*Point)
{
if (OrderStopLoss() > Ask + (TrailingStop+ TrailingStep)*Point)
{
SL = NormalizeDouble (Ask+TrailingStop*Point,Digits);
if (OrderStopLoss() !=SL)
OrderModify (OrderTicket(), OrderOpenPrice(), SL,0,0);
}
}
}
}
}
}
}
Here's the .cpp file of the project, have a look at it and after a couple of Google and Yandex searches, I didn't find anything at all brainy, it's generally understandable. It even seems simple.
But how does it work? I'm not quite sure how to refer to this ddl - from the EA's code? How? First, it looks like this #include <GetIntValue>.
It's roughly like this. To make it work, you need to compile the dll and put it in the experts/libraries folder (read the help and tutorial, it's detailed there).
2. When calling the dll, you don't have to keep studio on, right? So how is it executed?
Here's another question. I have a trailing order. When 1 unidirectional order is open, everything works fine, if more, it doesn't work for some reason. Why?
{
for(int i = 0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
{
if (OrderType() == OP_BUY)
{
if(Bid - OrderOpenPrice() > TrailingStop*Point)
{
if (OrderStopLoss() < Bid - (TrailingStop + TrailingStep)*Point)
{
SL = NormalizeDouble(Bid - TrailingStop*Point,Digits);
if (OrderStopLoss() !=SL)
OrderModify(OrderTicket(),OrderOpenPrice(),SL,0,0);
}
}
}
if (OrderType() == OP_SELL)
{
if(OrderOpenPrice() - Ask > TrailingStop*Point)
{
if (OrderStopLoss() > Ask + (TrailingStop+ TrailingStep)*Point)
{
SL = NormalizeDouble (Ask+TrailingStop*Point,Digits);
if (OrderStopLoss() !=SL)
OrderModify (OrderTicket(), OrderOpenPrice(), SL,0,0);
}
}
}
}
}
}
}
Because you need to pass parameters into the function, try this
bool IfProfTrail=false; // Use only for profitable positions - Breakeven mode
int TrailingStop=0; // Trailing distance = 0 - minimum allowed
int TrailingStep=1; // Trailing distance step
Thank you very much!
Now I understand what the problem is.
For the purchase I used:
As far as I know, buying is ask, but iClose(Symbol(),Period(),0) takes prices from bid. This may be the reason for error.
But here the question arises, because the EA is not a Pips based EA, the price was in the buy zone for a long time and updated with every tick.Now I use the following combination:
Why does not the trade open? It turns out that the EA stops on the error and does not see further price movement?
I took the template for my Expert Advisor from https://c.mql5.com/mql4/book/mq4/experts/tradingexpert.mq4
In your opinion, should I add to the error handling function in this EA a check for 129 and 138 errors?
If yes, how to do it?
At a minimum, you must have your own function for opening positions/setting orders that will handle all errors. This is where you need to get the latest prices.
I haven't looked at any blanks. But I will say: the EA needs to handle all the errors returned by the server. And that's not enough. It should be able to pick up its positions after any unexpected situation without loss of functionality and without the algorithm failure, and continue its work as if nothing extraordinary had happened.
At the very least you should have your own function for opening positions/setting orders that handles all errors. It is where you need to get the latest prices.
I haven't looked at any blueprints. But I will say: you need to handle all errors returned by the server in your EA. And this is not enough. It must be able to pick up its positions after any unforeseen situation, without losing functionality, without any failure of its algorithm, and continue its work as if nothing extraordinary had happened.
The template is taken from a textbook. I'm not really good at error handling functions.
On order opening, there is RefreshRates(); (I replaced Bids and Asks through Market Info as suggested).
And error handling function:
I wanted to ask. I want to ask: May I add another line from 129 error to it?