[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 194

 
extralifes:

It's not working. Here's a screenshot:

The timing seems to be confused + after the end of the first cycle, a new one has not started.


How about another option?

//+------------------------------------------------------------------+
//|                                      Circle_X _Minutes_v.2.mq4 |
//|                                             Copyright 2012, Roll |
//|                                https://www.mql5.com/ru/users/roll |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, Roll"
#property link      "https://www.mql5.com/ru/users/roll"
extern int minut=5;datetime t;int k;
//+------------------------------------------------------------------+
int init(){t=0;k=minut;return(0);}int deinit(){return(0);}
//+------------------------------------------------------------------+
int start(){F1();if(k>60)return(0);if(k==0){t=0;k=minut;F1();}if(k>0){Sleep(59*950);k--;
if(k!=0)Alert("цикл из ", minut," минут - ПРОВЕРКА: время - ",TimeToStr(TimeLocal(),TIME_SECONDS));
  t=TimeLocal()+59;}return(0);}
void F1(){if(t==0&&TimeSeconds(TimeLocal())>=0)
  {Alert("цикл из ", minut," минут - УСТАНОВКА: время - ",TimeToStr(TimeLocal(),TIME_SECONDS));t=TimeLocal();}}
 

Hi,

Please give me the simplest example to open an order (immediately, without any ifs).
The textbook is very complicated.

 
olis:

Hi,

Please give me the easiest example to open an order (immediately, without any ifs).
The tutorial is very complicated.

OrderSend()

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)

Basic function used to open a position or place a pending order.
Returns the ticket number, which is assigned to the order by the trade server, or -1 in case of failure. To get more information about the error, you should call the GetLastError() function.
Notes.
When opening a market order (OP_SELL or OP_BUY), only the latest Bid (for selling) or Ask (for buying) prices may be used as the opening price. If the operation is performed for a financial instrument, different from the current one, then to get the latest quotes for this instrument, you should use the MarketInfo() function with the MODE_BID or MODE_ASK parameter. You cannot use an estimated or non-normalized price. If the requested opening price was not in the price flow or the requested price is not normalized according to the number of decimal places, error 129 (ERR_INVALID_PRICE) will be generated. If the requested opening price is severely out of date, an error 138 (ERR_REQUOTE) will be generated regardless of the value of the slippage parameter. If the requested price is out of date but still present in the price flow, the position will be opened at the current price and only if the current price falls within the price+-slippage range.

StopLoss and TakeProfit prices may not be placed too close to the market. The minimum stop distance in pips can be obtained using the MarketInfo() function with the MODE_STOPLEVEL parameter. Error 130 (ERR_INVALID_STOPS) is generated in case of erroneous or non-normalized stops.

When placing a pending order, the opening price cannot be too close to the market. The minimum distance of the pending price from the current market price in points can also be obtained using the MarketInfo() function with the MODE_STOPLEVEL parameter. If the pending order open price is incorrect, error 130 (ERR_INVALID_STOPS) will be generated.

On some trade servers a ban on expiration of pending orders can be set. In this case an error 147 (ERR_TRADE_EXPIRATION_DENIED) will be generated when trying to set a non-zero value in the expiration parameter.

On some trade servers a limit on the total number of open and pending orders can be set. If this limit is exceeded, a new position will not be opened (no pending order will be set) and the trade server will return error 148 (ERR_TRADE_TOO_MANY_ORDERS).
Parameters:
symbol - Name of a financial instrument traded.
cmd - Trade operation. Can be any of the trade values.
volume - Number of lots.
price - Opening price.
slippage - Maximum permitted price slippage for market orders (buy or sell orders).
stoploss - The price of closing a position when the loss is reached (0 if there is no loss).
takeprofit - The close price of a position when the profitability level is reached (0 if there is no profitability level).
comment - Order comment text. The last part of the comment can be changed by the trading server.
magic - Magic number of the order. Can be used as a user-defined identifier.
expiration - Expiration time of the pending order.
arrow_color - Colour of the opening arrow on the chart. If the parameter is absent or its value is CLR_NONE, the opening arrow is not shown on the chart.
 
ULAD:

I can't figure out how to calculate the lifetime from pattern formation to 0 bar.

If the pattern exists and there is no hard reference to price and time.

The pattern does not always exist. It was formed at some moment. Here is a link to the time of its formation and the time of the current bar or to the bar of its formation and the current bar. Can you find the difference between the pattern formation and the current time?
 
olis:

Hi,

Please give me the simplest example to open an order (immediately, without any ifs).
The textbook is very complicated.


//--------------------------------------------------------------------
// simpleopen.mq4 
// Предназначен для использования в качестве примера в учебнике MQL4.
//--------------------------------------------------------------------
int start()                                  // Спец. функция start()
  {                                          // Открытие BUY
   OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-15*Point,Bid+15*Point);
   return;                                   // Выход из start()
  }
//--------------------------------------------------------------------
 
Roll:


Thank you, it's working!
 

I'm trying to figure out an example from S.K.'s book, rocseparate.mq4 Expert Advisor I start a test, display a chart. At the bottom there is a rocseparate window, but it is empty. Please, advise how to make an indicator drawn in the main window? The code is as in the book:

//-------------------------------------------------------------- 5a --
   double L_1=iCustom(NULL,0,"rocseparate",H,P,B,A,1,0);
   double L_5=iCustom(NULL,0,"rocseparate",H,P,B,A,5,0);
//-------------------------------------------------------------- 5b --
   if (L_5<=-Level && L_1>L_5)
     {
      Opn_B=true;                               // Критерий 
 
ScioMe:

I'm trying to figure out an example from S.K.'s book, rocseparate.mq4 Expert Advisor I start a test, display a chart. At the bottom there is a rocseparate window, but it is empty. Please, advise how to make an indicator drawn in the main window? The code as in the book:


Tutorial:
"...The rocseparate.mq4 custom indicator of price change rate on the current, nearest larger and next larger timeframes... is a full analogue of the roc.mq4 indicator, but it is displayed in a separate window. This allowed to calculate the values of the velocity lines for different timeframes, not relative to the MA reference, but relative to the horizontal zero line".

 
Roll:


Tutorial:
"... The rocseparate.mq4 custom indicator of the rate of price change on the current, nearest larger and next larger timeframes is displayed in a separate window ... is the full analogue of the roc.mq4 indicator, but it is displayed in a separate window. This allowed to calculate the values of the velocity lines for different timeframes, not relative to the MA reference, but relative to the horizontal zero line".


Yes, absolutely right: I drop it on the chart, rocseparate appears at the bottom in its own window. But when I click on "Open Chart" after testing, the chart window is empty. I don't understand what's wrong?
 
Then press End on the keyboard (EA shared.mq4) and observe your indicator (window is not empty).
Reason: