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

 
Igor Makanu:

you cannot execute something long in OnInit - the terminal may unload the code

in the indicator must not run slip

Yeah, I'm dumb... Maybe, instead of an infinite loop in OnInit, return from OnCalculate with the same condition? - there should be a definite number when there is no login, either -1, or 0, or EMPTY_VALUE

 

Greetings traders and programmers!

Could you please tell me if it is possible to use a non-standard method to calculate the period for the MA(Moving Average) ? I mean the position of the MA on the current (zero) bar will not be determined by the last 20 (for example) bars, but by every 5m of the last 100, or just by specifying the numbers of bars in the history, starting from the current one. And, if there is such a possibility, is it possible to specify the function directly in the indicator code?

Thanks for the information.

 

Hello. How do I display the triangle symbol down and up?

Here is the code

bool OutText(const string name="Label",

const string text="Label", // text

const int x=0, // X coordinate

const int y=0, // coordinate along the Y axis

const color clr=clrYellow, // colour

const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // anchor method

const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // chart corner for anchor

const int font_size=12, // font size

const string font="Arial", // font

const double angle=0.0, // text slope

const bool back=false, // back

const bool selection=false, //select for moving

const bool hidden=true, // hidden in the list of objects

const long z_order=0,

const int sub_window=0, // number of subwindow

const long chart_ID=0 // chart ID

) // click priority

{

//--- reset the error value

ResetLastError();

//--- create a text mark

if(ObjectFind(chart_ID,name)==-1)

{

if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))

{

Print(__FUNCTION__, ": failed to create text label! Error code = ",GetLastError());

// return(false);

}

}

//--- set marker coordinates

ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

//--- set the chart angle, relative to which the point coordinates will be determined

ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

//--- set the text

ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

//--- set text font

ObjectSetString(chart_ID,name,OBJPROP_FONT,font);

//--- set font size

ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);

//--- set angle of slope of the text

ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);

//--- set anchoring method

ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);

//--- set colour

ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- display in the foreground (false) or background (true)

ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- switch on (true) or switch off (false) the mode of moving the mark with the mouse

ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

//--- hide (true) or display (false) the graphical object name in the object list

ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

//--- set the event of the mouse click receipt priority

ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

//--- successful execution

return(true);

}

How do I get the triangle symbol up?

What should be written

OutText("LabelBuy1", ">", 100, 20, clrWhite, ANCHOR_UPPER,CORNER_LEFT_UPPER,14, "Arial");

To make a triangle up?

1



Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Свойства объектов
Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Свойства объектов
  • www.mql5.com
Все объекты, используемые в техническом анализе, имеют привязку на графиках по координатам цены и времени – трендовая линия, каналы, инструменты Фибоначчи и т.д.  Но есть ряд вспомогательных объектов, предназначенных для улучшения интерфейса, которые имеют привязку к видимой всегда части графика (основное окно графика или подокна индикаторов...
 

Earlier I asked a question how to simulate Print() function from library side to check data coming into library functions and to search for errors, I was advised to use C++ resources: i.e. to write information into file from library dll side. In general the library can not create a file to write the information there, the file is created neither in the directory project, nor in the folder with the robot, tried to specify the default path does not work, outputting information via cout also does not work, but probably can not because it's not quite a console application. Who can advise?

#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <fstream>//подключаю библиотеку для записи в файл

/*using std::cout;
using std::endl;
using std::cin;*/

using namespace std;

#define _DLLAPI extern "C" __declspec(dllexport)

_DLLAPI int __stdcall Funkt(int qa){//"C:\\Program Files(x86)\\Forex4you\\MQL4\\Experts\\Moyperviyzapisfiles.txt"
        ofstream file;//"C:\\Users\\123\\Documents\\Visual Studio 2012\\Projects\\ConsoleApplication8\\ConsoleApplication8\\Moyperviyzapisfiles.txt"
        //"C:\\Users\\123\\documents\\visual studio 2012\\Projects\\ConsoleApplication8\\Debug\\ConsoleApplication8.dll\\Moyperviyzapisfiles.txt"
        file.open("C:\\Program Files(x86)\\Forex4you\\MQL4\\Experts\\Moyperviyzapisfiles.txt"/*,ios::out*/);//Moy perviy zapis files
        file<<"Moyperviyzapisfiles";//хочу записать эту фразу в файл
        file.close();   
        return 12;}
//если это делать не в библиотеке то работает.
 

How do I replace the standard picture in the description with ...


... can I put my own?


 
Alexandr Sokolov:

How do I replace the standard picture in the description with ...


... can I put my own?


#property icon
 
Artyom Trishkin:
#property icon

How simple it is... Thank you!

 

Hello!

Could you please tell me how to implement the detection of manually drawn graphical objects on a chart (horizontal or trend line, for example) and then retrieve their properties (price level at the right time)?

 
odyn:

Hello!

Could you please tell me how to implement the detection of manually drawn graphical objects on a chart (horizontal or trend line, for example) and then retrieve their properties (price level at the right time)?

If the number of objects on the chart has increased, then...
 
odyn:

Hello!

Could you please tell me how to implement the detection of manually drawn graphical objects on a chart (horizontal or trend line, for example) and then retrieve their properties (price level at the right time)?

They have a standardized prefix, e.g.: Trenler number. You can search as follows: in the loop if(StringFind(ObjectName(0,i), "Trendline")==0) for old ones or for new ones if(StringFind(sparam, "Trendline")==0))

Reason: