[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 614

 
Urain:

MathRand should be initialized with MathSrand() before use,

and I recommend passing TimeLocal() as a parameter of MathSrand().

Initialization is required once, then for 32768 queries MathRand() is not detected,

After that you can initialize again if you want a new sequence, otherwise the same thing happens.

You can of course initialize each step, but you need to monitor initialization parameter to change,

otherwise it's the same sequence.


That's what I do. What is timelockal?

I have the same set on the same story.

 
ANYONE GIVE ME A HINT... THIRD TIME I've been writing and no one is answering...AccountEquity() ONE BAR ABOVE (on a past bar) HOW TO WRITE?
 
vlad123:


That's what I do. What is timelockal?

I have the same set on the same story.


Examples from the textbook:

datetime TimeLocal()

The function returns local computer time as the number of seconds elapsed since 00:00 on January 1, 1970.
Note: when tested, the local time is simulated and matches the simulated last known server time.

Example:

MathSrand(TimeLocal());
  // Отображает 10 чисел.
  for(int i=0;i<10;i++ )Print("произвольная величина ", MathRand());

 
sllawa3:
COULD SOMEONE PLEASE ADVISE. ...AccountEquity() ONE BAR ABOVE (on a past bar) HOW TO WRITE?

Answer: no way.
AccountEquity() returns the amount of equity, and does not depend on the number of bars.
You cannot know its previous values simply by rolling back the history of bars.
Its value depends on the number of open/closed, profitable/loss-making trades.
To record the "history of equity", create a static array and record the AccountEquity() value into it, for example, at every bar opening.
Thus, we would need to scroll through the array to obtain the history of equity changes.

 
sllawa3:
SOMEBODY GIVE ME A HINT... AccountEquity() ONE BAR ABOVE (on a past bar) HOW TO WRITE?

It looks like we need to store it on each new bar in a variable, for example in this way:

1. store the initial equity value in the init() function in a variable, say EquAkk=AccountEquity();

2. check appearance of a new bar ( not in init of course), if yes, then
{
LastEqu=EquAkk; // store the past (required by us) equity value in the variable
EquAkk=AccountEquity(); // record the new equity value (for the next "past" value)
}

Thus, the LastEqu variable will store equity value for the past bar, and its value will be overwritten again as the next bar is opened...

... I wrote it on my own, didn't check it, and I fell asleep already, so don't kick me too much...
I think I've expressed the idea ....

 
ToLik_SRGV:

Answer: no way.
AccountEquity() returns the amount of equity, and does not depend on the number of bars.
You cannot know its previous values simply by rolling back the history of bars.
Its value depends on the number of open/closed, profitable/loss-making trades.
To record the "history of equity", create a static array and record the AccountEquity() value into it, for example, at every bar opening.
Accordingly, it would be possible to obtain the history of equity changes by scrolling the array.



SO, YOU CAN STILL
 
sllawa3:
SO, YOU CAN STILL


Well, I wrote the same thing but suggested using an array instead of a variable.

To record the "history of equity", you need, for example, to create a static array and record the value of AccountEquity() in it, for example, at the opening of each bar.
Accordingly, the history of equity changes should be obtained by scrolling the array.

 
Guys, I can't figure out how to set the arrows on the chart, one on the highest bar for the last 80 days and the other on the lowest bar for the same 80 days. I've created this code, but it's throwing arrows in clusters... I need one arrow at minimum and maximum of each bar for the last 80 days, then for the next 80 days, etc. Can you give me a hint?
//====================================================================================
   int      NBars,MostHiBar, MostLoBar;
   double   MostHiPrice,MostLoPrice;
   datetime TMostHiBar,TMostLoBar;
   
//-----------------------------------------------------------------
   NBars       = 80;
   MostHiBar   = iHighest(NULL,PERIOD_D1,MODE_HIGH,NBars,0);      // Номер "максимального" бара
   MostLoBar   = iLowest (NULL,PERIOD_D1,MODE_LOW, NBars,0);      // Номер "минимального" бара
   MostHiPrice = iHigh   (NULL,PERIOD_D1,MostHiBar);              // Цена  "максимального" бара
   MostLoPrice = iLow    (NULL,PERIOD_D1,MostLoBar);              // Цена  "минимального" бара
   
   TMostHiBar  = iTime   (NULL,PERIOD_D1,MostHiBar);              // Время открытия "максимального" бара
   TMostLoBar  = iTime   (NULL,PERIOD_D1,MostLoBar);              // Время открытия "минимального" бара

   Comment (
            "\n", 
            "Наибольшая цена за ", NBars, " дней = ", MostHiPrice, "\n",
            "Наименьшая цена за ", NBars, " дней = ", MostLoPrice, "\n",
            "Время наибольш. бара = ", Time[MostHiBar], "\n",
            "Время наименьш. бара = ", Time[MostLoBar]   // сюда пробовал и TMostLoBar вставлять - пофигу...           
           );
           
   SetArrow(241, MediumSpringGreen, "", Time[MostHiBar], High[MostHiBar], 0);
   SetArrow(242, OrangeRed, "", Time[MostLoBar], Low[MostLoBar], 0);
//====================================================================================
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 12.10.2007                                                     |
//|  Описание : Установка значка на графике, объект OBJ_ARROW.                 |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    cd - код значка                                                         |
//|    cl - цвет значка                                                        |
//|    nm - наименование               ("" - время открытия текущего бара)     |
//|    t1 - время открытия бара        (0  - текущий бар)                      |
//|    p1 - ценовой уровень            (0  - Bid)                              |
//|    sz - размер значка              (0  - по умолчанию)                     |
//+----------------------------------------------------------------------------+
void SetArrow(int cd, color cl, string nm="", datetime t1=0, double p1=0, int sz=0) 
{
  if (nm=="") nm=DoubleToStr(Time[0], 0);
  if (t1<=0) t1=Time[0];
  if (p1<=0) p1=Bid;
  if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_ARROW, 0, 0,0);
  ObjectSet(nm, OBJPROP_TIME1    , t1);
  ObjectSet(nm, OBJPROP_PRICE1   , p1);
  ObjectSet(nm, OBJPROP_ARROWCODE, cd);
  ObjectSet(nm, OBJPROP_COLOR    , cl);
  ObjectSet(nm, OBJPROP_WIDTH    , sz);
}
//====================================================================================
 
Could you tell me, is it possible to open a position on a stop in MT? For example, put a stop behind support/copr. and if it breaks through, the stop opens a position.
 
Craft:
Could you tell me, is it possible to open a position on a stop in MT? For example, put a stop behind support/sopr. and if it penetrates, the stop opens a position.

Sure. Only it is not called a stop but a pending order. Open your terminal. Press F1 in it. In the window that appears open Contents - Trade - Order Type.
Reason: