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

 

Let me give you the gist of the idea.

You need to find or identify the first arrow in the history from the current bar.

It does not matter whether it is up or down.

(A) And then save this finding in a variable or a flag. For example GlobalFlag =-1 (if the arrow is down) and +1 if it is up.

Then the price went further forward and some arrow is drawn again.

In the EA, the search cycle is started every time with a new tick, right?

The loop was started again and it found the arrow that was just drawn and saved it in a variable or a flag, i.e.

i.e. item A was executed.

That's the idea.

Why bother with the flag and stuff?

Then this flag, i.e. where the arrow will be looking, will be used with another indicator to confirm the signal.

For example, GlobalFlag=+1 (arrow up) and another indicator is signaling upwards, it means that we should enter the market.

That is, both conditions should coincide in the indicators.


How do you like this code?

That is, I do not need to calculate on which candle is the arrow, what price is there, etc. The main thing is to fix the fact

The main thing is to fix the availability of the arrow and its direction.

Can I assign true and falce ???? instead of +1 and -1 or not?


double DataIndUP, DataIndDN;
int    i, GlobalFlag, nBars = 250 ;  // nBars = количество проверяемых баров вглубь истории

for (i=0; i<nBars; i++) 
{
   DataIndUP = iCustom(Symbol(),Period(),"Имя индюшонка", через запятую все параметры индюка , номер буфера стрелки вверх, i)
   DataIndDN = iCustom(Symbol(),Period(),"Имя индюшонка", через запятую все параметры индюка , номер буфера стрелки вниз, i)
   if (DataIndUP !=EMPTY_VALUE)     // или if (DataIndUP !=0) // найдена стрелка вверх
                                    // всё зависит от того, что выдаёт буфер при отсутствии стрелки 
                                    // нажмите Ctrl+D и посмотрите что вам в окне данных будет показано
      GlobalFlag=+1                 // присвоение значения +1(стрелка вверх)  переменной 
      Break;                        //выход из цикла, так как  нашлась последняя стрелка
if (DataIndDN !=EMPTY_VALUE)     // или if (DataIndDN !=0) // найдена стрелка вниз
                                    // всё зависит от того, что выдаёт буфер при отсутствии стрелки 
                                    // нажмите Ctrl+D и посмотрите что вам в окне данных будет показано
      GlobalFlag=-1                 // присвоение значения -1(стрелка вниз) переменной
      Break;                        //выход из цикла, так как  нашлась последняя стрелка
}
 
Tupen:


It's a start.


So, entry point A -- sell and buy stands at 4 pips. 1 variant of behaviour - the price goes down, - we fix profit in, say, 5 points from the entry point. - If the price goes up, the number of points before fixing profit will also change (a minimum for now). I.e. the program will have to place 4 orders at once, )) is it possible to programme this?
 
Roman.:



Post deleted for obscene profanity

 
Vinin:

Post deleted for obscene profanity


Sorry, generous, couldn't help myself. Fed up with the tales of the Vienna Woods...
 

Please write a program with 4 orders. i need to look at the demo and see the reversal

 
Tupen:

Please write a program with 4 orders. i need to look at the demo and see if i can figure out the pivot option.


See the "Avalanche" thread - everything has been thoroughly thought out there with "everything", including the reversal options.

There is no need to reinvent the wheel. Everything was invented by people long ago. Read, analyse, use and make use of it.

You won't get to the "it" bicycle (read: the solution) soon enough...

 

Can you tell me why there is no cyclicality? In the tester, the Expert Advisor opens only two trades.

extern int F = 8; //period of fast МА
extern int S = 20; //period of slow MA
extern double Lots = 0.1; // order lot
int Slippage = 5; // slippage in pips.
int Magic = 123; //magic number of the Expert Advisor
int ticketsell;
int ticketbuy;
int start()
{
double MAfast = iMA(NULL,0,F,0,MODE_SMA,PRICE_CLOSE,1);
double MAslow = iMA(NULL,0,S,0,MODE_SMA,PRICE_CLOSE,1);
// no order with ticketell in the terminal OR it is closed AND the fast MA is lower than the slow one, sell !
if ( (OrderSelect(ticketsell,SELECT_BY_TICKET,MODE_TRADES) == false ) && MAfast < MAslow )
{
// if we have already had an opposite order, buy, let's close it :
if ( OrderSelect(ticketbuy,SELECT_BY_TICKET,MODE_TRADES) == true )
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, CLR_NONE);
OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,Magic,0,Red)
}
if ( (OrderSelect(ticketbuy,SELECT_BY_TICKET,MODE_TRADES) == false ) && MAfast > MAslow )
{
if ( OrderSelect(ticketsell,SELECT_BY_TICKET,MODE_TRADES) == true )
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, CLR_NONE);
ticketbuy = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,Magic,0,Blue);
}
return(0);
}

 

Mirgha Try this

extern int F = 8; //период быстрой МА
extern int S = 20; //период медл.МА
extern double Lots = 0.1; // лот ордера
int Slippage = 5; // проскальзывание в пп.
int Magic = 123; // магический номер эксперта
int ticketsell;  
int ticketbuy;

int start()
{
   double MAfast = iMA(NULL,0,F,0,MODE_SMA,PRICE_CLOSE,1);
   double MAslow = iMA(NULL,0,S,0,MODE_SMA,PRICE_CLOSE,1); 
   
   ticketsell = -1;
   ticketbuy = -1;
   for (int i = 0; i < OrdersTotal(); i++)
   {
      OrderSelect( i, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
      {
         if (OrderType() == OP_SELL) ticketsell = OrderTicket();
         if (OrderType() == OP_BUY)  ticketbuy  = OrderTicket();
      }
    }
   // ордера с тикетом ticketsell в терминале нету ИЛИ он закрылся И быстрая МА ниже медленной, продаем !
   if ( (OrderSelect(ticketsell,SELECT_BY_TICKET,MODE_TRADES) == false ) && MAfast < MAslow )
   {
      // если у нас при этом был противоположный ордер, бай, его закроем :
      if ( OrderSelect(ticketbuy,SELECT_BY_TICKET,MODE_TRADES) == true )
         OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, CLR_NONE);
      ticketsell = OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,0,Magic,0,Red);
   } 
   if ( (OrderSelect(ticketbuy,SELECT_BY_TICKET,MODE_TRADES) == false ) && MAfast > MAslow )
   {
      if ( OrderSelect(ticketsell,SELECT_BY_TICKET,MODE_TRADES) == true )
         OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, CLR_NONE);
      ticketbuy = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,0,Magic,0,Blue);
   }
   return(0);
} 
 
Thank you!
 

My question remains unanswered.

Still, how can I filter the number of incoming signals from the indicator? For example, the Expert Advisor accepts signal number three to start working, i.e. the first two signals are skipped, and the third one is accepted for action. As I wrote above, I tried to implement it with global variables, but it does not work....

Reason: