Where is the ea
The adviser did not go anywhere. Advisor is in its place:

I want to refine the Expert Advisor for myself, but to do this I need to understand a lot of things! (I don't understand a lot of things). I will ask questions in parts.
There is a code:
if(m_need_delete_buy_stop || m_need_delete_sell_stop) { int count_buy_stops=0,count_sell_stops=0; CalculateAllPendingOrders(count_buy_stops,count_sell_stops); if(m_need_delete_buy_stop) { if(count_buy_stops>0) { DeleteOrders(ORDER_TYPE_BUY_STOP); return; } else { m_need_delete_buy_stop=false; return; } } if(m_need_delete_sell_stop) { if(count_sell_stops>0) { DeleteOrders(ORDER_TYPE_SELL_STOP); return; } else { m_need_delete_sell_stop=false; return; } } }
What does it do?
I want to refine the Expert Advisor for myself, but to do this I need to understand a lot of things! (I don't understand a lot of things). I will ask questions in parts.
There is a code:
What does it do?
If flag'm_need_delete_buy_stop' ('need to delete pending buy stop orders ') or m_need_delete_sell_stop' ('need to delete pending sell stop orders') is raised
if(m_need_delete_buy_stop || m_need_delete_sell_stop)
{ proceed to deleting.
We calculate how many pending orders the Expert Advisor has placed at the moment:
int count_buy_stops=0,count_sell_stops=0; CalculateAllPendingOrders(count_buy_stops,count_sell_stops);
If 'it is necessary to delete pending buy stop orders':
if(m_need_delete_buy_stop) { if(count_buy_stops>0) { DeleteOrders(ORDER_TYPE_BUY_STOP); return; } else { m_need_delete_buy_stop=false; return; } }
and the number of placed buy stops is greater than zero ('count_buy_stops') - delete them. If the number is equal to zero - reset the'm_need_delete_buy_stop' flag.
We do the same if 'it is necessary to delete pending sell stop orders' ...
- www.metatrader5.com
Thank you!
Another code I don't understand:
//--- we work only at the time of the birth of new bar static datetime PrevBars=0; datetime time_0=iTime(m_symbol.Name(),InpWorkTimeFrame,0); if(time_0==PrevBars) return; PrevBars=time_0; if(!RefreshRates()) { PrevBars=0; return; }
This code does the following: it works only once - at the moment when a new bar is born.
Thank you. That's what I understood in the end:
//--- we work only at the time of the birth of new bar // remember the time of opening of the last bar in the static variable static datetime PrevBars=0; // current time (iTime - returns the value of bar opening time) datetime time_0=iTime(m_symbol.Name(),InpWorkTimeFrame,0); if(time_0==PrevBars) return; // if the time is different because the condition has passed if(time_0==PrevBars) // remember the time PrevBars=time_0; // if quotes have not been updated, then reset the time of the last bar opening if(!RefreshRates()) { PrevBars=0; return; } // if you've reached this place, it's not a new bar.
Without your link I wouldn't have figured it out)
Thank you. Here's what I realised in the end:
I wouldn't have figured it out without your link)
Small correction. This is
// if you've reached this place, it's not a new bar. is incorrect. It's correct:
// you've reached this spot, so the bar is new.
By the way, right below is the code:
if(!RefreshRates() || !m_symbol.Refresh()) { PrevBars=0; return; }
I think it partially duplicates the code discussed above:
if(!RefreshRates()) { PrevBars=0; return; }
I think it can be deleted
A small correction. This is
is incorrect. It's correct:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Cidomo:
The Expert Advisor uses Buy Stop and Sell Stop pending orders.
Author: Vladimir Karputov