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

 

Thanks. In principle, just replace "||" with "&&" (I probably wanted to check for inequality and then continue) and everything will work, but in the tester it will work anyway. Although, of course, your version will be more correct.

 

Well, these are nuances. I still try to rewrite it to suit my needs. I, for example, don't need medjic selection at all (in this function). Also I noticed that selection in function Figar0 was from the history list. The main thing here is to understand the idea. By the way, I need orders from the pool, so it all turned out much easier.

Thanks for the ideas and help, people.

PS: And please explain about

OrderType()>1
I've seen several times that OrderType is compared as int. What's the trick here? I thought it was a string variable.
 
Pyro:

Well, these are nuances. I still try to rewrite it to suit my needs. I, for example, don't need medjic selection at all (in this function). Also I noticed that selection in function Figar0 was from the history list. The main thing here is to understand the idea. By the way, I need orders from the pool, so it all turned out much easier.

Thanks for the ideas and help, people.

PS: Could you explain the following?

I've seen OrderType compared as int a few times. What's the trick here? I thought it was a string variable.

This is a correspondence between constants and their values.

OP_BUY corresponds to 0

OP_SELL corresponds to 1

__________________________________________________________________________________________________________-

Type of operation for the OrderSend() function. Can be any of the following values:

Constant Value Description
OP_BUY 0 Buy
OP_SELL 1 Sell
OP_BUYLIMIT 2 BUY LIMIT pending order
OP_SELLLIMIT 3 Pending SELL LIMIT order
OP_BUYSTOP 4 Pending BUY STOP order
OP_SELLSTOP 5 Pending SELL STOP order
 
Pyro:

By the way, I need orders from the pool, so it turned out to be much simpler.

When selecting an order by index, two lists are used - open and closed. This is set by specifying in which list you want to see them (parameter pool).

Therefore, if we need to select from a list of open orders, then we can omit specifying this parameter (it is set by default). If we want to choose from a list of closed orders, we should specify MODE_HISTORY as a parameter.

Accordingly, if you want to find the last open order, the loop is made on open orders of the terminal and you should also check the time of opening OrderOpenTime(), if you need the last closed order (as in the above examples), the loop should be made on closed orders of the terminal and you should check OrderCloseTime() to find out when the selected order was closed.

And for your reference, if you select by ticket, the parameter pool will be ignored at all and the order will be found in both lists. Once the order has been found, we must check its close time to find out which list the order has been selected from. If the time of closing is higher than zero, the order is closed and has been selected from the list of closed orders. If the time of closing of an open order is always equal to zero. So, if it is equal to zero, the order has been selected from the list of open orders.

Also, if you search for a pending order by its ticket, it can appear in both lists. This will happen if it is converted to a market order. Therefore you will also need to check the type of order you have chosen. And if the pending order is closed, and the market order with the same ticket is not closed, it means that the pending order has been transformed into a market order.

 
Figar0:

Thanks. In principle, just replace "||" with "&&" (I probably wanted to check for inequality and then continue) and everything will work, but in the tester it will work anyway. Although, of course, your version will be more correct.

I myself sometimes make silly mistakes when posting code here... Then I correct the code like scalded before it is read in improper form... :)))
 
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2

extern int period=24;
double Buf_0[],Buf_1[];

//+------------------------------------------------------------------+
int init()
  {
//---- 
   SetIndexBuffer(0,Buf_0);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(1,Buf_1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
//----
   return;
  }
//+------------------------------------------------------------------+
int start()
  {
   int  i,counted_bars,maxValueIdx,minValueIdx; 
//----

   counted_bars=IndicatorCounted();
   i=Bars-counted_bars-1;
   
   while(i>=0)
   {
   maxValueIdx=ArrayMaximum(Close,(period-1),0); 
   minValueIdx=ArrayMinimum(Close,(period-1),0);
   Buf_0[i]=Close[maxValueIdx];
   Buf_1[i]=Close[minValueIdx];
   i--;
   }
   
   
//----
   return;
  }
//+------------------------------------------------------------------+
Hello, I wanted to write an indicator that reads the MAX and MIN of the closing price for a certain period. I'm following the tutorial, but the old data is not shown at all, it shows two horizontal lines with the current MAX and MIN. Can you tell me what I'm doing wrong?
 
borisis:
Hello, I wanted to write an indicator that counts the MAX and MIN of the closing price for a certain period. Like all I do in the tutorial, but the old data is not drawn at all, it shows two horizontal lines with the current MAX and MIN. Can you tell me what I'm doing wrong?


maxValueIdx=ArrayMaximum(Close,(period-1), i);

minValueIdx= ArrayMinimum(Close,(period-1), i);

Otherwise you keep finding the same indexes at every step

 

Hi all! How to find out programmatically what type of variable belongs to: int OR double?

and secondly, what does the error "invalid double number as parameter 1 for DoubleToStr function" mean?

 
todem:

Hi all! How do I know the type of a variable: int OR double?

Curious as to why? Can you describe a situation where this would be needed?
 
Moved.

Valdemar 01.04.2011 16:31
Greetings to all masters of programming! Hint at the right idea, if you do not mind: Here I, say I decided at the end of a certain hour of trading, put a stop order, pushing away from the high and low of the hour on a few points, what I should use, write a programming function!
Reason: