[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 262

 
Valdemar:

Gentlemen, can you tell me where I made a mistake when I inserted this timing function into my EA code?

The compiler just flooded me with errors.



In the place where you declared a function inside another function:

int init()
  {
  
bool isTradeTimeInt (int hb=05,int mb=50,int he=23,int me=00) 
    {
 
Roll:

See the 10th parameter of the specified function. Set to 0.

OrderSend(g_symbol_284, OP_BUY, Lots, g_ask_528 - gi_164 * g_point_400, Slippage, l_price_40, l_price_32, 0, g_magic_112, "Newest", MediumBlue);

found this line and what to change there ?

 
Starting:

The use is simple - I run the script...

Which is what you needed to prove. That is, you need code that will determine the right order. There are dozens of such situations, and you can't save a special function for each one to simplify the code. It must be written for each case.
You can find examples of similar functions here: Useful functions from KimIV.

If off-the-shelf ones don't fit, you can build your own one by analogy with existing ones.
 
Bicus:

Here the calculation is based on price inertia. I.e. stop loss of the first order is triggered, the second order is at a profit with a value a little less than the loss. If the price moves in the same direction some more, then yes, we may be in the total profit.

But, imho, this strategy is not worth a bite.

Yeah, right! Guessing if it will go a few more pips in the profitable direction :)
 
granit77:
This is exactly what we have to prove. In other words, you need a code that would find the necessary order. There are dozens of such situations, and we can't provide a special function for each of them to simplify the code. It must be written for each case.
You can find examples of similar functions here: Useful functions from KimIV.

If off-the-shelf ones don't fit, you can build your own one by analogy with existing ones.


I think I didn't quite get the point across.

Assertion 1. Every code, after the pending order triggering, when accessing the date of opening of this order (that has become marketable at the moment of such triggering), will obtain the open date equal to the date of pending order placing - this is how the OrderOpenTime() function works.

Assertion 2: You can't remember the exact time of pending order triggering, without an Expert Advisor that constantly monitors the state of orders on the account.


Possible Solution 1. We can try to run from the date of setting the pending order to the current date and note the time of the first crossing of the open price and the trigger level.

This will be more or less exact time, but there is a big minus: the spread. Since we do not record the spread in the history (I am not taking the tick history with spread taken from Dukas, for example, since I am not trading in Dukas and we need to collect and record it), the order may have triggered much earlier, when the price almost touched the open level but did not cross it, and the order was opened due to the spread expansion, not later, when we actually saw the price crossing the pending order setting line.


The most probable solution is to create an Expert Advisor, put it on the chart and monitor the orders in the account. I do not want to do it for some reasons and there are also disadvantages associated with possible problems during breaks in the EA operation.


The functions, which you have referred to. You have provided a link to the OrderOpenTime() function. For the delayed orders it will be the date of their creation, and not of their triggering. Therefore, the existing functions are not suitable. And there is no way to combine them, since they still refer to OrderOpenTime() for the order open date.

 
Pyxlik2009:

OrderSend(g_symbol_284, OP_BUY, Lots, g_ask_528 - gi_164 * g_point_400, Slippage, l_price_40, l_price_32, 0, g_magic_112, "Newest", MediumBlue);

found this line and what to change there ?

Print the parameters and see
 
Pyxlik2009:

OrderSend(g_symbol_284, OP_BUY, Lots, g_ask_528 - gi_164 * g_point_400, Slippage, l_price_40, l_price_32, 0, g_magic_112, "Newest", MediumBlue);

found this line and what to change there ?

You have the tenth parameter "Newest", while the number you need is the expiry time of the order
 

here's the whole line

if (!(AccountFreeMarginCheck(g_symbol_284, OP_BUY, Lots) <= 0.0 || GetLastError() == 134/* NOT_ENOUGH_MONEY */)) g_ticket_352 = OrderSend(g_symbol_284, OP_BUY, Lots, g_ask_528 - gi_164 * g_point_400, Slippage, l_price_40, l_price_32, 0, g_magic_112, "Newest RX-1", MediumBlue);
 
 
Pyxlik2009:

here's the whole line

Again:

Documentation:

int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

Your tenth parameter in the "Newest" string is not a number. That's why there is an error

 

PapaYozh
:


Where you declared a function within another function:

int init()
  {
  
bool isTradeTimeInt (int hb=05,int mb=50,int he=23,int me=00) 
    {


Thank you for your feedback, dear PapaYozh,but I have inserted this function into int start(), but the result of the compiler does not change anyway.

int start()
{
int H,M,Ticket;
double Max,Min,
Max1,Min1,
TP,
Total;

bool isTradeTimeInt(int hb=07,int mb=55,int he=23,int me=00) 
    {
  datetime db, de;           // Время начала и окончания работы
  int      hc;               // Часы текущего времени торгового сервера

  db=StrToTime(TimeToStr(TimeCurrent(), TIME_MINUTES)+" "+hb+":"+mb);
  de=StrToTime(TimeToStr(TimeCurrent(), TIME_MINUTES)+" "+he+":"+me);
  hc=TimeHour(TimeCurrent());
  if (db>=de) {
    if (hc>=he) de+=24*60*60; else db-=24*60*60;
  

  if (TimeCurrent()>=db && TimeCurrent()<=de) return(True);
  else return(False);
}
 

H=Hour();
M=Minute();
Total=OrdersTotal();
if(Total==0)
{
if(isTradeTimeInt==true)
{
   Max=High[iHighest(Symbol(),PERIOD_M5,MODE_HIGH,12,0)];
   Min=Low[iLowest(Symbol(),PERIOD_M5,MODE_LOW,12,0)];
In the end the compiler showed me these errors, and I think it is referring to the wrong variable definition?

I apologize for any inconvenience, incomprehension, after all, just beginning to gain experience in such a not easy matter, and I think thanks to this forum and the people who responded here, continue to develop and improve their skills, thank you.



Reason: