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

 

Dear Professionals and knowledgeable!

I'm at a loss - the BB indicator is giving me incomprehensible signals (not "Red-Green-Red"!). To be more precise, I'm giving the following call:

bolup = iBands(Symbol(), 0, 24, 0, 2, 0, 1, 1);
boldn = iBands(Symbol(), 0, 24, 0, 2, 0, 2, 1);
bolmd = (bolup + boldn) / 2;
Print("Bands upper = ", bolup);
Print("Bands lower = ", boldn);
Print("Bands media = ", bolmd);

As a result, all 3 variables give the same value. >8-O

It is EUR, H1. Any ideas?

Thanks in advance...

 

Good evening. I have tried to show it in the picture for clarity. Suppose, there is a Dodge, when the price of the NEXT bar higher than the maximum "Dodge" - I buy, T / P suppose the 15 points I have taken, and the price on the same bar and still goes up and order (Buy_2) with T / P 15 points opens again, and I have this 2 nd opening (Buy_2) on the 1 st bar after the "Dodge" is not necessary. How to remove this misunderstanding?

 
iMAG:

Dear Professionals and knowledgeable!

I'm at a loss - the BB indicator is giving signals I don't understand (not "Red-Green-Red"!). To be more precise, I set such a call:

bolup = iBands(Symbol(), 0, 24, 0, 2, 0, 1, 1);
boln = iBands(Symbol(), 0, 24, 0, 2, 0, 2, 1);
bolmd = (bolup + boldn) / 2;
Print("Bands upper = ", bolup;)
Print("Bands lower = ", boldn);
Print("Bands media = ", bolmd);

The result is that all 3 variables give the same value. >8-O

Pair EUR, TF - H1. Any ideas???

Thanks in advance...

Would you also set the deviation to negative?
 
Fantar:

for clarity, I have tried to draw a picture of it at

Now try to do the same on mq4. Here is a branch for questions, if anything is unclear. There is the Work service for creating EAs from scratch
 
iMAG:

Dear Professionals and knowledgeable!

I'm at a loss - the BB indicator is giving me incomprehensible signals (not "Red-Green-Red"!). To be more precise, I'm giving the following call:

bolup = iBands(Symbol(), 0, 24, 0, 2, 0, 1, 1);
boldn = iBands(Symbol(), 0, 24, 0, 2, 0, 2, 1);
bolmd = (bolup + boldn) / 2;
Print("Bands upper = ", bolup);
Print("Bands lower = ", boldn);
Print("Bands media = ", bolmd);

As a result, all 3 variables give the same value. >8-O

It is EUR, H1. Any ideas?

Thanks in advance...

The deviation from the main line you set is 0 (zero). It should be more than zero.
 

The essence of the strategy: Entry by stochastic signal (5,14,3) exit also by stochastic but with another period (5,3,3). I don't understand how to make an exit by stochastic and not by reverse signal.
I have a problem and I have no idea how it can be solved, I will try to explain.
So, in the code I posted, there are 2 functions
//+------------------------------------------------------------------+
//| подготовить массив тикетов для закрытия |
//+------------------------------------------------------------------+
void PrepareTicketsToClose(int signal, bool Revers, int & ticketsClose[][2], double & lots[],double arrayTickets[][9])
{
int size=ArrayRange(arrayTickets,0);
//----
if (size==0) return;

int i,type,ticket,closeSize;
for (i=0;i<size;i++)
{
type=arrayTickets[i][1];
// если тип ордера не рыночный, то пропускаем
if (type>OP_SELL) continue;

if (Revers) // перевернем тип рыночного ордера
{
if (type==OP_BUY) type=OP_SELL; else type=OP_BUY;
}

// тут решаем для каждого открытого ордера его судьбу
// оставить в рынке или добавить в массив на закрытие
if (type==OP_BUY)
{
//
// код разрешающий оставить покупку

// как пример
if (signal==OP_BUY) continue;
}

if (type==OP_SELL)
{
//
// код разрешающий оставить продажу

// как пример
if (signal==OP_SELL) continue;
}

closeSize=ArrayRange(ticketsClose,0);
ArrayResize(ticketsClose,closeSize+1);
ArrayResize(lots,closeSize+1);
ticketsClose[closeSize][0] = arrayTickets[i][0]; // # тикета
ticketsClose[closeSize][1] = arrayTickets[i][1]; // тип ордера

// здесь укажем сколько лотов нужно закрыть
lots[closeSize] = arrayTickets[i][2]; // закрываемый объем
// можно закрывать частично, тогда нужно переписать строку сверху
}
//----
return;
}

//+------------------------------------------------------------------+
//| Закрывает ордера с указанными тикетами |
//+------------------------------------------------------------------+
void CloseMarketOrders(int ticketsArray[][2], double lotsArray[])
{
//----
int i,size=ArrayRange(ticketsArray,0);
if (size==0) return;

int ticket,type;
double lots;
bool res;

int total=OrdersTotal();

for (i=0;i<size;i++)
{
ticket = ticketsArray[i][0];
type = ticketsArray[i][1];
lots = lotsArray[i];
RefreshRates(); // на всякий случай обновим сведения о рыночном окружении

// блок закрытия покупок
if (type==OP_BUY)
{
res = OrderClose(ticket,lots,Bid,Slippage,Orange);
if (!res)
{
Print("Не удалось закрыть ордер в покупку #",ticket,"! Ошибка №",GetLastError());
// дальнейшая обработка ошибки, написать самостоятельно
}
}

// блок закрытия продаж
if (type==OP_SELL)
{
res = OrderClose(ticket,lots,Ask,Slippage,Orange);
if (!res)
{
Print("Не удалось закрыть ордер в продажу #",ticket,"! Ошибка №",GetLastError());
// дальнейшая обработка ошибки, написать самостоятельно
}
}

}
//----
return;
}
In void PrepareTicketsToClose(int signal, bool Revers, int & ticketsClose[][2], double & lots[],double arrayTickets[][9]) we have to put a condition that will decide if we should leave or close the order...
I tried to put conditions but nothing works....
Can someone look and show if there is an error in these functions or i messed up....
Files:
 
Can you tell me if I have two consecutive OrderSend commands setting orders, do I need to place the IsTradeAllowed function between them?

or is it not necessary and the EA will pass from the first OrderSend call to the second one only after a successfully placed order?

If IsTradeAllowed is still required, what time delay should be set in the while loop?
 
Desead:
Can you tell me if I have two consecutive OrderSend commands for setting orders, do I need to place the IsTradeAllowed function between them?

or is it not necessary and the EA will pass from the first OrderSend call to the second one only after a successfully placed order?

In the tester no need, but on the demo or real account you will get a message about a busy trade thread.

Desead:


If IsTradeAllowed is still needed, what time delay should be set in the while loop ?
Depends on execution speed, which is different for different servers. Remember to also add a loop check on IsStopped(), otherwise you won't have any luck.
 
Hello, could you please tell me where I can download the archive of detailed quotes (tick or minute)? The data that is in the archive of quotes in MT4 (not much) minute data only for 5 days of the test.
 

Good afternoon. The system provides three entry points for BUY and SELL. But when a signal comes in, positions are opened on every tick as long as the signal exists. There is an error somewhere with flags. Please help me to understand it.

   static bool buy_h=true, buy_l=true, buy_50=true,
               sell_h=true, sell_l=true, sell_50=true;

 if(LSMA_Sig==0) // up-trend
    {
      if(Stoch_Sig==4 && buy_l==true)
       { 
         sl=Ask-Stop_Loss*Point;
         Ans=OrderSend(Symb,OP_BUY,Lots,Ask,40,sl,0,"LSMA+Stoch",Magic);
         if(Ans==false)
           Alert("Неудачная попытка открыть ордер BUY. Ошибка: ", GetLastError());
         if(Ans==true)
            buy_l=false; // снимем флаг
       }
      //---
      if(Stoch_Sig==0 && buy_50==true)
       {
         sl=Ask-Stop_Loss*Point;
         Ans=OrderSend(Symb,OP_BUY,Lots,Ask,40,sl,0,"LSMA+Stoch",Magic);
         if(Ans==false)
           Alert("Неудачная попытка открыть ордер BUY. Ошибка: ", GetLastError());
         if(Ans==true)
            buy_50=false;        
       }
      //---
      if(Stoch_Sig==2 && buy_h==true)
       {
         sl=Ask-Stop_Loss*Point;       
         Ans=OrderSend(Symb,OP_BUY,Lots,Ask,40,sl,0,"LSMA+Stoch",Magic);
         if(Ans==false)
           Alert("Неудачная попытка открыть ордер BUY. Ошибка: ", GetLastError());
         if(Ans==true)
            buy_h=false;         
       }   
    }
   if(LSMA_Sig==1) // dn-trend
    {
      if(Stoch_Sig==3 && sell_h==true)
       {
         sl=Bid+Stop_Loss*Point;
         Ans=OrderSend(Symb,OP_SELL,Lots,Bid,40,sl,0,"LSMA+Stoch",Magic);
         if(Ans==false)
            Alert("Неудачная попытка открыть ордер SELL. Ошибка: ", GetLastError());
         if(Ans==true)
            sell_h=false;
       }
     //---
     if(Stoch_Sig==1 && sell_50==true)
      {
         sl=Bid+Stop_Loss*Point;      
         Ans=OrderSend(Symb,OP_SELL,Lots,Bid,40,sl,0,"LSMA+Stoch",Magic);
         if(Ans==false)
            Alert("Неудачная попытка открыть ордер SELL. Ошибка: ", GetLastError());
         if(Ans==true)
            sell_50=false;         
      }
     //---
     if(Stoch_Sig==5 && sell_l==true)
      {
         sl=Bid+Stop_Loss*Point;      
         Ans=OrderSend(Symb,OP_SELL,Lots,Bid,40,sl,0,"LSMA+Stoch",Magic);
         if(Ans==false)
            Alert("Неудачная попытка открыть ордер SELL. Ошибка: ", GetLastError());
         if(Ans==true)
            sell_l=false;        
      }
    }
    
   if(Stoch_Sig!=4 && buy_l==false) // поднимем флаг
       buy_l=true;
   if(Stoch_Sig!=0 && buy_50==false)
       buy_50=true;
   if(Stoch_Sig!=2 && buy_h==false)
       buy_h=true;
   if(Stoch_Sig!=3 && sell_h==false)
       sell_h=true;
   if(Stoch_Sig!=1 && sell_50==false)
       sell_50=true;
   if(Stoch_Sig!=5 && sell_l==false)
       sell_l=true;  
Reason: