- Questions from Beginners MQL5 MT5 MetaTrader 5
- Could simplicity win against complexity in EA programming?
- Optimization Solution/elimination of unwanted passes at the very beginning of the optimization/ (highly Expert Moderator-Programmer case)
Umm... i am in need of some programing ideas, hopefully someone in here could kindly come up with a less complex solution(it's what we programers do isn't it?) for the soon stated problem. I should start off saying am not new to programing buh however new to programing in MQL4 though relatively same with C++ you might agree.
For weeks now i have been building and testing an EA, and i currently find myself in a position where i need to add a custom function but do no really know how to go about the trade algorithm. I need to count a certain number of candle on a particular timeframe say (20candles on 15mins) from a trade execution time or candle. To explain further: Example trading 15mins: A trade buy is triggered by a 15mins candle, and i want to count 20 15mins candle from that triggered position.
I have tried doing this with the time-function available in MQL4 but the algorithm gets complex if i were to count say 100 candles which obviously exceeds a day. So i was hoping one in here would know how to count each candles on a particular timeframe into the future from a triggered position. Thanks
Umm... i am in need of some programing ideas, hopefully someone in
here could kindly come up with a less complex solution(it's what we
programers do isn't it?) for the soon stated problem. I should start off
saying am not new to programing buh however new to programing in MQL4
though relatively same with C++ you might agree.
For weeks now i have been building and testing an EA, and i currently find myself in a position where i need to add a custom function but do no really know how to go about the trade algorithm. I need to count a certain number of candle on a particular timeframe say (20candles on 15mins) from a trade execution time or candle. To explain further: Example trading 15mins: A trade buy is triggered by a 15mins candle, and i want to count 20 15mins candle from that triggered position.
I have
tried doing this with the time-function available in MQL4 but the algorithm
gets complex if i were to count say 100 candles which obviously exceeds a day. So i
was hoping one in here would know how to count each candles on a
particular timeframe into the future from a triggered position. Thanks
on same chart
if( Time[15] > OrderOpentime your trade) then how many bars there has been passed ??
you need to find the bar where your trade is opend how do you find that bar ??
on same chart
if( Time[15] > OrderOpentime your trade) then how many bars there has been passed ??
you need to find the bar where your trade is opend how do you find that bar ??
Thanks, it's a strange way answering a question with a question however brilliant it is. I believe i get your point, but this gets complex afterwards as Time[], iTime() would only use a greater than comparison and this functions always would be greater than OrderOpenTime() once HIT. While the challenge is to get exactly in this case 15 candles from OrderOpenTime().
Bar Trade opened i believe can be found using iBarShift() // Yet another time function.
I appreciate your solution, however, the problem remains same. To count exactly 15(or any amount) candles after OrderOpenTime() without the use of time function except of course to know the BAR the order was opened else What happens during the Weekend?.
Cannot see how this would get complex. Do not count bars, calculate ahead-of-time the exit bar time:
Say, 20 bars means 20*PERIOD_XX seconds;
Bar time at the time point of trade is Time[0];
So, in your example, exit_bar_time = Time[0] + 20 * PERIOD_M15;
From there you compare: if(Time[0] >= exit_bar_time) do_what_you_need_to_do_after_20_bars();
Cannot see how this would get complex. Do not count bars, calculate ahead-of-time the exit bar time:
Say, 20 bars means 20*PERIOD_XX seconds;
Bar time at the time point of trade is Time[0];
So, in your example, exit_bar_time = Time[0] + 20 * PERIOD_M15;
From there you compare: if(Time[0] >= exit_bar_time) do_what_you_need_to_do_after_20_bars();
Thanks, it's a strange way answering a question with a question however brilliant it is. I believe i get your point, but this gets complex afterwards as Time[], iTime() would only use a greater than comparison and this functions always would be greater than OrderOpenTime() once HIT. While the challenge is to get exactly in this case 15 candles from OrderOpenTime().
Bar Trade opened i believe can be found using iBarShift() // Yet another time function.
I appreciate your solution, however, the problem remains same. To count exactly 15(or any amount) candles after OrderOpenTime() without the use of time function except of course to know the BAR the order was opened else What happens during the Weekend?. //Olympics no trading no new bars
on same chart
if( Time[15] > OrderOpentime your trade) then how many bars there has been passed ?? Atleast 15 it can be at bar 16 but also at all bars > 16
you need to find the bar where your trade is opend how do you find that bar ?? It is the first bar where 'OrderOpentime your trade' is equal or greater then Time[bar]
Finding the bar trade has opend
Use a loop counting up from zero and find the first bar where 'OrderOpentime your trade' is equal or greater then Time[bar]
Show me how you do that........
Finding the bar trade has opend
Use a loop counting up from zero and find the first bar where 'OrderOpentime your trade' is equal or greater then Time[bar]
Show me how you do that........
Ummm... @deVries (if you permit my calling you that), that task as already been completed, though with a different approach, figured wouldn't so be the best idea counting bar numbers in open orders. Instead i have come up with a generic algorithm that learns from each tick update. "Hopefully this works" which currently the result have been ++ . But Looking into your solution statement, the problem i believe despite my been inexperienced(2weeks) with the program language, is the fact that we are still using a time function to locate the "OrderOpenTime()", which brings me to my initial question "How can one haven located the Order open Bar and count to current bar(x) a certain number without using a time function". Because looping from 0 would still be incorrect if one cannot identify the order open BAR[location] on chart in regards it's stated timeFrame. Else would lead into weekends/holidays (why? TimeFunction) and wouldn't want that. Great idea though, still with same task/challenge with my question.
Finding the bar trade has opend
Use a loop counting up from zero and find the first bar where 'OrderOpentime your trade' is equal or greater then Time[bar]
Show me how you do that........
This is funny, just had a thought. iBarShift() returns BAR Open Time and Time() returns open time for each BAR,
maybe what you are saying is, Get the order BAR open time (iBarShift) then
using the open time, identify each bar open time (Time[]) on the specified timeFrame, looping through iBars() or a certain given number. Then find the position where : orderBarOpenTime == Time[i]. This would make it possible to compare the found "position " to current position Thanks a lot.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use