[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 209

 

I close open positions with this function when pipsing:

if ( ( PriceOpenLastPos(NULL, OP_BUY, Magic  )+ TakeProfit_Buy*Point)<=Bid 
 && PriceOpenLastPos(NULL, OP_BUY, Magic  )>0) 
 ClosePositions(NULL, OP_BUY, Magic );
//если профит позиции в пунктах превышает заданное 
//значение - закрывем позицию
 
Thank you very much, rid. But it is important for me to understand where I went wrong.
 
Alex5757000 писал(а) >>

When compiling, it gives out a bunch of errors. Help to understand, I can't see where I made a mistake myself.

//-----------------------------------------------------------------------------+
// Функция возвращает OrderOpenPrice последнего открытого экспертом рыночного ордера               |
//-----------------------------------------------------------------------------+ 
double Last_Order_Price() {
  double Last_price=0;
  for(int i=OrdersTotal()-1; i>=0; i--) {
    if(OrderSelect( i, SELECT_BY_POS)==true)  {
      if(OrderSymbol()!=Symbol())     continue;
      if(OrderMagicNumber()!=123456)  continue;
      if(OrderType()>1)               continue;
      
      Last_price =OrderOpenPrice();
      return( Last_price);
    }
  }
}
>> it should work. didn't check.
 

Thank you, Vinin and rid . I've got it figured out.

 
Can you please tell me if there is a tool in MT4 that can display 2 lines, the first line would show 0 and the second one would show the value in pips or price from the first zero line.
 

Hello, I am trying to make it so that it opens a buy position when the RSI indicator crosses the LevelDown line from bottom to top, and within the candle crossing does not count, only between the Close prices of the current and previous candlestick. The resulting code is given below, but it opens a position regardless of whether the candle formed or not, ie as soon as the next tick of RSI is above LevelDown opens position, and should be at the closing price. Can you please advise what to look out for?

      double redRSI  = iRSI(NULL, 0, PeriodRed, PRICE_CLOSE,0);         
      double redRSI_old  = iRSI(NULL, 0, PeriodRed, PRICE_CLOSE,1);         
      if (( redRSI >= LevelDown) && ( redRSI_old <= LevelDown))
      {
           ticket= WHCOrderSend(Symbol(),OP_BUY, MyLots,Ask,3, SL, TP,"Buy", Magic,0,Blue);
           if( ticket < 0) 
           {
                 Print("Ошибка открытия ордера BUY #", GetLastError()); 
                 Sleep(10000);   
                 return (0); 
           }
      }   
         
 
cdover писал(а) >>

Hello, I am trying to make it so that it opens a buy position when the RSI indicator crosses the LevelDown line from bottom to top, and within the candle crossing does not count, only between the Close prices of the current and previous candlestick. The resulting code is given below, but it opens a position regardless of whether the candle formed or not, ie as soon as the next tick of RSI is above LevelDown opens position, and should be at the closing price. Please advise what to pay attention to? Thanks in advance.

>> Go to the analysis not of the zero bar and the first, but of the first and second.

      double redRSI  = iRSI(NULL, 0, PeriodRed, PRICE_CLOSE,1);         
      double redRSI_old  = iRSI(NULL, 0, PeriodRed, PRICE_CLOSE,2);  
But the advisor needs to have control over the opening of a new bar
 
Vinin писал(а) >>

Go to the analysis not of the zero bar and the first bar, but of the first and the second bar.

But in our EA we have to provide control of opening of a new bar

I see, i.e. the current bar, even though it is not fully formed yet, still has a close price for the current moment... >> Thank you!

 

Good day to you all!


Can you tell me who knows what "External Experts" are and how they work?

 
  • Help fix code to open trade every hour.HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Thanks!!!!!!!!!!!!
Files:
Reason: