Rsi ea with moving average instead of rsi line

 

Hi

I have tried to create need RSI  EA with an moving average applied to an RSI, (using simple moving average instead of rsi line)

Sells at a (MA)downward crossing of an oscillator overbought level, buys at an (MA)upward crossing of an oscillator oversold level

but the EA IS NOT WORKING 

 
Trading algorithms                           | 
//+----------------------------------------------+
#include <TradeAlgorithms.mqh>
//+----------------------------------------------+
//|  Enumeration for lot calculation options    |
//+----------------------------------------------+
/*enum MarginMode - the enumeration is declared in the TradeAlgorithms.mqh file
  {
   FREEMARGIN=0,     //MM from free funds on the account
   BALANCE,          //MM from the balance of funds on the account
   LOSSFREEMARGIN,   //MM for losses from free funds on the account
   LOSSBALANCE,      //MM for losses from the balance of funds on the account
   LOT               //Lot unchanged
  }; */
//+----------------------------------------------+
//|  Enumeration for defining a trend        |
//+----------------------------------------------+
enum TrendMode
  {
   DIRECT=0,         //by signals
   AGAINST           //against signals
  };
//+----------------------------------------------+
//| Expert indicator input parameters        |
//+----------------------------------------------+
input double MM=0.1;              //Money Managemnt
input MarginMode MMMode=LOT;      //Money Managent Mode
input int    StopLoss_=1000;      //stop loss in points
input int    TakeProfit_=2000;    //take profit in points
input int    Deviation_=10;       //Max. price deviation in points
input bool   BuyPosOpen=true;     //Permission to enter long
input bool   SellPosOpen=true;    //Permission to enter short
input bool   BuyPosClose=true;     //Permission to exit longs
input bool   SellPosClose=true;    //Permission to get out of shorts
//+----------------------------------------------+
//| Input parameters of the RSI indicator            |
//+----------------------------------------------+
input ENUM_TIMEFRAMES InpInd_Timeframe=PERIOD_M1; //indicator timeframe
input TrendMode            Trend=DIRECT;          //trade
//----
input uint                 RSIPeriod=10;          // indicator period
input ENUM_APPLIED_PRICE   RSIPrice=PRICE_CLOSE;  // price
input uint                 HighLevel=88;          // overbought level
input uint                 LowLevel=12;           // oversold level
//----
input uint                 SignalBar=1;           // bar number to receive the entry signal
//+----------------------------------------------+
//| Input parameters of the MA indicator            |
//+----------------------------------------------+
input int                  Inp_MA_ma_period     = 5;             // MA: averaging period 
input int                  Inp_MA_ma_shift      = 0;              // MA: horizontal shift 
input ENUM_MA_METHOD       Inp_MA_ma_method     = MODE_SMA;       // MA: smoothing type 
input ENUM_APPLIED_PRICE   Inp_MA_applied_price = PRICE_CLOSE;  // MA: type of price
//+----------------------------------------------+
//---- Declaring integer variables to store the chart period in seconds 
int TimeShiftSec;
//---- Declaring integer variables for indicator handles
//int InpInd_Handle;
int    handle_iRSI;                          // variable for storing the handle of the iRVI indicator
int    handle_iMA;                           // variable for storing the handle of the iMA indicator
//---- declaring integer data origin variables
int min_rates_total;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---- create handle of the indicator RSI
   handle_iRSI=iRSI(Symbol(),InpInd_Timeframe,RSIPeriod,RSIPrice);
   if(handle_iRSI==INVALID_HANDLE)
     {
      Print(" Failed to get the indicator handle RSI");
      return(INIT_FAILED);
     }
//--- create handle of the indicator iMA
handle_iMA=iMA(Symbol(),InpInd_Timeframe,Inp_MA_ma_period,Inp_MA_ma_shift,Inp_MA_ma_method,handle_iRSI);
   if(handle_iMA==INVALID_HANDLE)
     {
      Print(" Failed to get the indicator handle RSI");
      return(INIT_FAILED);
      }
//---- initialization of a variable to store the chart period in seconds  
   TimeShiftSec=PeriodSeconds(InpInd_Timeframe);

//---- Initializing data origin variables
   min_rates_total=int(Inp_MA_ma_period);
   min_rates_total+=int(3+SignalBar);
//--- completion of initialization
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//----
   GlobalVariableDel_(Symbol());
//----
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---- checking the number of bars for sufficiency for calculation
   if(BarsCalculated(handle_iRSI)<min_rates_total) return;

//---- loading history for normal operation of functions IsNewBar() и SeriesInfoInteger()  
   LoadHistory(TimeCurrent()-PeriodSeconds(InpInd_Timeframe)-1,Symbol(),InpInd_Timeframe);

//---- Declaring static variables
   static bool Recount=true;
   static bool BUY_Open=false,BUY_Close=false;
   static bool SELL_Open=false,SELL_Close=false;
   static datetime UpSignalTime,DnSignalTime;
   static CIsNewBar NB;

//+----------------------------------------------+
//| Definition of signals for deals              |
//+----------------------------------------------+
   if(!SignalBar || NB.IsNewBar(Symbol(),InpInd_Timeframe) || Recount) // checking for a new bar
     {
      //---- reset trading signals
      BUY_Open=false;
      SELL_Open=false;
      BUY_Close=false;
      SELL_Close=false;
      Recount=false;
      //---- Declaring local variables
      double MA[2];

      //---- copying the newly appeared data into arrays
      if(CopyBuffer(handle_iMA,0,SignalBar,2,MA)<=0) {Recount=true; return;}

      if(Trend==DIRECT)
        {
         //---- Get signals to buy
         if(MA[1]>LowLevel)
           {
            if(MA[0]<=LowLevel)
              {
               if(BuyPosOpen) BUY_Open=true;
               if(SellPosClose) SELL_Close=true;
              }

            UpSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
           }

         //---- Get signals for selling
         if(MA[1]<HighLevel)
           {
            if(MA[0]>=HighLevel)
              {
               if(SellPosOpen) SELL_Open=true;
               if(BuyPosClose) BUY_Close=true;
              }
            DnSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
           }
        }

      if(Trend==AGAINST)
        {
         //---- Get signals to buy
         if(MA[1]>LowLevel)
           {
            if(MA[0]<=LowLevel)
              {
               if(SellPosOpen) SELL_Open=true;
               if(BuyPosClose) BUY_Close=true;
              }
            DnSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
           }

         //---- Get signals for selling
         if(MA[1]<HighLevel)
           {
            if(MA[0]>=HighLevel)
              {
               if(BuyPosOpen) BUY_Open=true;
               if(SellPosClose) SELL_Close=true;
               UpSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
              }
           }
        }
      Print(BUY_Open,BUY_Close);
     }

//+----------------------------------------------+
//| Making deals                           |
//+----------------------------------------------+
//---- Close the long
   BuyPositionClose(BUY_Close,Symbol(),Deviation_);

//---- Close the short   
   SellPositionClose(SELL_Close,Symbol(),Deviation_);

//---- Opening long
   BuyPositionOpen(BUY_Open,Symbol(),UpSignalTime,MM,MMMode,Deviation_,StopLoss_,TakeProfit_);

//---- Opening the short
   SellPositionOpen(SELL_Open,Symbol(),DnSignalTime,MM,MMMode,Deviation_,StopLoss_,TakeProfit_);
//----
  }
//+------------------------------------------------------------------+
 

Unable to compile - huge bunch of bugs.

Correct the mistakes.

 
ok  how to retrieve data of SMA using the SMA on RSI handle hanndle
Vladimir Karputov:

Unable to compile - huge bunch of bugs.

Correct the mistakes.The platform features trading robots, copy trading and VPS Download

ok try this code below





//+----------------------------------------------+
//  Trading algorithms                           | 
//+----------------------------------------------+
#include <TradeAlgorithms.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>  
#include <Trade\AccountInfo.mqh>
#include <Trade\DealInfo.mqh>
#include <Trade\OrderInfo.mqh>
//#include <SmoothAlgorithms.mgh>
//+----------------------------------------------+
//|  Enumeration for lot calculation options    |
//+----------------------------------------------+
/*enum MarginMode - the enumeration is declared in the TradeAlgorithms.mqh file
  {
   FREEMARGIN=0,     //MM from free funds on the account
   BALANCE,          //MM from the balance of funds on the account
   LOSSFREEMARGIN,   //MM for losses from free funds on the account
   LOSSBALANCE,      //MM for losses from the balance of funds on the account
   LOT               //Lot unchanged
  }; */
//+----------------------------------------------+
//|  Enumeration for defining a trend        |
//+----------------------------------------------+
enum TrendMode
  {
   DIRECT=0,         //by signals
   AGAINST           //against signals
  };
//+----------------------------------------------+
//| Expert indicator input parameters        |
//+----------------------------------------------+
input double MM=0.1;              //Money Managemnt
input MarginMode MMMode=LOT;      //Money Managent Mode
input int    StopLoss_=1000;      //stop loss in points
input int    TakeProfit_=2000;    //take profit in points
input int    Deviation_=10;       //Max. price deviation in points
input bool   BuyPosOpen=true;     //Permission to enter long
input bool   SellPosOpen=true;    //Permission to enter short
input bool   BuyPosClose=true;     //Permission to exit longs
input bool   SellPosClose=true;    //Permission to get out of shorts
//+----------------------------------------------+
//| Input parameters of the RSI indicator            |
//+----------------------------------------------+
input ENUM_TIMEFRAMES InpInd_Timeframe=PERIOD_M1; //indicator timeframe
input TrendMode            Trend=DIRECT;          //trade
//----
input uint                 RSIPeriod=10;          //  RSI period
input ENUM_APPLIED_PRICE   RSIPrice=PRICE_CLOSE;  // price
input uint                 HighLevel=88;          // overbought level
input uint                 LowLevel=12;           // oversold level
//----
input uint                 SignalBar=1;           // bar number to receive the entry signal
//+----------------------------------------------+
//| Input parameters of the MA indicator            |
//+----------------------------------------------+
input int                  Inp_MA_ma_period     = 5;             // MA: averaging period 
input int                  Inp_MA_ma_shift      = 0;              // MA: horizontal shift 
input ENUM_MA_METHOD       Inp_MA_ma_method     = MODE_SMA;       // MA: smoothing type 
input ENUM_APPLIED_PRICE   Inp_MA_applied_price = PRICE_CLOSE;  // MA: type of price
//+----------------------------------------------+
//---- Declaring integer variables to store the chart period in seconds 
int TimeShiftSec;
//---- Declaring integer variables for indicator handles
//int InpInd_Handle;
int    handle_iRSI;                          // variable for storing the handle of the iRVI indicator
int    handle_iMA;                           // variable for storing the handle of the iMA indicator
//---- declaring integer data origin variables
int min_rates_total;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---- create handle of the indicator RSI
   handle_iRSI=iRSI(Symbol(),InpInd_Timeframe,RSIPeriod,RSIPrice);
   if(handle_iRSI==INVALID_HANDLE)
     {
      Print(" Failed to get the indicator handle RSI");
      return(INIT_FAILED);
     }
//--- create handle of the indicator iMA
handle_iMA=iMA(Symbol(),InpInd_Timeframe,Inp_MA_ma_period,Inp_MA_ma_shift,Inp_MA_ma_method,handle_iRSI);
   if(handle_iMA==INVALID_HANDLE)
     {
      Print(" Failed to get the indicator handle RSI");
      return(INIT_FAILED);
      }
//---- initialization of a variable to store the chart period in seconds  
   TimeShiftSec=PeriodSeconds(InpInd_Timeframe);

//---- Initializing data origin variables
   min_rates_total=int(Inp_MA_ma_period);
   min_rates_total+=int(3+SignalBar);
//--- completion of initialization
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//----
   GlobalVariableDel_(Symbol());
//----
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---- checking the number of bars for sufficiency for calculation
   if(BarsCalculated(handle_iMA)<min_rates_total) return;

//---- loading history for normal operation of functions IsNewBar() и SeriesInfoInteger()  
   LoadHistory(TimeCurrent()-PeriodSeconds(InpInd_Timeframe)-1,Symbol(),InpInd_Timeframe);

//---- Declaring static variables
   static bool Recount=true;
   static bool BUY_Open=false,BUY_Close=false;
   static bool SELL_Open=false,SELL_Close=false;
   static datetime UpSignalTime,DnSignalTime;
   static CIsNewBar NB;

//+----------------------------------------------+
//| Definition of signals for deals              |
//+----------------------------------------------+
   if(!SignalBar || NB.IsNewBar(Symbol(),InpInd_Timeframe) || Recount) // checking for a new bar
     {
      //---- reset trading signals
      BUY_Open=false;
      SELL_Open=false;
      BUY_Close=false;
      SELL_Close=false;
      Recount=false;
      //---- Declaring local variables
      double RSI[2];
      double MA[2];
      //---- copying the newly appeared data into arrays
      if(CopyBuffer(handle_iRSI,0,SignalBar,2,RSI)<=0) {Recount=true; return;}
      if(CopyBuffer(handle_iMA,0,SignalBar,2,MA)<=0) {Recount=true; return;}
      if(Trend==DIRECT)
        {
         //---- Get signals to buy
         if(MA[1]>LowLevel)
           {
            if(MA[0]<=LowLevel)
              {
               if(BuyPosOpen) BUY_Open=true;
               if(SellPosClose) SELL_Close=true;
              }

            UpSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
           }

         //---- Get signals for selling
         if(MA[1]<HighLevel)
           {
            if(MA[0]>=HighLevel)
              {
               if(SellPosOpen) SELL_Open=true;
               if(BuyPosClose) BUY_Close=true;
              }
            DnSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
           }
        }

      if(Trend==AGAINST)
        {
         //---- Get signals to buy
         if(MA[1]>LowLevel)
           {
            if(MA[0]<=LowLevel)
              {
               if(SellPosOpen) SELL_Open=true;
               if(BuyPosClose) BUY_Close=true;
              }
            DnSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
           }

         //---- Get signals for selling
         if(MA[1]<HighLevel)
           {
            if(MA[0]>=HighLevel)
              {
               if(BuyPosOpen) BUY_Open=true;
               if(SellPosClose) SELL_Close=true;
               UpSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
              }
           }
        }
      Print(BUY_Open,BUY_Close);
     }

//+----------------------------------------------+
//| Making deals                           |
//+----------------------------------------------+
//---- Close the long
   BuyPositionClose(BUY_Close,Symbol(),Deviation_);

//---- Close the short   
   SellPositionClose(SELL_Close,Symbol(),Deviation_);

//---- Opening long
   BuyPositionOpen(BUY_Open,Symbol(),UpSignalTime,MM,MMMode,Deviation_,StopLoss_,TakeProfit_);

//---- Opening the short
   SellPositionOpen(SELL_Open,Symbol(),DnSignalTime,MM,MMMode,Deviation_,StopLoss_,TakeProfit_);
//----
  }
//+------------------------------------------------------------------+
Files:
Untitled.png  10 kb
 
ENEZA PETER MKIRAMWENI :
ok  how to retrieve data of SMA using the SMA on RSI handle hanndle

ok try this code below

The code won't compile. The code contains a huge bunch of errors.

 
Vladimir Karputov:

The code won't compile. The code contains a huge bunch of errors.

Help me to correct it because i have compile with no error check the attached file below

Files:
aaaa.png  43 kb
 
ENEZA PETER MKIRAMWENI :

Help me to correct it because i have compile with no error check the attached file below

You have posted NOT ALL the code. Therefore, when trying to compile, a HUGE LOT of ERRORS occurs. Specifically: 48 errors and three warnings.

 
Vladimir Karputov:

You have posted NOT ALL the code. Therefore, when trying to compile, a HUGE LOT of ERRORS occurs. Specifically: 48 errors and three warnings.

Try this below but i there is logical not compiling error

//+------------------------------------------------------------------+
//|                                                         mimi.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+----------------------------------------------+
//  Trading algorithms                           | 
//+----------------------------------------------+
#include <TradeAlgorithms.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>  
#include <Trade\AccountInfo.mqh>
#include <Trade\DealInfo.mqh>
#include <Trade\OrderInfo.mqh>
//#include <SmoothAlgorithms.mgh>
//+----------------------------------------------+
//|  Enumeration for lot calculation options    |
//+----------------------------------------------+
/*enum MarginMode - the enumeration is declared in the TradeAlgorithms.mqh file
  {
   FREEMARGIN=0,     //MM from free funds on the account
   BALANCE,          //MM from the balance of funds on the account
   LOSSFREEMARGIN,   //MM for losses from free funds on the account
   LOSSBALANCE,      //MM for losses from the balance of funds on the account
   LOT               //Lot unchanged
  }; */
//+----------------------------------------------+
//|  Enumeration for defining a trend        |
//+----------------------------------------------+
enum TrendMode
  {
   DIRECT=0,         //by signals
   AGAINST           //against signals
  };
//+----------------------------------------------+
//| Expert indicator input parameters        |
//+----------------------------------------------+
input double MM=0.1;              //Money Managemnt
input MarginMode MMMode=LOT;      //Money Managent Mode
input int    StopLoss_=1000;      //stop loss in points
input int    TakeProfit_=2000;    //take profit in points
input int    Deviation_=10;       //Max. price deviation in points
input bool   BuyPosOpen=true;     //Permission to enter long
input bool   SellPosOpen=true;    //Permission to enter short
input bool   BuyPosClose=true;     //Permission to exit longs
input bool   SellPosClose=true;    //Permission to get out of shorts
//+----------------------------------------------+
//| Input parameters of the RSI indicator            |
//+----------------------------------------------+
input ENUM_TIMEFRAMES InpInd_Timeframe=PERIOD_M1; //indicator timeframe
input TrendMode            Trend=DIRECT;          //trade
//----
input uint                 RSIPeriod=10;          //  RSI period
input ENUM_APPLIED_PRICE   RSIPrice=PRICE_CLOSE;  // price
input uint                 HighLevel=88;          // overbought level
input uint                 LowLevel=12;           // oversold level
//----
input uint                 SignalBar=1;           // bar number to receive the entry signal
//+----------------------------------------------+
//| Input parameters of the MA indicator            |
//+----------------------------------------------+
input int                  Inp_MA_ma_period     = 5;             // MA: averaging period 
input int                  Inp_MA_ma_shift      = 0;              // MA: horizontal shift 
input ENUM_MA_METHOD       Inp_MA_ma_method     = MODE_SMA;       // MA: smoothing type 
input ENUM_APPLIED_PRICE   Inp_MA_applied_price = PRICE_CLOSE;  // MA: type of price
//+----------------------------------------------+
//---- Declaring integer variables to store the chart period in seconds 
int TimeShiftSec;
//---- Declaring integer variables for indicator handles
//int InpInd_Handle;
int    handle_iRSI;                          // variable for storing the handle of the iRVI indicator
int    handle_iMA;                           // variable for storing the handle of the iMA indicator
//---- declaring integer data origin variables
int min_rates_total;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---- create handle of the indicator RSI
   handle_iRSI=iRSI(Symbol(),InpInd_Timeframe,RSIPeriod,RSIPrice);
   if(handle_iRSI==INVALID_HANDLE)
     {
      Print(" Failed to get the indicator handle RSI");
      return(INIT_FAILED);
     }
//--- create handle of the indicator iMA
handle_iMA=iMA(Symbol(),InpInd_Timeframe,Inp_MA_ma_period,Inp_MA_ma_shift,Inp_MA_ma_method,handle_iRSI);
   if(handle_iMA==INVALID_HANDLE)
     {
      Print(" Failed to get the indicator handle RSI");
      return(INIT_FAILED);
      }
//---- initialization of a variable to store the chart period in seconds  
   TimeShiftSec=PeriodSeconds(InpInd_Timeframe);

//---- Initializing data origin variables
   min_rates_total=int(Inp_MA_ma_period);
   min_rates_total+=int(3+SignalBar);
//--- completion of initialization
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//----
   GlobalVariableDel_(Symbol());
//----
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---- checking the number of bars for sufficiency for calculation
   if(BarsCalculated(handle_iMA)<min_rates_total) return;

//---- loading history for normal operation of functions IsNewBar() и SeriesInfoInteger()  
   LoadHistory(TimeCurrent()-PeriodSeconds(InpInd_Timeframe)-1,Symbol(),InpInd_Timeframe);

//---- Declaring static variables
   static bool Recount=true;
   static bool BUY_Open=false,BUY_Close=false;
   static bool SELL_Open=false,SELL_Close=false;
   static datetime UpSignalTime,DnSignalTime;
   static CIsNewBar NB;

//+----------------------------------------------+
//| Definition of signals for deals              |
//+----------------------------------------------+
   if(!SignalBar || NB.IsNewBar(Symbol(),InpInd_Timeframe) || Recount) // checking for a new bar
     {
      //---- reset trading signals
      BUY_Open=false;
      SELL_Open=false;
      BUY_Close=false;
      SELL_Close=false;
      Recount=false;
      //---- Declaring local variables
      double RSI[2];
      double MA[2];
      //---- copying the newly appeared data into arrays
      if(CopyBuffer(handle_iRSI,0,SignalBar,2,RSI)<=0) {Recount=true; return;}
      if(CopyBuffer(handle_iMA,0,SignalBar,2,MA)<=0) {Recount=true; return;}
      if(Trend==DIRECT)
        {
         //---- Get signals to buy
         if(MA[1]>LowLevel)
           {
            if(MA[0]<=LowLevel)
              {
               if(BuyPosOpen) BUY_Open=true;
               if(SellPosClose) SELL_Close=true;
              }

            UpSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
           }

         //---- Get signals for selling
         if(MA[1]<HighLevel)
           {
            if(MA[0]>=HighLevel)
              {
               if(SellPosOpen) SELL_Open=true;
               if(BuyPosClose) BUY_Close=true;
              }
            DnSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
           }
        }

      if(Trend==AGAINST)
        {
         //---- Get signals to buy
         if(MA[1]>LowLevel)
           {
            if(MA[0]<=LowLevel)
              {
               if(SellPosOpen) SELL_Open=true;
               if(BuyPosClose) BUY_Close=true;
              }
            DnSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
           }

         //---- Get signals for selling
         if(MA[1]<HighLevel)
           {
            if(MA[0]>=HighLevel)
              {
               if(BuyPosOpen) BUY_Open=true;
               if(SellPosClose) SELL_Close=true;
               UpSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
              }
           }
        }
      Print(BUY_Open,BUY_Close);
     }

//+----------------------------------------------+
//| Making deals                           |
//+----------------------------------------------+
//---- Close the long
   BuyPositionClose(BUY_Close,Symbol(),Deviation_);

//---- Close the short   
   SellPositionClose(SELL_Close,Symbol(),Deviation_);

//---- Opening long
   BuyPositionOpen(BUY_Open,Symbol(),UpSignalTime,MM,MMMode,Deviation_,StopLoss_,TakeProfit_);

//---- Opening the short
   SellPositionOpen(SELL_Open,Symbol(),DnSignalTime,MM,MMMode,Deviation_,StopLoss_,TakeProfit_);
//----
  }
//+------------------------------------------------------------------+
 
Are you using MT5 editor because i run this code in mt5
 
ENEZA PETER MKIRAMWENI :

Try this below but i there is logical not compiling error

I'll just say - a huge bunch of mistakes. Correct your mistakes:

 
Vladimir Karputov:

You have posted NOT ALL the code. Therefore, when trying to compile, a HUGE LOT of ERRORS occurs. Specifically: 48 errors and three warnings.

Are you using MT5 editor? because i run this code in mt5  editor and there is 0 compile error