[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 405

 
Некоторые ДЦ на реальных счетах именам символов присваивают всякие префиксы типа "." или "FXF".

Как мне подставлять эти префиксы?

Try string StringConcatenate(...)

 
Dimka-novitsek:

Got it, I'll do it...

Also, the condition doesn't work.

It doesn't "don't work", it just doesn't get there for the same reason as for X

This can be clearly seen by the fact that there are no signals from i in Alert

 
ilunga:

it does not "not work", it just does not get to it for the same reason as X

this can be clearly seen by the fact that there are no signals from i in Alert


Yes, that's right...
 
Hooray, i says!!!!!!
//+------------------------------------------------------------------+
//|                                                    для лавин.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
extern double stoploss=0; extern double takeprofit=20;extern int otstup=20; extern datetime expiration=0;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
 int tiket,tikett;double volume=0.1;int i=0,R1=0,R2=0,A=1 ;double price=PRICE_OPEN;
   //  R1=((PRICE_OPEN- stoploss*Point)*stoploss)/stoploss;R2=((PRICE_OPEN+ stoploss*Point)*stoploss)/stoploss;
     
     
int start()
  {       int X,Y; double price=(Ask+Bid)/2;            
//----
       Alert ("OrdersTotal()",OrdersTotal());


 for(int i=OrdersTotal();i>0;i--){Alert ("i", i);if(OrderSymbol()==Symbol()&&OrderMagicNumber( )==1000){
OrderSelect(i,SELECT_BY_POS );if(OrderType( )==OP_BUYSTOP){X++;}}}Alert ("X", X);
if (X==0){


   tiket= OrderSend( Symbol(), OP_BUYSTOP,  volume*A, price +otstup*Point, Point* 3, R1, price+takeprofit*Point+otstup*Point, "OP_BUYSTOP", 1000,  expiration, Red); 
   Alert ("OP_BUYSTOP", GetLastError( )); }
   

 for ( i=OrdersTotal();i>0;i--){Alert ("i", i); OrderSelect(i,SELECT_BY_POS );if( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()) { 
if(OrderType( ) ==OP_SELLSTOP) { Y++;}}}Alert ("Y", Y);
 if (Y==0){ 
   tikett= OrderSend( Symbol(), OP_SELLSTOP,  volume*A, price -otstup*Point, Point* 3,R2, price-takeprofit*Point-otstup*Point, "OP_SELLSTOP" , 2000,  expiration,C'0,128,255' );
    Alert ("OP_SELLSTOP", GetLastError( )); 
    }       
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
ilunga:

well the "on the fly" option worked:

Yes, that's how it works. Thank you!
 
Phew!!! Hooray!!! We did it!!! All right!!!
 

Good afternoon. This is a problem, the Expert Advisor I wrote hangs after a certain amount of time? When I uninstall it, it says shutdown by timeout. What is the reason for this?

//+------------------------------------------------------------------+
//|                                                      RSITest.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  int deal, cnt;
  double TotalProfit;
//----
   // Проверяем, сободен ли торговый поток
if (!IsTradeAllowed())
{
return(0);
}


if (OrdersTotal() == 0)
   {
      while(true)
      {
         //*********************************** Открываем Buy ордер  ***********************************
         if (iRSI(NULL,0,14,PRICE_CLOSE,0) > iRSI(NULL,0,14,PRICE_CLOSE,1))
         { 
            if (iRSI(NULL,0,14,PRICE_CLOSE,0) > 60 && iRSI(NULL,0,14,PRICE_CLOSE,1) < 60)
            {
               deal = OrderSend(Symbol(),OP_BUY,0.1,Ask,0,iLow(NULL,0,0)-20*Point,0,"Long EUR/USD",0,0,CLR_NONE);
               if (deal > 0) Print("Long");
               else Print(GetLastError());
               return(0);
            }
         }
         //*********************************** Открываем Sell ордер  **********************************
         if (iRSI(NULL,0,14,PRICE_CLOSE,0) < iRSI(NULL,0,14,PRICE_CLOSE,1))
         { 
            if (iRSI(NULL,0,14,PRICE_CLOSE,0) < 40 && iRSI(NULL,0,14,PRICE_CLOSE,1) > 40)
            {
               deal = OrderSend(Symbol(),OP_SELL,0.1,Bid,0,iHigh(NULL,0,0)+20*Point,0,"Short EUR/USD",0,0,CLR_NONE);
               if (deal > 0) Print("Short");
               else Print(GetLastError());
               return(0);
            }
         }
      }
   }      
//else
//if
   //{
   for (cnt=0;cnt<OrdersTotal();cnt++)
      {
      if (OrderSelect(cnt, SELECT_BY_POS)==true)
      {
         TotalProfit += OrderProfit();
         if (TotalProfit>=2 || iRSI(NULL,0,14,PRICE_CLOSE,0)<iRSI(NULL,0,14,PRICE_CLOSE,1))
         {
            if (OrderType()== OP_BUY)
            {         
               // Закрываем и отдыхаем 15 минут
               OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE);
           //    Sleep(900000);
               return(0);
            }
         }
         if (TotalProfit>=2 || iRSI(NULL,0,14,PRICE_CLOSE,0)>iRSI(NULL,0,14,PRICE_CLOSE,1)) 
         {  
            if (OrderType()== OP_SELL)
            {     
               // Закрываем и отдыхаем 15 минут    
               OrderClose(OrderTicket(),OrderLots(),Ask,0,CLR_NONE);
           //    Sleep(900000);
               return(0);
            }
         }
      }
      }   
    //}


//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Remove the while loop, it is superfluous.
 
Thank you very much. Another question, I have 15 min. timeframe, let's say an order was closed at 18-38-55 how should I make my EA not work till 18-45-00, i.e. till the next bar?
 
Look at https://www.mql5.com/ru/forum/133552 and see how the Timebar variable is implemented in your case (with some modifications).