#include <stdlib.mqh>
//+------------------------------------------------------------------+
//|                                                Signals_Enter.mq4 |
//|                                                                  |
//|                                                                  |
//|                                        Converted by Mql2Mq4 v2.0 |
//|                                            http://yousky.free.fr |
//|                                  Copyright (c) 2006, Yousky Soft |
//+------------------------------------------------------------------+

#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_color1 Blue
#property indicator_buffers 1

//+------------------------------------------------------------------+
//| Common External variables                                        |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| External variables                                               |
//+------------------------------------------------------------------+
extern double HPeriod = 10;
extern double LPeriod = 40;

//+------------------------------------------------------------------+
//| Special Convertion Functions                                     |
//+------------------------------------------------------------------+

int LastTradeTime;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];

void SetLoopCount(int loops)
{
}

void SetIndexValue(int shift, double value)
{
  ExtHistoBuffer[shift] = value;
}

void SetIndexValue2(int shift, double value)
{
  ExtHistoBuffer2[shift] = value;
}

//+------------------------------------------------------------------+
//| End                                                              |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+

int init()
{
   SetIndexBuffer(0, ExtHistoBuffer);
   SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID);
   SetIndexBuffer(1, ExtHistoBuffer2);
   return(0);
}
int start()
{
//+------------------------------------------------------------------+
//| Local variables                                                  |
//+------------------------------------------------------------------+
int Shift = 0;
double Value = 0;
double Price = 0;

/*[[
        Name := Signals_Enter
        Separate Window  := No
        First Color      := Orange
        First Draw Type  := Symbol
        First Symbol     := 241
        Use Second Data  := Yes
        Second Color     := Red
        Second Draw Type := Symbol
        Second Symbol    := 242
]]*/







SetLoopCount(10);
for(Shift =0;Shift <=Bars - 1;Shift ++){
   Value = 0;
   Price = Low[Shift] - 15 * Point;
   if( iMA(NULL, 0, HPeriod, 0, 1, PRICE_CLOSE, Shift) < iMA(NULL, 0, LPeriod, 0, 1, PRICE_CLOSE, Shift) && iMA(NULL, 0, HPeriod, 0, 1, PRICE_CLOSE, Shift - 1) > iMA(NULL, 0, LPeriod, 0, 1, PRICE_CLOSE, Shift - 1) 
   	) Value = Price;
   SetIndexValue(Shift,Value);
   Value = 0;
   Price = High[Shift] + 15 * Point;
   if( iMA(NULL, 0, HPeriod, 0, 1, PRICE_CLOSE, Shift) > iMA(NULL, 0, LPeriod, 0, 1, PRICE_CLOSE, Shift) && iMA(NULL, 0, HPeriod, 0, 1, PRICE_CLOSE, Shift - 1) < iMA(NULL, 0, LPeriod, 0, 1, PRICE_CLOSE, Shift - 1) 
   	) Value = Price;
   SetIndexValue2(Shift,Value);
   }
  return(0);
}