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
Yeah, that's about right. Just haven't tested it that way yet.
Try it...
Added by
if (trans.order != my_order_ticket)
{
if(trans.symbol==Symbol())
{
if(проверяем магик)
{
//Сработал SL или TP
}
}
}
break;
What's wrong with this method?
if (trans.order != my_order_ticket)
{
//Сработал SL или TP
}
break;
Because the last known SL and TP positions may not coincide with the deal price and there will be nothing to compare it with.
And you don't like to share your codes, but you look at other people's ones with great pleasure...
This will not always work:
double G_LastSLlevel = 0.0; //Последний известный уровень SL
double G_LastTPlevel = 0.0; //Последний известный уровень TP
//——————————————————————————————————————————————————————————————————————————————
void OnTradeTransaction (const MqlTradeTransaction &trans, // структура торговой транзакции
const MqlTradeRequest &request, // структура запроса
const MqlTradeResult &result) // структура ответа
{
if(trans.type == TRADE_TRANSACTION_DEAL_ADD)
{
if(PositionsAny (G_Symbol))
{
G_LastSLlevel = GetSLlevel (G_Symbol);
G_LastTPlevel = GetTPlevel (G_Symbol);
Print ("SLlevel: " + G_LastSLlevel);
Print ("TPlevel: " + G_LastTPlevel);
}
if(trans.deal != G_LastTicket)
{
if(trans.price == G_LastSLlevel)
Print ("Сработал SL");
if(trans.price == G_LastTPlevel)
Print ("Сработал TP");
}
}
}
Try it...
What's wrong with this method?
You have to keepmy_order_ticket
Do you even know what you are talking about?
my_order_ticket - this order has a place to live if you have
and you are obliged to keep them.
You have to storemy_order_ticket
I'll give it a try sometime. Thank you. (chuckles) I'm busy with other tasks at the moment.
Not only that.
Yes, it is actually proposed to maintain and store the actual environment itself, comparing it with what OnTradeTransaction produces.
This is not a solution.
Yes, it is actually proposed to maintain and store the actual environment itself, comparing it with what OnTradeTransaction produces.
This is not a solution.
You're just not following the topic closely. :)
The original topic starter wrote:
"How do I know inOnTradeTransaction() that SL/TP has triggered? "
What should be the solution?
You can not remember or check anything at all, except the position itself, provided that
You did not operate any other orders
if (!PositionSelect(Symbol())
{
//Сработал SL или TP
}
break;
You're just not following the topic closely. :)
The original topic starter wrote:
You are the one who is rather inattentive, I am notthe topic starter.
You should also show code like this:
void OnTradeTransaction (const MqlTradeTransaction &trans, // структура торговой транзакции
const MqlTradeRequest &request, // структура запроса
const MqlTradeResult &result) // структура ответа
{
}
Well, what's the big deal - who needs it, finish it himself, do not like it - there is a job! Is it so?