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

 
alsu:
Do you bother to look in the terminal, RSI "in code" is there as standard.
If you don't have it, here you go.
Files:
rsi.mq4  3 kb
 

How do I lock the menu in MetaTrader4? Sometimes it gets so scattered all over the screen it's creepy. Well, the way the Taskbar is fixed in Windows, maybe the windows are fixed here as well?

 

Hello, could you please tell me

I have this code now:

         if(M_1<NizUroven && M_0 >=NizUroven)
                {
 for(int i=OrdersTotal()-1;i>=0;i--)
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
     {     CloseOrder();
     }
   Lot2=GetLot(MaxRisk);
NewOrder(OP_SELL,Lot2);
}


             if(M_1>VerhUroven && M_0<=VerhUroven)
               {
 for(int j=OrdersTotal()-1;j>=0;j--)
   if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))
     {    CloseOrder();
     }
Lot2=GetLot(MaxRisk);
 NewOrder(OP_BUY,Lot2);
}



how can I simplify it like this?

 for(int i=OrdersTotal()-1;i>=0;i--)
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
     {     CloseOrder(); 
     }
   Lot2=GetLot(MaxRisk);

         if(M_1<NizUroven && M_0 >=NizUroven) 
                { NewOrder(OP_SELL,Lot2);
}
             if(M_1>VerhUroven && M_0<=VerhUroven)
               {  NewOrder(OP_BUY,Lot2);
}

 

And another question, I've been optimising for six months and got these results. It is unclear why many passes have zeros (no deals)?

 
monopolie:

How do I lock the menu in MetaTrader4? Sometimes it gets so scattered all over the screen it's creepy. Well, the way the Taskbar is fixed in Windows, maybe the windows are fixed here as well?

They say it's not a bug, but a feature))
 
monopolie:

How do I lock the menu in MetaTrader4? Sometimes it gets so scattered all over the screen it's creepy. Well, the way the Taskbar is fixed in Windows, maybe the windows are fixed here as well?


Right-click on the menu - "Auto-size columns" and move as you like.
 
griha:

Hello, could you please

my code is like this:



how to simplify it by this principle?


this part:

for(int j=OrdersTotal()-1;j>=0;j--)
   if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))
     {    CloseOrder();
     }
Lot2=GetLot(MaxRisk);
 NewOrder(OP_BUY,Lot2);

put in a function:

ff(int cmd)
{
   for(int j=OrdersTotal()-1;j>=0;j--)
      if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))
      {
         CloseOrder();
      }
   double Lot2=GetLot(MaxRisk);
   NewOrder(cmd,Lot2);
}

and then:

if(M_1<NizUroven && M_0 >=NizUroven)
{
   ff(OP_SELL);
}

if(M_1>VerhUroven && M_0<=VerhUroven)
{
   ff(OP_BUY);
}

is as an example, with visibility or transfer to the function of the variable MaxRisk - figure it out yourself

 
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.

 

Hi all!

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

   string mytext = "Hello from programmer!";
   ObjectSetText("mycomment", mytext, 10, "Arial", Gray);
     if (ObjectFind("mycomment") == -1) {
         ObjectCreate("mycomment", OBJ_LABEL, 0, 0, 0);
         ObjectSet("mycomment", OBJPROP_CORNER, 2);
         ObjectSet("mycomment", OBJPROP_XDISTANCE, 5);
         ObjectSet("mycomment", OBJPROP_YDISTANCE, 7);}

output as a separate function so it can be called somehow:

mycomment("Hello from programmer!")