[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 497
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
embed code in the EA, I had something like this until I deleted it, I was using hourly timeframe
orderselect - select the last order in the history
take the time of its closing and pull out the closing hour
and before opening the order, set a condition that the current hour is NOT equal to the time of order closing from the history
Please help me with this problem, my TP variable is zeroed after the second price update, i.e., the advisor opens an order, and TP and Bid are both not equal to zero, then the price is updated again and TP is zero, although there is no such command in the code, I had a problem with pulling SL up, but now it turns out that the problem is in the definition of TP
int start()
{
//----
double TP;
double SL;
if (OrdersTotal()==0)
{
OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,Bid+4*Point);
OrderSelect(OrdersTotal()-1,SELECT_BY_POS);
TP=OrderTakeProfit();
}
Alert ("TP=" + TP);
Alert ("Bid=" + Bid);
if (OrdersTotal()>0)
{
if (TP-Bid<3*Point)
{
Alert ("Approaching TP by 1 or 2");
Alert ("TP=" + TP);
Alert ("Bid=" + Bid);
}
}
//----
return(0);
}
Please help me with this problem, my TP variable is zeroed after the second price update, i.e., the EA opens an order and displays values of TP and Bid, both are not equal to zero, then the price is updated again and TP is zero, although in the code, no such commands, I had a problem with pulling SL up, but now it turns out that the problem is in the definition of TP
double TP, SL;
int start()
{
//----
if (OrdersTotal()==0)
{
OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,Bid+4*Point);
OrderSelect(OrdersTotal()-1,SELECT_BY_POS);
TP=OrderTakeProfit();
}
Alert ("TP=" + TP);
Alert ("Bid=" + Bid);
if (OrdersTotal()>0)
{
if (TP-Bid<3*Point)
{
Alert ("Приблизился к ТП на 1 или 2");
Alert ("TP=" + TP);
Alert ("Bid=" + Bid);
}
}
//----
return(0);
}
Please advise how to open an order on a new bar only once ????
Read here: https://www.mql5.com/ru/forum/134437
Hello all!
There are two signals in the strategy: a primary and a secondary one. A trade is opened when the second signal appears no later than 12 hours later. Question: How can I teach my Expert Advisor not to react to the signal, if it appears after 12 hours? Please, if you can give a concrete code example
Hello all!
There are two signals in the strategy: a primary and a secondary one. A trade opens when the second signal appears no later than 12 hours later. Question: How can I teach my Expert Advisor not to react to the signal, if it appears after 12 hours? Please, if you can give me an example of the code
Hi Dmitry. For my part I am ready to offer you the following variant. For analogy, see the triggering of the trading criteria of this article - there are also two signals - namely - see after the second figure "The first thing to wait for on the DeMarker chart is the moment when the DeMarker crosses the fast and slow MA lines around 0.7 for a short position. This is the first preliminary signal. Then we wait for the crossing of the MA lines themselves. This is the main signal, after which the Taichi indicator readings can be taken. If the MA lines are not crossed, it is considered a false signal and the price movement will continue. Here is how it is implemented in my code - in the included inclusion of owls that are responsible for triggering of trade criteria.
The main trick is to work through the two below (at the end of) the inclusion by setting and resetting flags when one or the other trade criterion is triggered.
You will additionally save the current time when the main criterion is triggered using TimeCurrent, i.e. you will specify an expression of type x = TimeCurrent beforereturn(OP_BUY); orreturn(OP_SELL); where x is a global variable of datetime type by analogy in the firstint_op_DeMarker function. Then do the same with the secondint type_op_MA function... - there you memorize variable y = TimeCurrent;
Then in the block of trade criteria calculation you compare the value of these two variables with the plus sign (it turns out that you don't need the analogue of working with UTC values - instead you take a comparison of time of receipt of your two trade signals):
P.S. Plus I am sending you a function for the possibility to optimize the value of the working TF.
P.P.S. This is how this code structure is organized in my code. I do not exclude that there are much better code variants for fulfilling such conditions of the EA. :-)))
How do I calculate a profit on one currency pair in my EA?
For example, I have seven buy orders open on euros at different prices. How do I calculate a profit on euros without affecting other orders on other pairs? ????
use SelectOrder to scan all open orders
check the required pair (OrderSymbol)
then add the profit to any variable if it is the required OrderProfit
here is a link with useful functions https://docs.mql4.com/ru/trading/OrderSelect
on the left side there is a menu with operations, all of them are described there