There is a problem. Using the function (see below), we can obtain TakeProfit and StopLoss values by position ID from the history (i.e. when the position is already closed), this function works in real time, but in the strategy tester, it cannot find TakeProfit and StopLoss, because it does not see historical orders that set stops (importantly, the stops are set after the position opening)
Question: How can I use the Strategy Tester to find out the TP/Loss for a closed position based on a ticket?
Hello all ! I'm just trying to program EAs, and I want to start by writing a statistical spread collector. I mean, what would I like it to do? In the tester, an EA starts and collects data on tick history for a certain period of time, e.g. ten days. And then it generates the following data in csv or xlsx file: Average spread for a period of time: 00:00 - 09:00 on the server, 09:00 - 18:00, 18:00 - 00:00 (for all ten days), maximum spread for this time, minimum spread and average spread of currency pair for the entire period of ten days. I am really tired of collecting it by hand.
I know that there are programs, which kind of do it themselves... But I want my own, as a workout. Maybe respected connoisseurs can tell me where to start? And is it even possible to write such a program?
Thanks in advance to all who replied and were sympathetic to a newcomer.
Hi all. Maybe someone has a ready piece of code. There are 2 parameters, deposit=3000 and lot 0.01 i.e. with deposit 3000 lot will be 0.01, now strictly at doubling i.e. when depo will be 6000 lot will be 0.02 at 9000 will be 0.03 how to do it?
Hi all. Maybe someone has a ready piece of code. There are 2 parameters, deposit=3000 and lot 0.01 i.e. with deposit 3000 lot will be 0.01, now strictly at doubling i.e. when depo will be 6000 lot will be 0.02 at 9000 will be 0.03 how to do it?
Please help me to find a bug... I copy bar values (BarsCount) from the indicator buffer in the script, then I loop around values, detect a signal and print them to Print(); it seems to be simple, but it's not so easy... I get all signals as I wanted except for crossing zero line.
CROSSOVER_OR_REVERSE
Maybe the script shouldn't do it that way? I attached the code and a screenshot of the log... Thanks a lot!
//+------------------------------------------------------------------+//| B_O_P_Signals.mq5 |//| Copyright 2021, MetaQuotes Ltd. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2021, MetaQuotes Ltd."#property link"https://www.mql5.com"#property version"1.00"//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+enum enMaTypes
{
ma_sma, // Simple moving average
ma_ema, // Exponential moving average
ma_smma, // Smoothed MA
ma_lwma // Linear weighted MA
};
inputint inpSmoothPeriod = 14; // Result smoothing periodinput enMaTypes inpSmoothMethod = ma_sma; // Result smoothing typeinputdouble inpLevelUp = 0.2; // Level upinputdouble inpLevelDown = -0.2; // Level downinputint BarsCount = 100;
double Mid_line[1] = {0.0};
int handle=0;
double TREND_VAL[];
voidOnStart()
{
handle = iCustom(_Symbol,PERIOD_CURRENT,"Balance of Market Power",inpSmoothPeriod,inpSmoothMethod,inpLevelUp,inpLevelDown);
CopyBuffer(handle,2,0,BarsCount,TREND_VAL);
ArraySetAsSeries(TREND_VAL,true);
string Signal ="";
for (int i=ArraySize(TREND_VAL)-1; i>=0; i--)
{
int k=1;
if(TREND_VAL[i] != EMPTY_VALUE && TREND_VAL[i] > Mid_line[0] && TREND_VAL[i] > inpLevelUp)
Signal = "TREND_UP";
elseif (TREND_VAL[i] != EMPTY_VALUE && TREND_VAL[i] > Mid_line[0] && TREND_VAL[i] < inpLevelUp)
Signal = "TREND_UP_ROLLBACK_OR_FLAT";
elseif(TREND_VAL[i] >= Mid_line[0] && TREND_VAL[i+k] <= Mid_line[0])
Signal ="CROSSOVER_OR_REVERSE_UP";
elseif (TREND_VAL[i] != EMPTY_VALUE && TREND_VAL[i] < Mid_line[0] && TREND_VAL[i] < inpLevelDown)
Signal = "TREND_DN";
elseif (TREND_VAL[i] != EMPTY_VALUE && TREND_VAL[i] < Mid_line[0] && TREND_VAL[i] > inpLevelDown)
Signal = "TREND_DN_ROLLBACK_OR_FLAT";
elseif(TREND_VAL[i] < Mid_line[0] && TREND_VAL[i+k] > Mid_line[0])
Signal = "CROSSOVER_OR_REVERSE_DN";
else Signal = "UNKNOWN_SIGNAL";
Print(string(i),"_", Signal);
}
}
//+------------------------------------------------------------------+
Vladimir Karputov, and me?)
I can't say for sure, but try 0.0
Added: It seems that you cannot cancel 'INDICATOR_MINIMUM' and 'INDICATOR_MAXIMUM' with MQL5.
I can't say for sure, but try 0.0
Added: It seems that 'INDICATOR_MINIMUM' and 'INDICATOR_MAXIMUM' cannot be cancelled by MQL5.
Alas...
Thank you for your reply.
(same problem with levels, actually; but solved by setting the number of levels)
Alas...
Thanks for the reply.
(The problem with levels is actually the same; but solved by setting the number of levels)
Experiment and everything will work out.
I compared the properties that the chart saves (using'Stochastic Oscillator' indicator as an example)
This is clearly a 'bool' type property, but there is no access to this property from MQL5 language.
I compared the properties that the chart saves (using'Stochastic Oscillator' indicator as an example)
It is clearly a 'bool' type property but there is no access to this property from MQL5.
Yes, alas.
Thanks again)
There is a problem. Using the function (see below), we can obtain TakeProfit and StopLoss values by position ID from the history (i.e. when the position is already closed), this function works in real time, but in the strategy tester, it cannot find TakeProfit and StopLoss, because it does not see historical orders that set stops (importantly, the stops are set after the position opening)
Question: How can I use the Strategy Tester to find out the TP/Loss for a closed position based on a ticket?
I'm just trying to program EAs, and I want to start by writing a statistical spread collector.
I mean, what would I like it to do? In the tester, an EA starts and collects data on tick history for a certain period of time, e.g. ten days.
And then it generates the following data in csv or xlsx file:
Average spread for a period of time: 00:00 - 09:00 on the server, 09:00 - 18:00, 18:00 - 00:00 (for all ten days), maximum spread for this time, minimum spread and average spread of currency pair for the entire period of ten days.
I am really tired of collecting it by hand.
I know that there are programs, which kind of do it themselves... But I want my own, as a workout.
Maybe respected connoisseurs can tell me where to start? And is it even possible to write such a program?
Thanks in advance to all who replied and were sympathetic to a newcomer.
Hi all. Maybe someone has a ready piece of code. There are 2 parameters, deposit=3000 and lot 0.01 i.e. with deposit 3000 lot will be 0.01, now strictly at doubling i.e. when depo will be 6000 lot will be 0.02 at 9000 will be 0.03 how to do it?
Hi all. Maybe someone has a ready piece of code. There are 2 parameters, deposit=3000 and lot 0.01 i.e. with deposit 3000 lot will be 0.01, now strictly at doubling i.e. when depo will be 6000 lot will be 0.02 at 9000 will be 0.03 how to do it?
It is roughly like this:
Result:
Good time,
Please help me to find a bug... I copy bar values (BarsCount) from the indicator buffer in the script, then I loop around values, detect a signal and print them to Print(); it seems to be simple, but it's not so easy... I get all signals as I wanted except for crossing zero line.
CROSSOVER_OR_REVERSEMaybe the script shouldn't do it that way? I attached the code and a screenshot of the log... Thanks a lot!