Good afternoon, could you please tell me how to correctly average the indicator line? The basic curve with period Per_1 is drawn normally (Buffer_1[]), until I add a block of simple averaging with Buffer_2[] with averaging period Per_2.
Eugen8519: That's the problem, it only opens and closes starthour->stophour orders
And open orders are not closed after stophour
Because you cannot trade after stophour
I've been writing the logic of opening before closing, trawling and other position maintenance for a long time. For the most part it is true, before you open something else, you have to check what is already open.
Your logic is correct, you just need to swap the blocks:
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
This is how the order closes
Do as I wrote above...
Or post the OnTick() code
This is how the order closes
This structure should be
This structure should be
If I am not mistaken, it can be written as follows
Well thanks for the advice, I'll check it out tonight and report back later.
if UseTimeLimit is set in the settings when starting the owl, then
this function is better in OnInit() instead of OnTick()
If I'm not mistaken, you can write it like this
I actually write it like this.
if(TimeHour(time[i])>=Time_Start&&TimeHour(time[i])<TimeFinish)or even simpler
if(Hour()>=Time_Start&&Hour()<TimeFinish)Good afternoon, could you please tell me how to correctly average the indicator line? The basic curve with period Per_1 is drawn normally (Buffer_1[]), until I add a block of simple averaging with Buffer_2[] with averaging period Per_2.
int OnCalculate(default parameters)
{
int i, j, limit;
if(rates_total <= Per_1)
return(0);
//The last calculated bar will be recalculated
limit = rates_total - prev_calculated - Per_1;
if(prev_calculated > 0)
limit++;
//calculate and fill in indicator buffers
for(i=0; i < limit; i++)
{
//Calculate the main line of the indicator
Buffer_1[i] = Formula of the curve
double Sum = 0;
for(j = i; j < Per_2 + i; j++)
{
//Calculate line of averaging
Sum += Buffer_1[j];
Buffer_2[i] = Sum / Per_2;
}
}
return(rates_total);
}
Good afternoon!
Insert code
Here seems to be the answer to your questionThat's the problem, it only opens and closes starthour->stophour orders
Because you cannot trade after stophour
I've been writing the logic of opening before closing, trawling and other position maintenance for a long time. For the most part it is true, before you open something else, you have to check what is already open.
Your logic is correct, you just need to swap the blocks:
Insert code
Here seems to be the answer to your questionCool! It works, thank you!