Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1534
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
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!