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

 
Equilibrium:
Good day, please help me, I can not debug my Expert Advisor (opening and closing orders do not work by criterion as expected (by crossing stochastics every time), open at stochastics very rarely and I can not understand why ((((), here is a screenshot and the program:

No stochastic intersection found (I mean code)
 

Hi all.

Help me to get the code right.

 if(Bid > Line_2 && Rsi < 30)     //Если цена больше максимальной(верхней) линии..
                                  //..и RSI меньше заданного условия..
      {
       Opn_B= true;               //..тогда получаем условие на открытие  Buy
      }

When the first condition Bid > Line_2 is met, the second condition RSI<30 is lost, i.e. the RSI indicator line goes above value 30.

How to link two conditions correctly?

If someone has seen such an implementation, please give me a link.

 
Pacman:

Hi all.

Help me to get the code right.

When the first condition Bid > Line_2 is met, the second condition RSI<30 is lost, i.e. the RSI indicator line goes above value 30.

How to link two conditions correctly?

If someone has seen such an implementation, please give me a link.

The easiest and most effective way is to search in CodaBase for word "RSI" in already implemented EAs.
 
I want to repeat my question. I have an indicator (the upper indicator in the picture) that gives ONLY these signals.
I need to transform these signals into a "solid" signal (bottom indicator in the picture).
Help if you know how to do it!

P.S.

The MACD indicator in the picture is only used to illustrate my problem.



I got an answer from TaraasBY (for which thank you very much):

You fill the indicator buffer, in case there is no value in it, with the previous (not empty) value:

if (gda_BUF1[pos] == EMPTY_VALUE) 
    {
        if (gda_BUF1[pos+1] != EMPTY_VALUE) gda_BUF1[pos] = gda_BUF1[pos+1];
       
    }


But it doesn't work for me.How to link ExtMapBuffer1[i] and ExtMapBuffer1[pos]?

I want to repeat that indicator from MACD only for example! How to repeat above mentioned construction in it?

#property indicator_separate_window
#property indicator_minimum -1.5
#property indicator_maximum 1.5
#property indicator_buffers 1
#property indicator_color1 Aqua
#property  indicator_width1  2
#property indicator_level1 0.0
//--- buffers
double ExtMapBuffer1[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
     int counted_bars=IndicatorCounted(),
       limit;  
       
    if(counted_bars>0)
      counted_bars--;
   
      limit=Bars-counted_bars;
//----
   for(int i=0;i<limit;i++)
   
      if((iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i+2)<iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i+2))&&
         (iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i+1)>iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i+1)))
       {
        ExtMapBuffer1[i]=1;
       }
      else
       {
        
       
       
      if((iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i+2)>iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i+2))&&
         (iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i+1)<iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i+1)))
       {
        ExtMapBuffer1[i]=-1;
       }
      else
       {
        ExtMapBuffer1[i]=0;
       }
      }
      
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
MK07:

How do I connect ExtMapBuffer1[i] and ExtMapBuffer1[pos]?

Here is the code of the indicator. I want to repeat that the MACD indicator is just for example, how can I repeat the above-mentioned structure in it?

Like this (as applied to MACD):

int start()
  {
     int counted_bars=IndicatorCounted(),
       limit;  
     static int li_preSignal = 0;
    if(counted_bars>0)
      counted_bars--;
   
      limit=Bars-counted_bars;
//----
   for(int i=0;i<limit;i++)
   
      if((iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i+2)<iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i+2))&&
         (iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i+1)>iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i+1)))
       {
        ExtMapBuffer1[i]=1;
        li_preSignal = 1;
       }
      else
       {
        
       
       
      if((iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i+2)>iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i+2))&&
         (iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i+1)<iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i+1)))
       {
        ExtMapBuffer1[i]=-1;
        li_preSignal = -1;
       }
      else {ExtMapBuffer1[i] = li_preSignal;}
      }
      
 
//----
   return(0);
  }
 
TarasBY:
The easiest and most effective way is to search CodaBase for the word "RSI" in already implemented EAs.

Thanks, I'll keep looking.
 
TarasBY:

So (as applied to the MACD):

Thanks, it's working, but only one bar LATER! Is there anything else you can do?

 
TarasBY:

So (as applied to the MACD):

Your previous version with ExtMapBuffer1[pos] makes more sense to me and seems to be more universal.
 
MK07:

Thanks, it's working, but only one bar LATER! Is there anything else you can do?

Try this.

Files:
 

Vinin
:


No stochastic intersection found (I mean code)

// Обращение к функции техн.индикат.
   
   M_1=iStochastic(NULL,0,Kperiod,Dperiod,Slowing,MODE_SMMA,Price_field,MODE_MAIN,  1);
   M_2=iStochastic(NULL,0,Kperiod,Dperiod,Slowing,MODE_SMMA,Price_field,MODE_MAIN,  2);
   S_1=iStochastic(NULL,0,Kperiod,Dperiod,Slowing,MODE_SMMA,Price_field,MODE_SIGNAL,1);
   S_2=iStochastic(NULL,0,Kperiod,Dperiod,Slowing,MODE_SMMA,Price_field,MODE_SIGNAL,2);

                        // Анализ ситуации
   
   if (M_2 < S_2 && M_1==S_1)                    // Условие откр. Buy и закр. Sell 
     {
      if (Total>0)
        {
        Close_Order_S(Ticket,Ans,Lts); 
        }
      
        Ticket = Open_Order_B(StopLoss,Lts); 
                                                                         
     } 
   if (M_2 > S_2 && M_1==S_1)                    // Условие откр. Sell и закр. Buy        
     {  
      if (Total>0)
        {
        Close_Order_B(Ticket,Ans,Lts);   
        }                           
      
        Ticket = Open_Order_S(StopLoss,Lts);