Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 980

 
Igor Makanu:

I've seen it, I doubt that he will be able to unset everything himself, that's why I suggested using the proven method of closing a selected order via OrderSelect() with ClosePosBySelect() - he can do that, at least I've seen him build codes for himself with the constructor ))))

ZZY: I have another suspicion that he closes one order twice, but Kim's f-function prints in the log, no like separate loops to close on the 2nd condition

:-) Yes.

Artyom Trishkin:

It is clear that Igor's functions will do everything for the user (and even then, some users manage to make a mistake with them too). But then he himself will not learn how to do anything. Although, of course - their choice.

Gentlemen - I'll write here tonight...

It seems that the lifetime of the account has expired. It's just not the usual error...

The screenshot is just that.

P.S. I can and am trained to program, if anything! :-) it's to the question of collecting code constructor!!!!!!!!!!!!!!! :-)

PPS don't raise the beast in me, please, the jerk... :-)

I'M GOOD AT CODE AND NOT ONLY THAT, I'M GOOD AT BIDDING TOO!

 
Roman Shiredchenko:

:-) Yep.

Gentlemen - I'll post here tonight...

It looks like the lifetime of the account has expired there. It's just not the usual error...

The screenshot is just that.

P.S. I can and am trained to program, if anything! :-) it's to the question of collecting code constructor!!!!!!!!!!!!!!! :-)

PPS do not raise the beast in me, please, the jerk... :-)

I'M A SHIAT IN CODE AND NOT ONLY THAT, IN BIDDING TOO!

Lots of letters. What's the point? There is no check to get a price. And the error of closing positions at zero prices.

That's the thing about "able and trained".

 
Artyom Trishkin:

He's got a zero price closing there.

Consequently, I have to monitor what MarketInfo-function has returned, but there is no control. However, as usual on the four, some people are used to write - something received, what - have not checked, but sent the argument.

YEAH. I saw that.

It looks like the lifetime of the account has expired there...

When I tried to close it manually - it returned "GENERAL ERROR" on the screen.

Earlier - it seems that the function worked, I just didn't have time to check it.

The function is written correctly. Yes - slipage in spreads, so what?

I will post the TOTALS here tonight.

Reloaded the trades into a new account.

 
Roman Shiredchenko:

Gentlemen - I'll post here tonight...

It looks like the life of the account has expired. It's just an unaccustomed error...

wrong one! why should i guess what the mistake is if you printed it out? - Or was the question originally meant for telepaths...no, tushkas? )))


Roman Shiredchenko:

When trying to close manually - it came back on the screen in the box - "GENERAL ERROR".

Maybe the trading flow is busy, maybe you get requotes, that's why the general error could mean anything - the same "mess" happened on insta last year, i used to close orders exactly for 5 minutes - and the code should be closed with all the checks and printers ;)

 
Artyom Trishkin:

A lot of letters. What's the point? There is no price receipt check. And there is no error in closing positions at zero prices.

That's the "can do and learn" thing.

Yes because I'm already writing from a sheet of paper in Word - gud. at once. I DO NOT HAVE ACCESS TO THE TERMINAL.

Access to the terminal - no. Will be in the evening in Moscow - I will write here.

 
Igor Makanu:

the wrong one! why should i guess what the mistake is if you printed it out in print? - or was the question originally posed to telepaths...no, to tushkas? )))

О! That's better - more smiles... :-)

Yes. The prints didn't print from the "EXPERTS" tab... right. There was just a lot going on... didn't have time.

 
Igor Makanu:

the wrong one! why should i guess what the mistake is if you printed it out? - or was the question originally meant for telepaths...no, tushkas? )))


may be a busy flow, requotes, so you have to guess - the common error could mean anything - at insta last year the same "hat" was there, orders took 5 minutes to close - and the code should be printed with all checks and printers ;)

Ok. :-)

PS I will post the result here tonight.

 
 #property  indicator_chart_window
#property  indicator_buffers 1
#property  indicator_plots 1
#include  "Includes//Symbol.mqh"
enum price_types
  {
   Bid,
   Ask
  };
input datetime start_date = D'2019.10.07 00:00:00' ;
input int Chops = 10 ;
input price_types applied_price= 0 ; //Price
int data_filled = 0 ;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string symbol_custom= StringFormat ( "%s_%dsec" , _Symbol ,Chops);
long chart_id = 0 ;
datetime start;
void OnInit ()
  {
//CustomSymbolDelete(symbol_custom);
   start=start_date- 60 ;
   Print ( "Ticks History Deleted : " , CustomTicksDelete (symbol_custom, 0 , LONG_MAX ));
   data_filled = 0 ;

   const SYMBOL SYMB(symbol_custom);
   SYMB.CloneProperties( _Symbol );
   SYMB.On();
   MqlTick ticks_add[];
   int len = CopyTicksRange ( _Symbol ,ticks_add, COPY_TICKS_INFO , ulong (start_date)* 1000 , ulong ( TimeCurrent ())* 1000 );
   Print ( "Ticks: " ,len);
   start = start - (len* 60 );
   Print ( "Start Date : " ,start);
   for ( int i= 0 ; i<len && ! IsStopped (); i++)
     {
       if (data_filled%Chops== 0 )
        {
         start = start+ 60 ;
         start = datetime ( TimeToString (start, TIME_DATE )+ " " + TimeToString (start, TIME_MINUTES )+ ":00" );
        }
       else
        {
         start++;
        }
      ticks_add[i].time = start;
      ticks_add[i].time_msc = long (ticks_add[i].time)* 1000 ;
      data_filled++;
     }
//Print(SYMB.CloneTicks(ticks_add));
   Print ( CustomTicksAdd (symbol_custom,ticks_add));
   chart_id = ChartOpen (symbol_custom, _Period );
   Print ( GetLastError ());
  }
void OnDeinit ( const int r)
  {
   if (chart_id != 0 )
     {
       ChartClose (chart_id);
     }
   return ;
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
  {
   if (rates_total <= 0 )
       return 0 ;
   MqlTick ticks[ 1 ];
   CopyTicks ( _Symbol ,ticks, COPY_TICKS_INFO , ulong ( TimeCurrent ())* 1000 , 1 );
   if (data_filled%Chops== 0 )
     {
      start = start+ 60 ;
      start = datetime ( TimeToString (start, TIME_DATE )+ " " + TimeToString (start, TIME_MINUTES )+ ":00" );
     }
   else
     {
      start++;
     }
   Print (start);
   ticks[ 0 ].time = start;
   ticks[ 0 ].time_msc = long (start)* 1000 ;
   data_filled++;

   Print ( CustomTicksAdd (symbol_custom,ticks));
   Print ( GetLastError ());

   return (rates_total);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

Why aren't the ticks added to my custom character?

Files:
Symbol.mqh  7 kb
 
Igor Makanu:

What's the error? wrong screen

in theory it should work, but I haven't seen such a sophisticated closing taking into account the spread and adding it as slippage - imho, if you decide to close, then slippage is not the most important thing to watch for, closing errors are more important, then requotes, then the connection is lost completely


Take OrderClose(....) away and replace it with Kim's ClosePosBySelect()https://www.mql5.com/ru/forum/131859/page2#comment_3359664

use it, then you will clearly see where it is breaking - either in your conditions for closing, or the server has some kind of trick

Artyom Trishkin:

It has a zero price close there. Respectively, we should check what was returned by MarketInfo function but we have no control. However, as usual on the four some people are used to write - something received, what - did not check, but sent an argument.

Colleagues, thank you from the bottom of my heart for the timely help in the code, no joke here, you've always helped me before and help.

All fi ions from last page on closing trades work fine. There was a problem with the end of the demo account period here, that's why there were no close conditions, including zero prices...

I've updated the account and am continuing the tests.

 
jaffer wilson :

Why are the ticks not added to my custom character?

@ Artyom Trishkin

Please can you answer my question? I don't think anyone cares.

Reason: