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

 
hoz:

How to make it so that when a trend parameter is passed to this function, which will be responsible for the transfer of the assumed main trend at the moment, the calculation will be based on this parameter.

I.e., if trend == downward, the function in the loop was like now, and iftrend == upward, the Open[i] and Close[i] were swapped in the loop, so that the conditions were observed. Because in that case the close price of the bar will be lower than the open price and the difference will be minus.


bool trend;

if ((2*trend-1)*Δ=>const) cnt++;
if ((2*trend-1)*Δ<const) cnt=0;
In that case2*trend-1takes values +1 and -1, i.e. if trend=true it will be up and trend=false it will be down while Δ will be respectively taken with right or wrong sign. This is just an example of where maths replaces if.
 

gyfto, is the test script from the kit working for you?

I would have done so:

//в шапке
#include <SharedMemoryMT4.mqh>
//в инит. Создание и открытие не обязательно. Эти функции для ускорения работы с памятью.
MemoryCreate(1, "", NULL, -1, "ind", 60*GlobalVariableGet("ADXBars"));
// Вариант более быстрый, чем выше:
MemoryCreateProjection(1, "", NULL, -1, "ind", 60*GlobalVariableGet("ADXBars"));

//в деинит
MemoryCloseName(1, "", "ind");
//в старт вместо 
for(; i<Σ; i++) MemoryWriteInt(1, "", -1, "ind", i * 4, iBars(sn, 1));//ind[i]=iBars(sn, 1);
#property show_inputs
#include <SharedMemoryMT4.mqh>
extern int x;//сколько секунд назад с данного момента прикрепления смотрим значения TOLHCV

int init()
  {
//   MemoryOpen(1, "", -1, "ind"); // Это не требуется.
   return(0);
  }
int start()
  {
   //MemoryReadInt(1, "", -1, "ind", i) это ind[i], GlobalVariableGet("final") это последний элемент в массиве, а ф-ла выглядит так: n=ind[final]-ind[final-x]+1
   int n=MemoryReadInt(1, "", -1, "ind", GlobalVariableGet("final"))-MemoryReadInt(1, "", -1, "ind", GlobalVariableGet("final")-x)+1;
   Alert(TimeToStr(TimeCurrent(),TIME_SECONDS), ": Time=", TimeToStr(Time[n], TIME_SECONDS), ", Open=", Open[n], ", High=", High[n], ", Low=", Low[n], ", Close=", Close[n], ", Volume=", Volume[n]);
   return(0);
  }

The rest is correct. Didn't get into the data transfer protocol only.

Creating, opening and allocating memory are optional. These functions are for speeding up memory handling. For the simplest library operation , you only need the read and write functions. The library will do the rest. Moreover, you can read before you write. Memory in the size requested will be allocated and the function will return zero. Since there is nothing there yet.

 

Zhunko, I think not. Comment() doesn't output, it only writes in the log, in the log:

15:51:13 Check_SharedMemoryMT4.dll AUDUSD,M1 inputs: Area=1; InitPrefix=""; UserGlobal=25; UserTerminal=50; UserWindow=100; CheckWriteRead=false; CheckWrite=false; CheckRead=false; CheckGeneral=false
CheckProjection=false; CheckClose=false; NamePrefix="Check"; NameMemory0="CheckMemory0"; NameMemory1="CheckMemory1"; NameMemory2="CheckMemory2"; NameMemory3="CheckMemory3"; NameMemory4="Memory4"
Index=-1; StartByte=0; MemorySize=64000; bValue=true; cValue=123; ucValue=255; shValue=32100; ushValue=65535; nValue=2147012345; fValue=1234.56789012; dValue=1234.56789012; sValue0="Контроль = 1234.56789"
sValue1="Контроль = 9876.54321"; sValue2="Привет мир!!!"; sValue3="Миру мир!"; sValue4="Неправильное  имя";

It's all on one line, I moved it here so there's no abnormal screen width here.

 
gyfto:

Zhunko, I think not. Comment() doesn't output, it only writes in the log, in the log:

It's all on one line, I moved it here so there's no abnormal screen width here.

Take a look at the video. Do exactly the same. If it doesn't work, we'll figure it out. It works for me.
 
I'm probably about to win a contest for the dumbest mistake. I didn't have ADXBars GV variable declared, so I wrote "method error". Plus there was no alignment on int boundary. But the alert still outputs all zeros, with or without alignment. I will watch the video and try to figure it out by myself first. If I fail, we'll try to figure it out together.
 

TarasBY artmedia70 hoz

Thank you gentlemen officers!

 
CYBOPOB:

TarasBY artmedia70 hoz

Thank you gentlemen officers!

Did you shoot yourself? :)))
 
artmedia70:
What, you shot yourself? :)))


Twice 8-[
 

Hello! Please help me on this topic:

https://www.mql5.com/ru/forum/144634

Thank you very much!

 

I got the fucking error myself. In fact, there is no logic at all. To open a pending order according tohttps://book.mql4.com/ru/appendix/limits, the opening price should be either below Bid (for selling) or above Ask (for buying). I am doing as required.

//+-------------------------------------------------------------------------------------+
//| Открытие длинной позиции                                                            |
//+-------------------------------------------------------------------------------------+
bool OpenBuy()
{
   int ticket = -1;
   double OOP = High[1] + i_thresholdToUp * pt;
   pr ("ND(OOP) = " + ND(OOP) + " ; Ask = " + Ask);

   if (ND(OOP) > Ask)
       ticket = OrderSend(Symbol(), OP_BUYSTOP, 0.1, ND(OOP), 3, 0, 0, NULL, i_magic, 0, CLR_NONE);
   else pr ("Ордер послать не удалось " + GetLastError());
   
   if (ticket > 0)
   {
       lastBarTime = Time[0];               // На текущем баре все необходимые действия..
                                            // .. успешно выполнены
       return (true);
   }
}

From time to time I get 0 and 130 errors. Although 130 is an error of wrong stop, which can happen during modification, but not during order opening.

On the screenshot the situation and the print displayed using the pr function.

Misplaced stop error

Please advise how to get rid of this bug. I am really sick and tired of this error. Logically, it is not on the subject at all.