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

 
w_ersoc:

Mm-hmm. It's elementary. But it doesn't work.

You can argue, but so many people have said it's bullshit and in the end nothing ((


Here you go:

//+------------------------------------------------------------------+
//|          Function  : GetOrdersInThePrice(min,max,&tickets[])bool |
//|          Copyright © 2012, XrustSolution.  mail:xrustx@gmail.com |
//|          https://www.youtube.com/user/opmlv http://forexrust.info |
//+------------------------------------------------------------------+
//|   Description: Пишет в массив тикеты ордеров с ценою открытия    |
//| между максимальной и минимальной ценой, если ордеров нет = false |
//+------------------------------------------------------------------+
bool GetOrdersInThePrice(double pr1,double pr2,int &tickets[]){int i,ii;double min,max;
   min = MathMin(pr1,pr2);
   max = MathMax(pr1,pr2);
   ArrayResize(tickets,100);
   for(i=OrdersTotal()-1;i>=0;i--){
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
         if(OrderSymbol()!=Symbol()){continue;}
         if(OrderOpenPrice()>max){continue;}
         if(OrderOpenPrice()<min){continue;}
         tickets[ii] = OrderTicket();
         ii++;
      }
   }
   if(ii<1){return(false);}
   ArrayResize(tickets,ii);
   return(true);
}
 
FAQ:


Here you go:

incompatible types error

 
Leo59:

Dear granit77! If you don't mind, please make corrections directly in the code, if anything is wrong. It will be clear and understandable.

Example. Of the eight indicator buffers available, seven are used to display lines in the indicator window, the eighth is used for calculations, without displaying in the indicator window.
If there are not enough indicator buffers, the calculations can be performed in conventional arrays.

#property indicator_buffers 7 double ind_buffer1[]; double ind_buffer2[]; double ind_buffer3[]; double ind_buffer4[]; double ind_buffer5[]; double ind_buffer6[]; double ind_buffer7[]; double ind_buffer8[];//the eighth buffer is used for additional calculations //double ind_buffer9[];   //there is no ninth buffer in the indicator; this array has nowhere to go int init() { IndicatorBuffers(8); SetIndexBuffer(0,ind_buffer1); SetIndexBuffer(1,ind_buffer2);
SetIndexBuffer(2,ind_buffer3); SetIndexBuffer(3,ind_buffer4); SetIndexBuffer(4,ind_buffer5); SetIndexBuffer(5,ind_buffer6); SetIndexBuffer(6,ind_buffer7); SetIndexBuffer(7,ind_buffer8); //ind_buffer1...ind_buffer7 draw seven lines //they are displayed in the indicator window according to #property indicator_buffers 7 //ind_buffer8 is not displayed in the window, but is available for participating in calculations return(0); }
 
granit77:
Example. Seven out of eight indicator buffers are used to display lines in the indicator window, the eighth buffer is used for calculations, but it won't be displayed in the indicator window.
If there are not enough indicator buffers, the calculations can be done in normal arrays.



Thank you! That's understandable.

I do not understand another one. I do not know why the array that takes part in the calculations, but is not displayed in the indicator window, should be identified as the SetIndexBuffer. And if we need 10 arrays for calculations and 8 for displaying (18 arrays in total), how to declare and identify these 10 correctly? I want them to have the same properties, as the arrays attached to the indicator buffers, except they are not drawn.

 
Zhunko:

You don't have to rename it if it doesn't work. Which is odd. You can open it from the context menu by selecting WinRar. Or open WinRar, then from the "File" menu item "Open Archive" find the archive and open it.

I said above that the extension is needed only for automatic association of the file.

Have you enabled extension visibility? Screenshot or video here if it doesn't work.


Thanks for the detailed instructions. I did download this WinRar, apparently it wasn't there and the archive opened!
 
You know, I don't see the function working. True, the ticks aren't working now, but at least the start should work when joining the graph, right? Well, at least it compiles!!! I'm trying this.
//+------------------------------------------------------------------+
//|                                                  таймфрейммм.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#include <ServicesMT4.mqh>
void start()
  {
   int hwndChart = WindowHandle(Symbol(),Period());
   while (!IsStopped())
    {
     for (int i = 0; i < 9; i++)
      {
       ServiceSetTimeframeByNumber(hwndChart, i);
       Sleep(4000);
      }
    }
  }
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
 
PR //Profit
UB //Loss
Pk //Variable taking buy values
Pr //Variable taking values of sale
ADR //Variable taking values of the script

//Profit condition
if(PR==Pk) //If profit on purchase
ADR=1; //Set script 1
else //If profit on sale
ADR=2; //Set script 2

//Selling condition
if(UB==Pk) //If a loss on buying
ADR=2; //set script 2
else //If a loss on sale

ADR=1; //Set script 1

How do I improve this for trading? I need an EA to monitor which order closed (buy or sell), and how it closed at profit or loss. After such analysis the EA will execute 1 or 2 scripts.

 
What are the names of the take profit and stop loss variables? And how do I specify the address of the script to be executed?
 
Dimka-novitsek:
I do not see this function working, you know. True, the ticks don't occur now, but at least the start should work when connecting to the chart, right? Well, at least it compiles!!! Trying this

There are no ticks. The start is not triggered. Can be compiled as a script. But you will have to specify the descriptor of the adjacent chart, which will be updated.

Or like this:

#include <ServicesMT4.mqh>
int hwndChart = NULL;
void init()
 {
  hwndChart = WindowHandle(Symbol(),Period()); // Получаем системный дескриптор графика.
  ServiceRefreshChart(hwndChart, 1000); // Запускаем обновление графика каждую 1 секунду.
 }

void start()
 {
  ServiceStopRefreshChart(hwndChart); // Останавливаем обновление. Больше не требуется.
  while (!IsStopped())
   {
    for (int i = 0; i < 9; i++)
     {
      ServiceSetTimeframeByNumber(hwndChart, i);
      Sleep(4000);
     }
   }
 }

But it probably won't work for you. It seems that the ServiceRefreshChart () function is not available for everybody.

You can try it in the indicator. It refreshes 2 times when it joins the chart and changes TF.

 
Thank you!!!!!!