[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 841

 
etroplus:

Please advise!

Is there a function that returns the profit value of an open position in pips?

(Bid - OrderOpenPrice())/Point;    //для ордеров BUY
(OrderOpenPrice() - Ask)/Point;    //для ордеров SELL
 
webgreck:

check whether there has been a date change and use the functions

MarketInfo(Symbol(),MODE_SWAPSHORT);
MarketInfo(Symbol(),MODE_SWAPLONG);
 
alsu:

check if the date has been changed and use the functions


How can you control the date? It doesn't change. Look at the screenshot.

 
webgreck:


I have a lot of orders that need to be worked out differently what kind of trailing what kind of fixed objectives and set parity but I can not cope with this task because after the deal is closed and opens because of the swap, it changes the ticket number, so I can not use the ticket number to identify the position to know what to do with it.

Please advise how to deal with swap and how to identify a trade and know if I have already set parity on it or not etc.


In these cases the "order magic number" can be actively used.
 
abolk:

In these cases, the Magic Number Order can be actively used.

I already use the magic number to identify the three types of signals ... If i have already placed parity for a pose, i should probably think of a way to use the magic number to determine if i have already placed parity. For example, we can give a magic number value to an order, but magic number can not be edited ... or am i wrong ? we can only give it a value when setting the order, but what can we write in the magic number, so we will be able to check if parity has been already set for the order?
 
webgreck:

I already use it to identify the three types of signals ... If your algorithm is closely related to order identification, then I need to know your algorithm to help me in this case.

If your algorithm is closely related to order identification, then we should know your algorithm to help you in this case.
 
abolk:

If your algorithm is closely connected with identification of orders, then to help you in this case, we need to know your algorithm.


I was afraid of this question. The system is quite complicated and difficult to describe in 2 words. I don't want to post the code either as there are thousands of lines of code and no one will understand or worry about them...

I thought there were some common flexible methods to implement order identification ... The magic number is basically what it is for, but it cannot be edited to remember that the order has already been done this or that ...

Maybe it is still possible to edit a magic number?

 
webgreck:


How do you control the date? It doesn't change. Look at the screenshot.

how does it not change? on your screenshot it was january 13, at 00:00 14th swap floz - swap open
 
webgreck:


Yes, this is the question I was afraid of) because the algorithm is not simple ... the system is quite complex and can not be described in 2 words. And to put the code also makes no sense as there are thousands of lines of code and no one will understand and delve into them ...

I thought there are some common flexible tricks to implement identification of orders ... We have a magic number for this purpose, but we cannot edit it to remember what has already been done with this order ...

Maybe it is possible to edit the magic number of an order?


And you convert the opening time to int - there you have two magiks for one position. If you haven't set parity, there is only magik. If you have already set parity, the variable responsible for the presence of set parity will be equal to the time of the position opening, which is denoted by int and the position will have a magic number... :)
Dance from there...
 

Hi!

I can not understand why the opened orders are not modified, the modification condition is a profit above 5 pips.

//+------------------------------------------------------------------+
|| news trade.mq4 |
//| Copyright © 2010, MetaQuotes Software Corp.
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net"


extern bool In_BUYSTOP=true;
extern intProfit_buy=100;
extern int StopLoss_buy=5;
extern double Lots_buy=0.01;
//+------------------------------------------------------------------+
extern bool In_SELLSTOP =true;
extern inttern TakeProfit_sell=100;
extern int StopLoss_sell =5;
extern double Lots_sell =0.01;
extern int LevelProfit = 25; // - Profit level in points, which is necessary to reach in order to transfer its stop to the Breakeven level.
extern int LevelWLoss = 1; // - Breakeven level in points, to which the stop position will be moved after its profit reaches the LevelProfit level in points.

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
int profitbuy=((Bid - OrderOpenPrice())/Point); // BUY
int profitsell=((OrderOpenPrice()- Ask)/Point); // SELL
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
//----
{
int ticket;
if (Bid >iHigh(NULL,PERIOD_D1,1))
{
if(OrdersTotal() < 1)
ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots_sell,iHigh(NULL,PERIOD_D1,1),3,iHigh(NULL,PERIOD_D1,1)+StopLoss_sell*Point,iHigh(NULL,PERIOD_D1,1)-TakeProfit_sell*Point,Hour() == 21 && Minute() == 59);
if(OrderSelect(1, SELECT_BY_POS,MODE_TRADES)==true)
{
int profitsell=((OrderOpenPrice()- Ask)/Point);
if (profitsell>5)
ticket=OrderModify(OrderTicket(),OrderOpenPrice(),0,OrderTakeProfit(),0,Blue);
return(0);
}
}
if (Ask <iLow(NULL,PERIOD_D1,1))
{
if(OrdersTotal() < 1)
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots_buy,iLow(NULL,PERIOD_D1,1),3,iLow(NULL,PERIOD_D1,1)-StopLoss_buy*Point,iLow(NULL,PERIOD_D1,1)+TakeProfit_buy*Point,Hour() == 21 && Minute() == 59);
if(OrderSelect(1, SELECT_BY_POS,MODE_TRADES)==true)
{
int profitbuy=((Bid - OrderOpenPrice())/Point);
if (profitbuy>5)
int stopmodify=OrderOpenPrice();
OrderModify(OrderTicket(),OrderOpenPrice(),stopmodify,OrderTakeProfit(),0,Blue);
return(0);
}
}
//oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
return(0);
}
//+------------------------------------------------------------------+
Reason: