barabashkakvn: If you know the time and dates of your points, you only need to callbool TrendCreate()
Thanks for the advice. It turned out to be easier than that.
I did it this way:
#property strict#property script_show_inputs//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+voidOnStart()
{
long chart_ID=0; // ID графикаstring name="TrendLine"; // имя линииint sub_window=0; // номер подокна//--- сбросим значение ошибкиResetLastError();
//--- создадим трендовую линию по заданным координатамif(!ObjectCreate(chart_ID,name,OBJ_TREND,sub_window,Time[41],1.0656,Time[65],1.0494))
{
Print(__FUNCTION__,
": не удалось создать линию тренда! Код ошибки = ",GetLastError());
return;
}
}
//+------------------------------------------------------------------+
P.S. One thing I can't understand is why the numbers in the example are chosen like that:
forexman77: Now the next problem to solve is how to continue the line to the right and get the value of the line in the EA?
The script code has it all:
//+------------------------------------------------------------------+//| Создает линию тренда по заданным координатам |//+------------------------------------------------------------------+bool TrendCreate(constlong chart_ID=0, // ID графика
.
.
.
//--- включим (true) или отключим (false) режим продолжения отображения линии влевоObjectSetInteger(chart_ID,name,OBJPROP_RAY_LEFT,ray_left);
//--- включим (true) или отключим (false) режим продолжения отображения линии вправоObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,ray_right);
.
.
.
1.When called from the tester trades are opened. If I run optimization there are zeros everywhere. When I launch any optimization run, the deals are there. What to do?
2. How can I make a line be saved if a deal has occurred (on each deal), and if not, it is deleted?
long chart_ID=0; // ID графикаstring name="TrendLine"; // имя линииint sub_window=0; // номер подокнаObjectDelete(chart_ID,name);
//--- сбросим значение ошибкиResetLastError();
//--- создадим трендовую линию по заданным координатамif(!ObjectCreate(chart_ID,name,OBJ_TREND,sub_window,Time[minbar],Low[minbar],Time[IPMIN],Low[IPMIN]))
{
Print(__FUNCTION__,
": не удалось создать линию тренда! Код ошибки = ",GetLastError());
return(0);
}
ObjectSet("TrendLine",OBJPROP_TIME1,Time[minbar]);
ObjectSet("TrendLine",OBJPROP_PRICE1,Low[minbar]);
ObjectSet("TrendLine",OBJPROP_TIME2,Time[IPMIN]);
ObjectSet("TrendLine",OBJPROP_PRICE2,Low[IPMIN]);
if (IPMIN!=0){ double uroven= ObjectGetValueByTime(chart_ID,name,Time[1],sub_window);}
}
Print("uroven=",uroven);
if (Time[0] > b && Close[1] < uroven){Opn_B=true;}
barabashkakvn: You need to control the trades yourself. But for each trade to have its own line, you need to give each line a unique name when you create it.
During visualization testing, the Expert Advisor interacts with the real chart. In normal testing, without visualization, the Expert Advisor operates with a "virtual" chart that is not rendered; in this case, some subtleties are possible. Graphical objects are not supported when the tester is in optimisation mode.
Two days to study, and it turns out it's impossible to perform optimization.
I wonder if I create an indicator. Will I be able to get the line value in my Expert Advisor through it?
Who has to say what? Perhaps, who has already studied this question?
But anyway, it is easier to solve everything using the indicator. Calculations are performed in the indicator and their results are displayed through indicator buffers.
There is one more alternative. Create global variables with parameters of the line instead of lines, but then the function GetValueByShift() will not work, you must write its analog.
If you know the time and dates of your points, you only need to callbool TrendCreate()
Thanks for the advice. It turned out to be easier than that.
I did it this way:
P.S. One thing I can't understand is why the numbers in the example are chosen like that:
From them the trend line goes somewhere in the middle of the range.
...
From them, the trend line is put somewhere in the middle of the range.
Now the next problem to solve is how to continue the line to the right and get the value of the line in the EA?
The script code has it all:
The script code has it all:
1.When called from the tester trades are opened. If I run optimization there are zeros everywhere. When I launch any optimization run, the deals are there. What to do?
2. How can I make a line be saved if a deal has occurred (on each deal), and if not, it is deleted?
You need to control the trades yourself. But for each trade to have its own line, you need to give each line a unique name when you create it.
How? Can I give you an example?
Graphic objects during testing
During visualization testing, the Expert Advisor interacts with the real chart. In normal testing, without visualization, the Expert Advisor operates with a "virtual" chart that is not rendered; in this case, some subtleties are possible. Graphical objects are not supported when the tester is in optimisation mode.
Two days to study, and it turns out it's impossible to perform optimization.
I wonder if I create an indicator. Will I be able to get the line value in my Expert Advisor through it?
Who has to say what? Perhaps, who has already studied this question?
...
I wonder if I could make an indicator? Would I be able to get the value of the line in the EA through it?
...
If the indicator creates graphical objects and then gets their parameters, no.
But anyway, it is easier to solve everything using the indicator. Calculations are performed in the indicator and their results are displayed through indicator buffers.
There is one more alternative. Create global variables with parameters of the line instead of lines, but then the function GetValueByShift() will not work, you must write its analog.