Make EA stop executing orders if the latest OrderOpenPrice is less than XX number of points. (MQL

 

I'm trying to stop my EA from executing orders if the latest order open price is less than number of points,


As far as I know, I have to identify the Order open price of the latest order,


Please help.

 
u110725: latest order open price is less than number of points,

That is your problem; it makes no sense. Until you can state your want in concrete terms, it can not be coded. A price can only be less n points relative to another price.

Help you with what? You haven't stated a problem, you haven't stated a valid want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
          No free help (2017)

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum (2018)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
          No free help (2017)

 

Wow, little sparky there, You don't have to be rude.

if you don't want to help, then don't.


Anyways I will try to explain the problem,,

Lets say I'm using Moving Averages crossovers to execute orders,

But since MA crossovers work best when there in a trends, so when prices are moving sideways, a lot of crossovers are going to happen so therefor orders will be executed, that's why I want to insert a code to stop these trades.


Hope it's clear, otherwise I will code a simple MA crossover strategy to illustrate.

 
u110725 #:

Wow, little sparky there, You don't have to be rude.

if you don't want to help, then don't.


Anyways I will try to explain the problem,,

Lets say I'm using Moving Averages crossovers to execute orders,

But since MA crossovers work best when there in a trends, so when prices are moving sideways, a lot of crossovers are going to happen so therefor orders will be executed, that's why I want to insert a code to stop these trades.


Hope it's clear, otherwise I will code a simple MA crossover strategy to illustrate.

If you need coding help you should show your attempt.

If you need trading ideas you are in the wrong section.

 

do it like i do... when a new trade is opened, i retrieve the orderopenprice of the last order, and record that, and then do whatever i want when price is x distance from that price. If you want the ea to stop doing all actions, then just have it "return". But remember that if your ea manages those trades, such as a trail stop or virtual takeprofit, then, your trades will also stop being monitored and manaaged.

But as the forum gods have coldly told you, your post is undsecriptive, and lacking any indication that you have attempted to do it yourself. If you want help on this forum you have to show that you have made some attempt. But if you are not coding, then you should look on Marketplace where I am sure you can find some eas that can do what you ask, for a price.

 

Generally, you are expected to post your code attempt to receive help otherwise assistance provided will be based on guess work or inaccurate interpretation of your request. Furthermore, you need to relate cordially with the senior coders. 

   datetime             last_position_time         = 0;
   double               last_position_price_open   = 0.0;
   ENUM_POSITION_TYPE   last_position_type         = -1;

   for(int i=PositionsTotal()-1;i>=0;i--)
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
           if(m_position.Time()> last_position_time)
              {
               last_position_time         = m_position.Time();
               last_position_price_open   = m_position.PriceOpen();               l
               last_position_type         = m_position.PositionType();
               }

      if(last_position_type==POSITION_TYPE_BUY )                     
      if (last_position_price_open - 200*_Point > m_symbol.Ask()  )
      Sleep(1000); // suspend execution of the EA for 1 second