How I assemble my advisor by trial and error - page 27

 
Алексей Тарабанов:

Did you like it?

I need to see it in action

not for me, for him

 

I think there is not enough of a separate, stop limit and profit for the horizontal lines, which are set automatically.

that's plus 4 more lines - and no! 8

Photo by

 
Aleksandr Klapatyuk:

I think there is not enough of a separate, stop limit and profit for the horizontal lines, which are set automatically.

that's plus 4 more lines - and no! 8


#property version "1.11"

sets a horizontal StopLoss line and if price moves in the right direction the position is closed

yellow lines are StopLoss and trawl at the same time

trall

input string   t1="------ TakeProfit    ----------";    // TakeProfit
input double   InTakeProfit            = 54;            // Take Profit, in pips (1.00045-1.00055=1 pips)

it cannot be zero - it will close immediately. you have to set how many pips you want the position to be closed.

Photo by

Snapshot1

you have to set how many pips you want the position to be closed.

Files:
 
2019.10.28 10:21:58.667 Your intelligence (USDJPY,H1)   zero divide in 'Your intelligence.mq5' (1481,14)

I get this error and the Expert Advisor is deleted when I open a position. the account is 500 GLD.

I can't figure it out yet.

 
Aleksandr Klapatyuk:

I get this error and the Expert Advisor is deleted when I open a position. the account is 500 GLD.

I can't figure it out yet.

Damn! and there is no information in the search . can anyone tell me what the error is?

2019.10.28 10:21:58.667 Your intelligence (USDJPY,H1) zero divide in 'Your intelligence.mq5' (1481,14)

Photo by

 
Aleksandr Klapatyuk:

I get this error and the Expert Advisor is deleted when I open a position. the account is 500 GLD.

I can't figure it out yet.

In the code, line 1481, position 14 - look for an error.

 
Vladimir Karputov:

In the code, line 1481, position 14 - look for an error.

Thank you very much ! I think I figured out what the reason is . Thanks for the tip !!!

 
Vladimir Karputov:

In the code at line 1481, cursor position 14 - look for an error.

Here - I messed up.

  {
//---
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of current positions
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
        {
         if((PositionGetDouble(POSITION_PROFIT)/PositionGetDouble(POSITION_VOLUME)/
             SymbolInfoDouble(Symbol(),SYMBOL_TRADE_TICK_VALUE))/n<-InStopLoss)
            ClosePosition(m_position.Symbol());  // close a position by the specified symbo
        }
  }

corrected it to this - just haven't checked this function yet - but it's supposed to work

  {
//---
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of current positions
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
        {
         if(m_position.Commission()+m_position.Swap()+m_position.Profit()/n<-InStopLoss)
            ClosePosition(m_position.Symbol());  // close a position by the specified symbo
        }
  }

Once again - Thank you very much! Health ! and All the best !

 

now noticed - in the terminal where - GLD account

the profit does not change after opening a position - as it shows 8 pips and does not change

the price moves on the chart - maybe that's why I got an error

InkedAlpari MT5_LI

 

here - I messed up.

  {
//---
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of current positions
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
        {
         if((PositionGetDouble(POSITION_PROFIT)/PositionGetDouble(POSITION_VOLUME)/
             SymbolInfoDouble(Symbol(),SYMBOL_TRADE_TICK_VALUE))/n<-InStopLoss)
            ClosePosition(m_position.Symbol());  // close a position by the specified symbo
        }
  }

I fixed it to this - just haven't checked it yet - but it's supposed to work.

  {
//---
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of current positions
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
        {
         if(m_position.Commission()+m_position.Swap()+m_position.Profit()/n<-InStopLoss)
            ClosePosition(m_position.Symbol());  // close a position by the specified symbo
        }
  }

I should leave it - where I messed up. - it works! and as I wanted to correct, does not work and /n and deleted and with it. does not work .

the whole reason is the GLD account itself. opened a USD account in the same terminal and everything works