[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 700

 
cyclik33:


I told you why the code doesn't work properly - you put it in the wrong place... :) I think if you unscrew the wheels and put them in the boot, you won't get far, even though the wheels are there and the doors close... :)
 
T-G:

The question may be trivial, the Expert Advisor is trading on M1, the signal to open an order came in, let's assume the stop is short and the order closed on the sl. but the condition to open the order still exists.

What is the best way to ensure that the order is not opened again at the same minute?

Check the opening of a new candle. If it's a new one, you open, if it's an old one, you don't...
 
ToLik_SRGV:

The number count in OrderSelect() starts at zero. And you have 1, which means you are looking for a second order, although you only have one in the market, which is why it doesn't work.

Thanks, I forgot.
 
ToLik_SRGV:

Boris, a small correction in the code, I forgot to add resetting the array position, when returning to the original lot:


Tolik, please advise me, it works strangely. After a losing one it may open the initial lot, if this one is losing too, it may open the initial lot again.

And sometimes after the first loss it takes 0.4.

I must have put something in the wrong place?

 
cyclik33:


I have a very strange way of working with this code. After losing one it may open the first lot and if this one is losing again, it may open the first lot.
And sometimes after the first loss takes 0.4.
I must have put something in the wrong place?

Boris, a small correction in the code, I forgot to add resetting of array position, when returning to the original lot:

//+------------------------------------------------------------------+
double getMartinLot(double lot, double arrayLot[]){//ФУНКЦИЯ УПРАВЛЕНИЯ ОБъЕМОМ ТОРГОВ ПО СИСТЕМЕ МАРТИНГЕЙЛА
   static double balance_before, balance_after;    //ДЛЯ ХРАНЕНИЯ СОСТОЯНИЯ БАЛАНСА ДО И ПОСЛЕ СДЕЛОК
   static double save_Lot;   
   static int loop;
   if(loop == ArraySize(arrayLot))loop = 0;   
   balance_after = AccountBalance();               //СОХРАНЕНИЕ ТЕКУЩЕГО СОСТОЯНИЯ БАЛАНСА   
   if(balance_after >= balance_before){            //ПРОВЕРКА ИЗМЕНЕНИЯ БАЛАНСА
      save_Lot = lot;                              //ЕСЛИ ОН НЕ ИЗМЕНИЛСЯ ИЛИ СТАЛ БОЛЬШЕ, ТО СБРАСЫВАЕМ ЛОТ ДО БАЗОВОГО
      loop = 0;
   }else{
      save_Lot = arrayLot[loop];                   //ЕСЛИ СТАЛ МЕНЬШЕ ТО УВЕЛИЧИВАЕМ ЛОТ
      loop++;
   }
   balance_before = balance_after;                 //СОХРАНЯЕМ СОСТОЯНИЕ БАЛАНСА ПОСЛЕ РАБОТЫ
   return(save_Lot);
}
//+------------------------------------------------------------------+
 
artmedia70:
I've told you why it doesn't work properly - you put it in the wrong place... :) I think if you unscrew the wheels and put it in the boot, you won't get far, although it looks like the wheels are there and the doors close... :)


I absolutely agree with you. But I'm not criticizing your code, I just said that I had a problem with it), by the way, I have a problem with it again, if you don't mind - tell me what's wrong, I'd really like to understand what I'm doing wrong.

extern color colorOpenBuy = Blue;
extern colorCloseBuy = Aqua;
extern colorOpenSell = Red;
extern colorCloseSell = Aqua;


void deinit() {
Comment(");
}

double Lots_New = Lot;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+

int start(){
if (lFlagUseHourTrade){
if (!(Hour()>=nFromHourTrade && Hour()<=nToHourTrade)) {
Comment("Time for trade has not come yet!");
return(0);

I pasted it here, as you told, before function Start, but at compilation it says 'Lot' - initialization expected D:\MetaTrader\experts\Prostoj_2.mq4 (39, 20)

Please tell me what it may be.

 
artmedia70:
Check the opening of a new candle. If new, you open, if old, you don't...
what is the best way to do this?
 
cyclik33:


I absolutely agree with you. But I'm not criticizing your code, I'm just saying I have some problems with it. By the way, I have another problem with it, if you don't mind - tell me what's wrong, I'd really like to know what I'm doing wrong.

extern color colorOpenBuy = Blue;
extern color colorCloseBuy = Aqua;
extern colorOpenSell = Red;
extern color colorCloseSell = Aqua;


void deinit() {
Comment(");
}

double Lots_New = Lot;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+

int start(){
if (lFlagUseHourTrade){
if (!(Hour()>=nFromHourTrade && Hour()<=nToHourTrade)) {
Comment("Time for trade has not come yet!");
return(0);

I inserted it here, as you told, before the Start function, but when compiling it says 'Lot' - initialization expected D:\MetaTrader\experts\Prostoj_2.mq4 (39, 20)

Please tell me what it may be.

Where is Lot initialized in your code?

extern color colorOpenBuy = Blue;
extern color colorCloseBuy = Aqua;
extern color colorOpenSell = Red;
extern color colorCloseSell = Aqua;
extern double Lot = 0.1;
double Lots_New;

void deinit() {
Comment("");
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+

int start(){
if (lFlagUseHourTrade){
if (!(Hour()>=nFromHourTrade && Hour()<=nToHourTrade)) {
Comment("Time for trade has not come else!");
return(0);

Next, only after checking for moose, either change Lots_New as written before, or assign it value = Lot;

 

Yeah... I'm having a hard time with arrays... Trying to fill an array with inductor data, the little function is a boo-o-o-o-o-little stalemate... Can you tell me what I'm doing wrong?

double      TempIND[50]; 
void   SaveDataIND(double TempIND[], int nBars)
{
   ArrayResize(TempIND,nBars);
   for (int j=0; j<=nBars-1; j++)
      {
         TempIND[j]=iAD(NULL,PERIOD_M5,j);       // ЗДЕСЬ ОШИБКА array item cannot be assigned
         Print("TempIND[",j,"] = ",TempIND[j]);
      }

}

I call it like this:

SaveDataIND(TempIND, 20);
Where's the problem?
 
artmedia70:

Yeah... I'm having a hard time with arrays... Trying to fill an array with inductor data, the little function is a boo-o-o-o-o-little stalemate... Can you tell me what I'm doing wrong?

I call it like this:

Where the hell is the problem?



your dog in passing parameters to function, if you pass as SaveDataIND(double TempIND[])

double TempIND[ ] is in fact a new array for the function but without the right to change parameters, try SaveDataIND(double & TempIND[])

Reason: