[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 215

 
Qra:

Good day to all!

I'm writing my first bot, and at the same time I'm getting acquainted with MQL. I have the following problem during testing:

Order OP_BUYSTOP is executed right after the order is placed, although judging by the chart, the price does not reach the target value (see below)

TimeTypeOrderVolumePriceS / LT / PProfitBalance
12011.09.19 02:10buy stop10.0176.93576.73577.135
22011.09.19 02:10buy10.0176.93576.73577.135

USDJPY,M5 (visual)

Date 2011.09.19

Time 02:15

Open 76.903

High 76.909

Low 76.890

Close 76.890

Volume 66

I am testing all ticks.

Maybe I do not understand OP_BUYSTOP order correctly? To buy if the price exceeds a certain value, right?

Here is a bit of source code that places an order

int ticket=OrderSend(Symb, OP_BUYSTOP, Lot, Price, 0, SL, TP);

Thank you all very much in advance!

On the candlestick chart, all prices are Bid and any buy order is executed at Ask price.
 
PapaYozh:
On the candlestick chart, all prices are Bid and any buy order is executed at Ask price.

Thank you!

 
Hi all!

I want to delete pending horizontal lines if their level has been broken by the current price. Another way to put it: if the level has been exceeded or "renegotiated" already after OBJ_HLINE has been created.

Thanks to Roll for the help. Could you please tell me how to correctly track the condition of keeping the level at a known period?
//----------------------------------------------------------------------+ 
//  Удаление  OBJ_HLINE при пробитии его уровня   /Red-Up/Blue-Down|    |
//----------------------------------------------------------------------+   
void DelHLine( string nm="")  
   {
    int obj_total=ObjectsTotal();

       for(int i=1;i<obj_total;i++) 
      { 
        nm=ObjectName(i);
         if(nm==ObjectName(i)&&ObjectType(nm)==OBJ_HLINE)
         {
          color    cl     = ObjectGet(nm,OBJPROP_COLOR);
          double   pl     = ObjectGet(nm,OBJPROP_PRICE1);
          datetime timeSet= ObjectGet(nm,OBJPROP_TIME1);
          int      shift  = iBarShift(NULL,0,timeSet);
   
          if((cl==Red  && pl<High[iHighest(NULL,0,MODE_HIGH,shift,1)])||
             (cl==Blue && pl>Low [iLowest (NULL,0,MODE_LOW, shift,1)]) ) ObjectDelete(nm); 
         } 
      }
    return(0);  
  }
//+------------------------------------------------------------------+
 

Hello! Please help me.

I can't understand why this script doesn't display the data in excel as columns.

When running it in excel, there is only a table header, no data.

Help me to understand why delimiter is not perceived by excel.

Files:
writefile.mq4  3 kb
 

I'm starting with programming, so a lot of questions arise, thank you in advance for your attention!

I wrote a script called NewScript, which performs a simple function - display OHLC prices by bars on a chart...

My question is - if BARS is exactly the number of bars on the current chart, then why in my EA log displays the number of bars on the screen (about 200), but in my log more than 2000?

Thank you!

Files:
 
Vinin:


Small correction


double Hi (int pos=0) //создали Hi, зависящую от pos
{ 
  int i=pos; //присваиваем "i" значение от "pos", то есть i равно pos
  double H=0;
  while (i<=pos+10) //как она может быть меньше, если она равна?
  {
    if (H<iMACD (NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i))  //это мне вообще не понятно... то есть если значение "Н" будет меньше, то присваиваем...  
      H=iMACD (NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i); //то есть он определит мне наинизший, но не наивысший бар


    i++; //ну тут мы добавляем к "i" плюс 1
  }
  return(H); //возвращаем Hi в самое начало
}

sorry, can't understand the function...

 
CLAIN:



The easiest option

double Hi (int pos=0) 
{ 
  double H[10]; // Объявили массив
  
  for (i=pos+1;i<=pos+10;i++) // формируем массив
  {
    H[i]=iMACD (NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i);
  }
  int MaxId=ArrayMaximem(H); ищем индекс максимального элемента
  return(H[MaxId]); // возвращаем максимальный элемент
}
 

Hello!

Can you help me write code to stop the EA for a while?

I wrote the code like this.

int init() {
string OrderStop="OrderStop "+ Symbol();
OrderSig =GlobalVariableGet(OrderStop);
// Print (OrderSig);

return (0);
}

int deinit() {
return (0);
}

int start() {
string OrderStop="OrderStop "+ Symbol();
OrderSig = GlobalVariableGet(OrderStop);

if (OrderSig==1)return(0);

else {

EA body(code)

}

return(0);

}

In the trailer this code works, but when I compile or rerun Terminal,

EA starts to work (opens position) and does not trade again.

What can it be?

Or tell me another option.

 
alega:

Or suggest another option.

Use a f:

  Sleep (3000);
 
Thank you, I'll give it a try.
Reason: