[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 1014

 

001 replied.

As far as I understand this is where the comparison is made. If I'm wrong, let them correct me.

if(
(sar10>Open[0])&& // SAR 1 // compare with open price
(sar11>Close[0+1])&& // minute and compare with close price
(sar50>Open[0])&& // SAR 5
(sar51>Close[0+1])&& // minutes
(sar150>Open[0])&& // SAR 15
(sar151>Close[0+1])&& // minutes
(sar152<Close[0+2]) // trend start

)

but that's not it. To clarify, the Expert Advisor is attached to the 15 min. chart and SAR is compared to the price for 15, 5 and 1 min. time intervals.... Open[0] Close[0+2] and Close[0+2 ] is the open and close price. I need to compare the bottom of the chart, which is attached to the Expert Advisor on lower timeframes!

Thanks in advance...

 
boris.45:

Do you have this pair in the Market Watch window?

Try to recalculate all Timeframes when you get the message "No new data for symbol", because it asks you to do so. I usually do so: I open the data loading window (F2), double-click on the required symbol, double-click on M1 and load the data, despite all its messages. And I do it for each TF - M1, M5, M15 ... Month...

Usually it helps... Although I'm sometimes confused by it... :)

 
igrok2008:

But that's not it. To clarify, the Expert Advisor is attached to the 15 min. chart and SAR is compared to the price for 15, 5 and 1 min. time intervals.... Open[0] Close[0+2] and Close[0+2 ] is the open and close price. I need to compare the bottom of the chart, which is attached to the Expert Advisor on lower timeframes!

Thanks in advance...

   iSAR(Symbol(),PERIOD_M1, step,maximum,1);  // Данные параболика для текущего символа с периода М1
   iSAR(Symbol(),PERIOD_M5, step,maximum,1);  // Данные параболика для текущего символа с периода M5
   iSAR(Symbol(),PERIOD_M15,step,maximum,1);  // Данные параболика для текущего символа с периода М15
   iSAR(Symbol(),PERIOD_M30,step,maximum,1);  // Данные параболика для текущего символа с периода М30

   iOpen (Symbol(),PERIOD_M1,0);     // цена открытия минутной свечи текущего (нулевого) бара
   iClose(Symbol(),PERIOD_M1,0);     // цена закрытия минутной свечи текущего (нулевого) бара
   iOpen (Symbol(),PERIOD_M1,1);     // цена открытия минутной свечи предыдущего (первого) бара
   iClose(Symbol(),PERIOD_M1,1);     // цена закрытия минутной свечи предыдущего (первого) бара
   iOpen (Symbol(),PERIOD_M5,0);     // цена открытия пятиминутной свечи текущего бара
   iClose(Symbol(),PERIOD_M5,0);     // цена закрытия пятиминутной свечи текущего бара

By analogy, go ahead and do it yourself...

 
artmedia70:

Do you have this pair in the Market Watch window?

Try to recalculate all Timeframes when you get the message "No new data for symbol", because it asks you to do so. I usually do so: I open the data loading window (F2), double-click on the required symbol, double-click on M1 and load the data, despite all its messages. And I do it for each TF - M1, M5, M15 ... Month...

Usually it helps... Although I'm sometimes confused by it... :)

 
What can be the reason, when the EA does not close orders (even though it is specified in its code), and the tester gives out these errors:
 
ViktorF:
What may be the reason, when EA does not close orders (even though it is specified in its code), and tester gives such errors:
This is not correct in the code and that is why the EA does not close. And these are harmless errors, it is desirable to update the quotes
 
artmedia70:

By analogy, go ahead and do it yourself...

Please check!!!!!

//+------------------------------------------------------------------+
//|                                 expert SAR_1_5_15 min primer.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//---- input parameters
extern double    Lots=0.01;
extern int       StopLoss=300;
extern int       TakeProfit=150;
extern int       MagicNumber=123456;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
  
bool CheckOrders(int Type)
{
 bool Result=True;
 for(int i=0;i<OrdersTotal();i++)
  if(OrderSelect(i,SELECT_BY_POS))
   if(OrderMagicNumber()==MagicNumber && OrderSymbol() == Symbol())
      if(OrderType()==Type)
        {
         if(Type==OP_BUY)
           if(!OrderClose(OrderTicket(),OrderLots(),Bid,0))
             Result=False;
         if(Type==OP_SELL)
           if(!OrderClose(OrderTicket(),OrderLots(),Ask,0))
             Result=False;
         } 
        else Result=False;
 return(Result); 
}

// Проверяем наличие закрытой на текущей свече позиции типа Type. Если есть, то возвращает False  
bool CheckExists(int Type)  
{
 bool Result=True;
 for(int i=OrdersHistoryTotal()-1; i>=0;i--)
  if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
   if(OrderMagicNumber()==MagicNumber&&OrderSymbol()==Symbol()&&OrderCloseTime()>=Time[0]&&OrderType()==Type)
    {
     Result=False;
     break;
     }
 return(Result); 
 }
  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
    // Узнаем уровень стопов и спрэд
    int Spread = MarketInfo(Symbol(), MODE_SPREAD);
    int StopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL);

    // Рассчитываем значения Parabolic,на 0-ом, 1-ом и 2-м барах для 1,5-ти,15-ти минутн. графиков
    double sar10 = iSAR(NULL,1,0.02,0.2,0);
    double sar11 = iSAR(NULL,1,0.02,0.2,1);
    double sar50 = iSAR(NULL,5,0.02,0.2,0);
    double sar51 = iSAR(NULL,5,0.02,0.2,1);
    double sar150 = iSAR(NULL,15,0.02,0.2,0);
    double sar151 = iSAR(NULL,15,0.02,0.2,1);
    double sar152 = iSAR(NULL,15,0.02,0.2,2);
    // Определяем цену открытия и закрытия для 15,5 и 1 мин. графиков
   double Open10 = iOpen (Symbol(),PERIOD_M1,0); // цена открытия 1 мин. свечи нулевого бара
   double Close10= iClose(Symbol(),PERIOD_M1,0); // цена закрытия 1 мин. свечи нулевого бара
   double Open50 = iOpen (Symbol(),PERIOD_M5,0); // цена открытия 5 мин. свечи нулевого бара
   double Close51= iClose(Symbol(),PERIOD_M5,1); // цена закрытия 5 мин. свечи первого бара    
   //-------------открытие позиции Buy покупка----------------- 
    if(
    (sar10>Open10)&&     //  SAR 1 // сравниваем с ценой открытия
    (sar11>Close10)&&    // минута и сравниваем с ценой закрытия
    (sar50>Open50)&&         //  SAR 5
    (sar51>Close51)&&        // минут
    (sar150>Open[0])&&        //  SAR 15
    (sar151>Close[0+1])&&     // минут
    (sar152<Close[0+2])       // начало тренда
    )
     if(CheckOrders(OP_SELL) && CheckExists(OP_BUY))
      {
       if(StopLoss <= StopLevel+Spread)
         double SL = 0;
        else
         SL = Ask - StopLoss*Point;
       if(TakeProfit <= StopLevel-Spread)
         double TP = 0;
        else
         TP = Ask + TakeProfit*Point;
       if(!OrderSend(Symbol(), OP_BUY, Lots, Ask, 10, SL, TP, NULL, MagicNumber))
         Print("Не открыт ордер Buy. Ошибка №", GetLastError()); 
       }
    //-------------------Конец блока покупки -------------------
    
    //-------------Открытие позиции Sell продажа----------------  
    if(
    (sar10<Open10)&&       //  SAR 1// сравниваем с ценой открытия
    (sar11<Close10)&&      // минута и сравниваем с ценой закрытия
    (sar50<Open50)&&       //  SAR 5
    (sar51<Close51)&&      // минут
    (sar150<Open[0])&&        //  SAR 15
    (sar151<Close[0+1])&&     // минут
    (sar152>Close[0+2])       // начало тренда
    )
     if(CheckOrders(OP_BUY) && CheckExists(OP_SELL))
      {
       if(StopLoss <= StopLevel+Spread)
         SL = 0;
        else
         SL = Bid + StopLoss*Point;
       if(TakeProfit <= StopLevel-Spread)
         TP = 0;
        else
         TP = Bid - TakeProfit*Point;
       if(!OrderSend(Symbol(), OP_SELL, Lots, Bid, 10, SL, TP, NULL, MagicNumber))
         Print("Не открыт ордер Sell. Ошибка №", GetLastError()); 
       }

//-----------------конец блока продажи ----------------------
   return(0);
  }
//+------------------------------------------------------------------+

No errors detected on compile!!!!!

Thanks in advance!

 
artmedia70:
artemida70, there is a currency pair in the Market Watch window. I tried your method of loading, but it doesn't work. When loading the data, the green bar does not reach the end and the loading stops. On reloading, the "No new symbol data..." tableau stopped appearing. By the way, all timeframe cubes became bright colours at the same time (although the loading is done on M1). May be the loading file got corrupted? Your opinion - what to do ?
 
Vinin:


Maybe you wanted to ask how to get the value of a variable described in the include file?


Yes, that's exactly it. There is a file, you've posted, which is very useful, OptimizationReport.mq4. I slightly improved it in order to calculate the Recovery Factor. Now I want to get the value of this variable in the main code to speed up optimization by detecting the pass of the tester and setting the limit of the PV level. I tried to do it through global variables. The value of my variable is not visible in the main code.

In the EA I write:

double myValue = GlobalVariableGet("myValue");
Print("myValue="+myValue);
MessageBox("myValue="+myValue);
Alert("myValue="+myValue);

In include(laying out):

GlobalVariableSet("myValue", 1);

Doesn't work, myValue=0.00000000

Files:
 

Thought I'd check in here as well ...

How do I set up sending email to narod.ru?

All variants tried:

SMTP server - smtp.narod.ru

SMTP login: - имя@narod.ru

SMTP password - password

From: slt-soft@narod.ru

To: slt-soft@narod.ru

Error: Mail: login to smtp.narod.ru failed