What's wrong with my code. It compiles.

 

What the code is supposed to do is put an up arrow on the chart if the 9 sma is above the 20 sma and price closed below the 9 sma and then closed above the 9 sma.

EDIT by moderator: Code inserted from a later post and that post deleted.

//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. | 
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      " https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window 
#property indicator_buffers 5
#property indicator_plots   2
//--- plot Up
#property indicator_label1  "Up" 
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrBlue
#property indicator_style1  STYLE_SOLID 
#property indicator_width1  3
//--- plot Down
#property indicator_label2  "Down"
#property indicator_type2   DRAW_ARROW 
#property indicator_color2  clrMagenta
#property indicator_style2  STYLE_SOLID
#property indicator_width2  3 
//--- indicator buffers
double         UpBuffer[];
double         DownBuffer[];
double         SMANineBuffer[]; 
double         SMATwntyBuffer[];

input ENUM_MA_METHOD     MA_Method=MODE_SMA;
input ENUM_APPLIED_PRICE MA_Price=PRICE_CLOSE;

int            MA_handle;
int            MA_handle1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping 
   SetIndexBuffer(0,UpBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,DownBuffer,INDICATOR_DATA);
   
   SetIndexBuffer(2,SMANineBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,SMATwntyBuffer,INDICATOR_CALCULATIONS); 
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   PlotIndexSetInteger(0,PLOT_ARROW,233); 
   PlotIndexSetInteger(1,PLOT_ARROW,234);
   
   MA_handle=iMA(Symbol(),0,9,0,MODE_SMA,PRICE_CLOSE); 
   MA_handle1=iMA(Symbol(),0,20,0,MODE_SMA,PRICE_CLOSE);
   return(0);
   
//---
   return(INIT_SUCCEEDED); 
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated, 
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[], 
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---

CopyBuffer(MA_handle,0,0,rates_total,SMANineBuffer);
CopyBuffer(MA_handle1,0,0,rates_total,SMATwntyBuffer);

for(int i=0;i<rates_total;i++)
     {
      //--- If the current Close price is higher than the previous one, draw an arrow 
      
      if(SMANineBuffer[i] > SMATwntyBuffer[i] && close[i-1] < SMANineBuffer[i-1] && close[i] > SMANineBuffer[i]) 
         {UpBuffer[i]=low[i];}
      
      else if(SMANineBuffer[i] < SMATwntyBuffer[i] && close[i-1] > SMANineBuffer[i-1] && close[i] < SMANineBuffer[i]) 
         DownBuffer[i]=high[i];
         }
   
//--- return value of prev_calculated for next call 
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
tradingmarkets4pips:
What the code is supposed to do is put an up arrow on the chart if the 9 sma is above the 20 sma and price closed below the 9 sma and then closed above the 9 sma.

It's not coded to do what you want.

 
I think it's on line 23.
 
Marco vd Heijden:
I think it's on line 23.

Guys where do you see the code

This is what I see on this page (no code nor attachments)

 
Mladen Rakic:

Guys where do you see the code

This is what I see on this page (no code nor attachments)

I used my crystal ball.

 
Mladen Rakic:

Guys where do you see the code

This is what I see on this page (no code nor attachments)

 
Marco vd Heijden:

I used my crystal ball.

:)

Ahhh ... then it is line 23 by all means :)

 
Mladen Rakic:

Guys where do you see the code

This is what I see on this page (no code nor attachments)

Marco is using his crystal ball.

There is no code.

Does the OP really expect a serious reply?

 
3 replies while I was typing mine!
 
Keith Watford:
3 replies while I was typing mine!
That's a funny topic :-)
 
I have deleted the posts that actually contain the code and pasted it into the first post.
Reason: