[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 65

 

Roll, thanks for the tip, here's a feature to display a comment in the bottom left hand corner of the chart if anyone needs it:

void mycomment(color c,string mytext)
{
string name="mycomment";
if(ObjectFind(name)<0) ObjectCreate(name,OBJ_LABEL,0,0,0);
ObjectSet("mycomment", OBJPROP_CORNER, 2);
ObjectSet(name,OBJPROP_XDISTANCE,5);
ObjectSet(name,OBJPROP_YDISTANCE,7);
ObjectSetText(name,mytext,12,"",c);
}

 
Can you tell me how to reopen a file in one script: open file - look through - close file, when I try to reopen it it says "end of file"...
 
Hello, Can you advise if anyone has encountered this problem: In the currency chart window, sometimes the chart itself disappears. Then it says refresh and everything is restored. At this time, sometimes expert advisors start working incorrectly (opening deals without conditions). Today even opened a trade with maximum lot. I have noticed it and closed with 2.5 points loss. Here is the code for determining the lot. I think this should not be so. I suspect that this is because of the last two lines. But how?
//========================================================================                                                                              
//определение лота
//========================================================================

double Free =AccountFreeMargin();
double One_Lot =MarketInfo(Symbol(),MODE_MARGINREQUIRED);
double Step =MarketInfo(Symbol(),MODE_LOTSTEP);
double Min_Lot =MarketInfo(Symbol(),MODE_MINLOT);
double Max_Lot =MarketInfo(Symbol(),MODE_MAXLOT);
LOT=NormalizeDouble(AccountFreeMargin()*RISK/100000,2);
if (LOT*One_Lot > Free) // Не хватает даже..
     {                                         // ..на минимальн. лот:(
         Comment("денег нет  " );  
            return(0);                           // ..и выход 
     }
     else Comment("деньга есть  " );
if(LOT<Min_Lot)
 LOT=Min_Lot;
if(LOT>Max_Lot)
 LOT=Max_Lot;
далее открытие ордера по условиям.
 
Lians:

Hi all!

Can you tell me if it's possible to display text on a graph, like

output as a separate function so it can be called like this:

Look at this function:

//+----------------------------------------------------------------------------+
void iPrint(bool print, string mess1, string mess2="", string mess3="", string mess4="", 
            int sz=9, color cl1=Aqua, color cl2=Aqua, color cl3=Aqua, color cl4=Aqua) {
   string   NameGrafText, message, nm;
   int      i, y, k, LenStr, shift, Win_Num=-1, num=0;
   color    cl;
   if (mess1=="") {
      Print("Func iPrint: Передана пустая строка, выходим");
      return;
      }
   Win_Num=WindowFind("Win_Inform");
   if (print || Win_Num<0) {
      message=mess1+mess2+mess3+mess4;
      Print(message); 
      return;
      }
   k=ArraySize(Mass_Name_Message)-1;
   if (StringLen(mess1)>0) num++;
   if (StringLen(mess2)>0) num++;
   if (StringLen(mess3)>0) num++;
   if (StringLen(mess4)>0) num++;
   for (i=k; i>=0; i--) {                             
      NameGrafText=Mass_Name_Message[i];           
      if (StringLen(NameGrafText)>0)
      if (ObjectFind(NameGrafText)==Win_Num) {
         if (i+num>k) {
            ObjectDelete(NameGrafText);  
            Mass_Name_Message[i]="";
            }
         else if (i+num<=k) {
            Mass_Name_Message[i+num]=Mass_Name_Message[i];
            y=ObjectGet(NameGrafText, OBJPROP_YDISTANCE);               // координата Y
            ObjectSet  (NameGrafText, OBJPROP_YDISTANCE, y+(sz+1)*num); // координата Y
            ObjectSet  (NameGrafText, OBJPROP_COLOR, LightSeaGreen);    // цвет
            }
         }
      }
   shift=num;
   int v=GetTickCount();
   for (i=0; i<num; i++) {
      shift--;
      NameGrafText=Prefix+"_Graf_Text_"+i+"_"+sy+"_"+v;
      int app=0;
      while (ObjectFind(NameGrafText)==Win_Num) {
         app++;
         NameGrafText=Prefix+"_Graf_Text_"+i+"_"+sy+"_"+v+"_"+app;
         }
      Mass_Name_Message[num-1-i]=NameGrafText;
      switch (i) {
         case 0: message=mess1; cl=cl1; break;
         case 1: message=mess2; cl=cl2; break;
         case 2: message=mess3; cl=cl3; break;
         case 3: message=mess4; cl=cl4; break;
         default:message=mess1; cl=cl1; break;
         }
      ObjectCreate (NameGrafText, OBJ_LABEL, Win_Num, 0, 0);
      ObjectSetText(NameGrafText, message, sz, "Courier New", cl);
      ObjectSet    (NameGrafText, OBJPROP_COLOR, cl);                   // цвет
      ObjectSet    (NameGrafText, OBJPROP_CORNER,    2);                // угол
      ObjectSet    (NameGrafText, OBJPROP_XDISTANCE, 150);              // координата Х
      ObjectSet    (NameGrafText, OBJPROP_YDISTANCE, 2+(sz+1)*shift);   // координата Y
      WindowRedraw();
      }
   return;
}
//+----------------------------------------------------------------------------+

It looks for empty Win_Inform indicator window on the chart and, if it is present, displays messages in it. If not, outputs it with print.

Example call:

//-------------------------------------------------------
   message1=StringConcatenate("Тик: ",GetTickCount()," ");
   message2=StringConcatenate("Цена Bid: ", DoubleToStr(Bid,dg));
   iPrint(false, message1, message2, "", "", 9, Aqua, DarkOrange);
   b=4; c=7;
   a=b+c;
   message1=StringConcatenate("a=",a," ");
   message2=StringConcatenate("b=",b," ");
   message3=StringConcatenate("c=",c);
   iPrint(false, message1, message2, message3, "", 9, Aqua, LimeGreen, DarkOrange);
   
   message1=StringConcatenate("Время: ", TimeToStr(TimeCurrent())," ");
   message2=StringConcatenate("Тик: ",GetTickCount()," ");
   message3=StringConcatenate("Время бара: ",TimeToStr(Time[0])," ");
   message4=StringConcatenate("Цена Bid: ", DoubleToStr(Bid,dg));
   iPrint(false, message1, message2, message3, message4, 9, Aqua, Aqua, Aqua, DarkOrange);
//-------------------------------------------------------

Uses array string Mass_Name_Message[10] declared at global level. This is an array for storing object names. You can change its size to suit your needs. The Prefix variable stores names of experts to allow them to identify their own objects for correct handling of graphical objects. It is also declared globally and has the string type. You can probably figure it out...

Turkey in a trailer

Files:
 

Faced with a small problem with my function:

void mycomment(color c,string mytext)
{
string name="mycomment";
if(ObjectFind(name)<0) ObjectCreate(name,OBJ_LABEL,0,0,0);
ObjectSet("mycomment", OBJPROP_CORNER, 2);
ObjectSet(name,OBJPROP_XDISTANCE,5);
ObjectSet(name,OBJPROP_YDISTANCE,7);
ObjectSetText(name,mytext,12,"",c);
}

It trims a long message, for example if you try to comment on the line "Check your EA settings, to open the settings window press F7".

it just leaves this: "Check your EA settings to open the settings window" and then it is cut off, although the text is not even halfway down the window.

Can you please tell me if there is any way to remove this restriction?

 

No, maximum line length in label = 62 characters.

Format the text into multiple lines (labels), or use Comment() - there are 255 characters

 
Good afternoon!
I have encountered a problem with opening a certain (user-defined) number of orders.
I have written a small code to solve this problem.
But there are times when an arbitrary number of orders is opened, usually near the end of the test.

Below is the code itself.

extern string Kolichestvo_orderov = "Количество единовременно открытых ордеров";
extern int OrederBuy = 1;
extern int OrederSell = 1;


int OrdS=1,OrdB=1,ticketBuy,ticketSell,lastticketSell=0,lastticketBuy=0;

//========================================================================================================//     
                                  //---- Открытие ордеров SELL ----//
//========================================================================================================//

if(OrdS<=OrederSell)
  { //----- start
 
if(trendDn==true && SthFast>88.2 && SthSlow<38.2)
     {
ticketSell=OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,0,magick,0,Blue);OrdS++; //--- Если ордер открыт параметр OrdS увеличиваю 
     }
   } //-----end
          
//========================================================================================================//  
                                   //----Открытие ордеров BUY ----//
//========================================================================================================//  

if(OrdB<=OrederBuy)
  { //-----start

if(trendUp==true && SthFast<11.8 && SthSlow>61.8)
      {
ticketBuy=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,0,0,magick,0,Red);OrdB++; //--- Если ордер открыт параметр OrdB увеличиваю
      }

  } //------end
  

//------------------------------- Подсчет количества ордеров BUY & SELL ----------------------------------//
   
  if(ticketBuy<=OrdersHistoryTotal()) //------ проверка тикетов тех  ордеров которые уже закрыты
   {
  for(int ordBuy=lastticketBuy;ordBuy<=OrdersHistoryTotal();ordBuy++) //--- перебор новых закрытых ордеров
    {
     if(OrderSelect(ordBuy,SELECT_BY_POS,MODE_HISTORY)==true){if(OrderType()==OP_BUY)OrdB--;lastticketBuy=ticketBuy;} //--- если добавился новый закрытый ордер бай, то параметр OrdB уменьшаю
    }
   }
  
  //-----
    
 if(ticketSell<=OrdersHistoryTotal()) //------ проверка тикетов тех  ордеров которые уже закрыты
  {
 for(int ordSell=lastticketSell;ordSell<=OrdersHistoryTotal();ordSell++) //--- перебор новых закрытых ордеров
     {
     if(OrderSelect(ordSell,SELECT_BY_POS,MODE_HISTORY)==true){if(OrderType()==OP_SELL)OrdS--;lastticketSell=ticketSell;} //--- если добавился новый закрытый ордер селл, то параметр OrdS уменьшаю

If you have a simpler solution, I would be glad to receive comments.

 
Lians:

Faced with a small problem with my function:

void mycomment(color c,string mytext)
{
string name="mycomment";
if(ObjectFind(name)<0) ObjectCreate(name,OBJ_LABEL,0,0,0);
ObjectSet("mycomment", OBJPROP_CORNER, 2);
ObjectSet(name,OBJPROP_XDISTANCE,5);
ObjectSet(name,OBJPROP_YDISTANCE,7);
ObjectSetText(name,mytext,12,"",c);
}

It trims a long message, for example if you try to comment on the line "Check your EA settings, to open the settings window press F7".

it just leaves this: "Check your EA settings to open the settings window" and then it is cut off, although the text is not even halfway down the window.

Can you please tell me if there is any way to remove this restriction?

Try my function. It is above your post on this page. Split a string into several strings so that each string is no more than 64 characters long. My function outputs these split lines one above the other. Then, when the next message is displayed, it grayscales the old ones above, and displays the new message in the colour you set when you called my function.
 
I downloaded the history and accidentally found out that I have a hole in USDJPY from 2012.01.16 to 2012.03.20. When I tried to re-download it, the terminal replied that I have the entire history.
How can I fill this gap?
How can I upload the history without any holes?
And is there any way to check if there is a hole in the history?
 
artmedia70:
Try my function. It is above your post on this page. Split a string into several strings so that each string is no more than 64 characters long. My function outputs these split lines one above the other. Then, when the next message is displayed, it grayscales the old ones above, and displays the new message in the colour you set when you called my function.
Thanks, but it's a bit complicated for me, and your function outputs 4 messages at once, while I need one. It turns out no more than 64 characters in one line?