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

 
Hello!
//+------------------------------------------------------------------+
//|                                               Indicator_MACD.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
// Modify Vinin
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int       Fast_EMA=13;
extern int       Slow_EMA=21;
extern double    N = 0.001221;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double MACD[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(3);
   SetIndexStyle(0,DRAW_ARROW, EMPTY, 3);
   SetIndexArrow(0,233);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW, EMPTY, 3);
   SetIndexArrow(1,234);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   SetIndexBuffer(2,MACD);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit = Bars-counted_bars-1;
   
   for(int i = limit; i>= 0; i--) {
      ExtMapBuffer2[i] = EMPTY;
      ExtMapBuffer1[i] = EMPTY;
      MACD[i]=iMACD(NULL,0,Fast_EMA,Slow_EMA,1,1,MODE_MAIN, i);
      if (((MACD[i]-N)*(MACD[i+1]-N)<0) || ((MACD[i]+N)*(MACD[i+1]+N)<0))
      {
       if( MACD[i] <-N) ExtMapBuffer2[i] = High[i]+iATR(Symbol(), 0, 14, i);
       if( MACD[i] > N) ExtMapBuffer1[i] = Low[i] -iATR(Symbol(), 0, 14, i); 
      }
   }
   return(0);
}
//+------------------------------------------------------------------+
Here is the code of the indicator (tweaked and changed with VIN - thanks a lot).
All good, seems to make sense....... Wanted to change it a bit. HOWEVER. The idea is MACD at the bottom begins to grow (ALL its values are less than the value N) here and set the arrow BAY,
for SHEL vice versa. I tried to change trade conditions (changed values < to > did not work). If MACD starts to grow (it is negative), the moment of arrow's appearance coincides with a trading condition. Seems right...... BUT the arrows have appeared too much...........
Please tell me!!!!!!!!!!!!!!
 
Swetten >>:
Есть МАКД с параметрами 9 и 12.

Верно ли, что он показывает разницу между МА с периодами 9 и 12? А то у меня какой-то разбег в цифрах.

Check compliance of ma_method, applied_price in MA and MAKD.

 
Please advise!
All MACD values are contained in a one-dimensional array MACD[], I want to check them in batches (every 10 elements) for maxima and minima, and draw them in the indicator.
Here is the code:
for(i=0; i<limit; i=i+10)
       {
         int k = i;
         for(k=i; k<i+10; k++)
             {       
              x10[k] = MACD[k];  
             }
         int maxValueIdx=ArrayMaximum(x10);
         int minValueIdx=ArrayMinimum(x10);    
         MAX[k] = maxValueIdx;
         MIN[k] = minValueIdx;
       }
Why isn't it drawn?
 
Noterday писал(а) >>
Please advise!
All MACD values are contained in a one-dimensional array MACD[], I want to check them in batches (every 10 elements) for highs and lows, and draw them in the indicator.
Here is the code:
Why isn't it drawn?


What is the dimension of x10 array ?

10?
Then you should rewrite it like this:

for(i=0; i<limit; i+=10)
       {
         int k;
         for(k=0; k<10; k++)
             {       
              x10[k] = MACD[i+k];  
             }
         int maxValueIdx=ArrayMaximum(x10);
         int minValueIdx=ArrayMinimum(x10);    
         MAX[i] = maxValueIdx;
         MIN[i] = minValueIdx;
       }
and it is not clear what exactly you want in the MAX and MIN arrays
 
The situation is as follows, I open an order with orderSend, 1 lot, I close it with orderClose, 0.5 lot.... How do I get a new order with another ticker to pick up the newly opened order?
 
Xors писал(а) >>
The situation is as follows, I open an order with orderSend, 1 lot, I close it with orderClose, 0.5 lot.... it closes half of it and opens a new order with another ticket, how do I quickly pick up the ticket of the newly opened order?


no way.
The only way is to brute-force among open and pending orders.

 
baltik писал(а) >>

lots=UseLots();
if (lots==0) return(0);
i=OrderSend(Symbol(),OP_BUY,UseLots(),NormalizeDouble(Ask, Digits),slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,EA,magic,0,Blue);

lots=UseLots();
if (lots==0) return(0);
i=OrderSend(Symbol(),OP_SELL,UseLots(),NormalizeDouble(Bid, Digits),slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,EA,magic,0,Red);

Error 4107 on 1 of 10 orders or on 3 of 25 differently in the tester


And what is the slippage value reported and what is the quote 5 or 4 decimal places.
 
granit77 >>:

Проверьте соответствие ma_method, applied_price в МА и МАКД.

Already. It was 120 instead of 12 for MA. I was amazed! :)

 
How do I know the currency of my order?(For futures)
 
Noterday писал(а) >>
Please advise!
All MACD values are contained in a one-dimensional array MACD[], I want to check them in batches (every 10 elements) for highs and lows, and draw them in the indicator.
Here is the code:
Why isn't it drawn?
ArrayResize(MAX,Bars);
ArrayResize(MIN,Bars);
int k=1;
for(i=0; i<limit; i++)
       {
        MACD[i]= trali vali;
         if(i==10*k){k++;
          for(int r=0; r<10; r++)
          MAX[r]=MACD[ArrayMaximum(MACD,10,i-10)];
         
          for(int r=0; r<10; r++)
          MIN[r]=MACD[ArrayMinimum(MACD,10,i-10)];
         }
       }
But I need to snap to a reference point!