[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 101
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello again :)
As I thought, problems have arisen. Here is the code. The point is that orders on the tester are closed by TP, and by function TP is removed when the order is modified during Trailing Stop.
Which means the trailing stop is not executed, and there were no errors with wrong TP and SL in the tester's log. So what is wrong?Dear Professionals, could you please tell me this question?
I have a previously written one dimensional string array in a text file
EURUSD 1654.31
GBPUSD -1654.61
USDCAD 110.98
USDJPY 1180.17
Suppose the total profit of USDCAD has changed and I need to replace the 3rd line with "USDCAD 115.64".
I read this data as a one-dimensional string array, but I can't replace only this element in the text file (can someone write a function?)
Or is it better not to bother and overwrite the entire array?
I just have data coming in from EAs standing on different pairs - each pair has a different string - it would of course be better to change only 1 element probably.
Hi all!!! Help to understand the example from HELPA
//--------------------------------------------------------------------
//obviousexpert.mq4
// Intended to be used as an example in the MQL4 Tutorial.
//--------------------------------------------------------------- 1 --
#property copyright "Copyright © Book, 2007"
#property link "http://AutoGraf.dp.ua"
//--------------------------------------------------------------- 2 --
#include <stdlib.mqh>
#include <stderror.mqh>
#include <WinUser32.mqh>
//--------------------------------------------------------------- 3 --
#include <Variables.mqh> //Variables description
#include <Check.mqh> // Checking the legality of the program.
#include <Terminal.mqh> // Order accounting
#include <Events.mqh> // Event tracking, updated.
#include <Inform.mqh> // Information function
#include <Trade.mqh> // Trade function
#include <Open_Ord.mqh> // Opening of a single order of a specified type
#include <Close_All.mqh> // Closing of all orders of a specified type
#include <Tral_Stop.mqh> // Modification of StopLoss of all orders of a specified type
#include <Lot.mqh> // Calculation of the number of lots
#include <Criterion.mqh> // Trade criteria
#include <Errors.mqh> // Error handling function.
//--------------------------------------------------------------- 4 --
int init() // Special function init
{
Level_old=MarketInfo(Symbol(),MODE_STOPLEVEL );//min. dist.
Terminal(); // Order function
return; // Exit from init()
}
//--------------------------------------------------------------- 5 --
int start() // Special function start
{
if(Check()==false) // If the conditions of use.
return; // ...are not met, exit.
PlaySound("tick.wav"); // On every tick
Terminal(); // Order accounting function
Events(); // Events information
Trade(Criterion()); // Trade function
Inform(0); // To recolor objects
return; // Exit()
}
//--------------------------------------------------------------- 6 --
int deinit() // Special function deinit()
{
Inform(-1); // To remove objects
return; // Exit deinit()
}
//--------------------------------------------------------------- 7 --
2) Only in the storage location? or in the design of the code as well?
The questions are, 1) What is the difference between include files (#include<...> and #include "..."), 3) And what is the difference between imported functions (#import) and #include directive?
The example from HELPA of usualexpert.mq4 illustrates the Expert Advisor, which was built on the include files, judging by the <> brackets in its #include directory.
Questions: Is the #include <Variables.mqh> file included // A description of variables, when created according to the example:
//--------------------------------------------------------------------
// Variables.mqh
// Intended to be used as an example in MQL4 tutorial.
//--------------------------------------------------------------- 1 --
// Description of global variables
extern double Lots =0.0; // Number of lots
extern int Percent =0; // Percentage of allotted funds
extern int StopLoss =100; // StopLoss for new orders (points)
extern int TakeProfit =40; // TakeProfit for new orders (points)
extern inttern TralingStop=100; // TralingStop for market orders (points)
//--------------------------------------------------------------- 2 --
int
Level_new, // New value of the minimum distance
Level_old, // Previous value of minimum distance
Mas_Tip[6]; // Array of order types
// [] type of orders: 0=B,1=S,2=BL,3=SL,4=BS,5=SS
//--------------------------------------------------------------- 3 --
double
Lots_New, // Number of lots for new orders
Mas_Ord_New[31][9], // Array of orders current .
Mas_Ord_Old[31][9]; // .
// index 1 = order number
// [][0] is not defined
// [][1] open order price (absolute value)
// [][2] StopLoss order (absolute value)
// [][3] TakeProfit order (abs. rate value)
// [][4] order number
// [][5] number of lots of the order. (abs. rate)
// [][6] Order type 0=B,1=S,2=BL,3=SL,4=BS,5=SS
// [][7] magic number of the order
// [][8] 0/1
//--------------------------------------------------------------- 4 --
Compiling gives an error -- '\end_of_program' - no function defined what does it mean and should I add something to the end of this example
And should the included files look like this or should they be added to the header:
#property copyright "Copyright © 2004, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net/"
#property library
//+------------------------------------------------------------------+
//| return error description |
//+------------------------------------------------------------------+
For example, as a part of ( usualexpert.mq4 // intended for use as an example in MQL4 tutorial. ) There is #include <Check.mqh> // Checking legitimacy of programs used. Without this hat, it generates an error (Start function not found and cannot be run). All is OK with it?
Or, the include files contain only descriptions of custom functions located in the library of functions at the address (libraries). If it already exists in the Expert Advisor file?
Hi all!!! Help me to understand an example from HELPA
//--------------------------------------------------------------------
// usualexpert.mq4
// Designed to be used as an example in MQL4 tutorial.
//--------------------------------------------------------------- 1 --
#property copyright "Copyright © Book, 2007"
#property link "http://AutoGraf.dp.ua"
//--------------------------------------------------------------- 2 --
#include <stdlib.mqh>
#include <stderror.mqh>
#include <WinUser32.mqh>
//--------------------------------------------------------------- 3 --
#include <Variables.mqh> //Variables description
#include <Check.mqh> // Verify legality of program usage
#include <Terminal.mqh> // Order accounting
#include <Events.mqh> // Event tracking function, updated
#include <Inform.mqh> // Information function
#include <Trade.mqh> // Trade function
#include <Open_Ord.mqh> // Opening a single order of a specified type
#include <Close_All.mqh> // Closing all orders of a specified type
#include <Tral_Stop.mqh> // Modification of StopLoss of all orders of a specified type
#include <Lot.mqh> // Calculation of lots number
#include <Criterion.mqh> // Trade criteria
#include <Errors.mqh> // Error handling function.
//--------------------------------------------------------------- 4 --
int init() // Special function init
{
Level_old=MarketInfo(Symbol(),MODE_STOPLEVEL );// Minimal dist.
Terminal(); // Order counting function
return; // Exit init()
}
//--------------------------------------------------------------- 5 --
int start() // Special function start
{
if(Check()==false) // If conditions of use.
return; // ..are not met, exit
PlaySound("tick.wav"); // On every tick
Terminal(); // Order accounting function
Events(); // Event information
Trade(Criterion()); // Trade function
Inform(0); // To recolor objects
return; // Exit start()
}
//--------------------------------------------------------------- 6 --
int deinit() // Specific function deinit() function deinit()
{
Inform(-1); // To delete objects
return; // Exit deinit()
}
//--------------------------------------------------------------- 7 --
2) Only in the storage location? Or in the design of the code as well?
The questions are, 1) What is the difference between include files (#include<...> and #include "..."), 3) And what is the difference between imported functions (#import) and #include directive?
The example from HELPA, in particular, illustrates the Expert Advisor, which was built based on the included files, judging by the <> brackets in its #include file.
Questions: Include\file #include <Variables.mqh> //Variables description, when created by the example:
//--------------------------------------------------------------------
// Variables.mqh
// Designed to be used as an example in the MQL4 tutorial.
//--------------------------------------------------------------- 1 --
// Description of global variables
extern double Lots =0.0; // Number of lots
extern int Percent =0; // Percentage allocated
extern int StopLoss =100; // StopLoss for new orders (pips)
extern int TakeProfit =40; // TakeProfit for new orders (pips)
extern int TralingStop=100; // TralingStop for market orders (pips)
//--------------------------------------------------------------- 2 --
int
Level_new, // New minimum distance value
Level_old, // Previous minimum distance value
Mas_Tip[6]; // Order type array
// [] order type 0=B,1=S,2=BL,3=SL,4=BS,5=SS
//--------------------------------------------------------------- 3 --
double
Lots_New, // Number of lots for new orders
Mas_Ord_New[31][9], // Order array current ..
Mas_Ord_Old[31][9]; // ... and old
// 1st index = order number
// [][0] cannot be defined
// [][1] open order price (abc rate)
// [][2] StopLoss order (abc rate)
// [][3] TakeProfit order (abc rate)
// [][4] order number
// [][5] number of lots an order (abc rate). (Abc Rate)
// [][6] Order type 0=B,1=S,2=BL,3=SL,4=BS,5=SS
// [][7] order magic number
// [][8] 0/1 comment fact
//--------------------------------------------------------------- 4 --
At compiling gives out an error -- '\end_of_program' - no function defined what it means and whether it is necessary to add something to the end of this example
And should the include files look like this or should they be added to the header
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property library
//+------------------------------------------------------------------+
//| return error description |
//+------------------------------------------------------------------+
For example, as a part of ( usualexpert.mq4 // intended for use as an example in MQL4 tutorial. ) There is #include <Check.mqh> // Checking legality of programs used. Without this hat, it generates an error (Start function not found and cannot be run). Is everything OK with it?
Or, the include files only contain descriptions of custom functions, which are located in the library of functions at the address (libraries). If it exists in the Expert Advisor's file?
.......
A better way to calculate the mode is to construct an empirical distribution function (not to be confused with the frequency distribution), then interpolate it from piecewise linear to smooth, and finally look for the point of maximum derivative. Such an algorithm is free of the drawbacks listed above and works quite effectively even with small sample sizes. At least, I had to solve just the task of searching for modes in samples of 50-100 elements with a comparable number of intervals using MQL - and everything was OK. The only disadvantage is that the speed of calculation usually decreases significantly when using interpolations, of course, if we want to smooth it out qualitatively.
Hello, could you tell me what Comment("") means, what will the function output in this case?
the box with the text in quotes
I meant when there are only quotes in brackets: Comment("")