Daily counter trend expert advisor

 

Hi Guys? Please tell me how I can fix these 4 errors:

12 &13:  Can't open ''C:\Users\hp\AppDataRoaming\MetaQuotes\Terminal\DOE8209F77C8CF37AD8BF550E51FF075\MQ...

72.'if'-Open parentheses expected

242.'}'-Not all control paths return a value


/+------------------------------------------------------------------+

//|                                          Daily Counter Trend.mq5 |

//|                                  Copyright 2022, MetaQuotes Ltd. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2022, MetaQuotes Ltd."

#property link      "https://www.mql5.com"

#property version   "1.00"



//Importing function libraries

#include<Trade\Trade.mqh>

#include<Risk_Management.mqh>

#include<Trade_Manager.mqh>



//Input parameter for EA

input int StopLoss=45; //Stop Loss in Pips

input int TakeProfit=146; //Take Profit in Pips

input int EA_Magic=1234;// Magic Number

input double LotSize=0.05; //Lot Size

input int Slippage=50; //Slippage in Points

input string Comments="DCT";//Trade Comments



//BreakEven input variables

input bool UseBreakEven=true; //Use Break Even

input int WhenToBreak=95; //When to break even in pips?

input int BreakBy=25;//Break Even by how many pips?



//Trailing Stop input variables

input bool UseTrailing=true; //Use Trailing Stop

input int WhenToTrail=100;// When to start Trailing in pips?

input int TrailBy=75; //Trailing Stop in Pips



//Money Management input variables

input bool Used_Money_Management;

input double ENUM_FUNDS_TYPE();//Funds to Use for Lot Calculation

input double ENUM_MM_MM_TYPE();//Type of Money Management

input double ATR_Multiplier=1; //ATR Multiplier

input double Fixed_Balance=1000;//Fixed Balance in account currency

input double Fixed_RiskMoney=20; //Fixed Risk Money

input double Percentage_risk=5; //Percentage of Funds to Risk



//EA variables

double STP,TKP;

ulong LastBars=0;

double Ask,Bid;

int Num_Days=30;

double Day_highs[];

double Day_lows[];

double H1ClosePrice[];





//Creating Some Objects

CTrade *Trade;

//+-----------------------------------------------------------------+

//| Expert initialization function

int OnInit()

  {

//Initializing the Trade Object

   Trade=new CTrade;

   Trade.SetExpertMagicNumber(EA_Magic);

   Trade.SetDeviationInPoints(Slippage);

   STP=StopLoss*_Point*10;

   TKP=TakeProfit*_Point*10;





//Check if we have enough bars on our chart

   if(Bars(_Symbol,PERIOD_CURRENT)<500)

     {

      Alert("Not enough bars on the Chart");

      return(INIT_FAILED);

     }

   if  else

     {

      return(INIT_SUCCEEDED);

         return(0);

   }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

   void OnDeinit(const int reason)

     {





      // Delete the trade object

      delete Trade;

     }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

   void OnTick()

     {

      //---Check if we are able to trade

      if((!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)||!TerminalInfoInteger(TERMINAL_CONNECTED))

        {

         return;

        }

       }

      //Check if we have a new bar

      ulong bars=Bars(_Symbol,PERIOD_CURRENT);

      if(LastBars!=bars)

        {

         LastBars=bars;

        }

      else

        {

         return;

        }



      //Obtaining Ask price and Bid Price

      Ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);

      Bid=SymbolInfoDouble(_Symbol; SYMBOL_BID);

      //Declare MQL Rates Objects

      MqlRates Dailyrates[];

      MqlRates Hourlyrates[];



      //...Reverse the Ordering of data within our Arrays

      ArraySetAsSeries(Dailyrates,true);

      ArraySetAsSeries(Hourlyrates,true);

      ArraySetAsSeries(Day_highs,true);

      ArraySetAsSeries(Day_lows,true);

      ArraySetAsSeries(H1ClosePrice,true);



      //----Resize our Dynamic arrays

      ArrayResize(Day_highs,Num_Days);

      ArrayResize(Day_lows,Num_Days);

      ArrayResize(H1ClosePrice,Num_Days);



      //Copy price data from the terminal

      if(CopyRates((_Symbol,PERIOD_D1,0,Num_Days,Dailyrates[])!=Num_Days||CopyRates(_Symbol,PERIOD_H1,0,Num_Days,Hourlyrates[])!=Num_Days||CopyRates(_Symbol,PERIOD_H1,0,3,Hourlyrates[])!=3))

        {

         Alert("Error copying price data",GetLastError());

        }



      //Copying Price data from objects into arrays

      for(int i=0; i<Num_Days; i++)

        {

         Day_high[i]=Dailyrates[i].high;

         Day_Lows[i]=Dailyrates[i].low;

        }



      for(int i=0; i<3; i++)

        {



         H1ClosePrice[i]=Hourlyrates[i].close;

        }



      //Declaring switches for market entry signals

      bool BuyCondition=false;

      bool SellCondition=false;

      bool BullTrend=false;

      bool BearTrend=false;

      bool TradeOpen=false;



      //Checking if we have an open position in the market

      if(PositionsTotal()>0)

        {

         TradeOpen=true;

        }

      if(UseBreakEven)

        {

         BreakEven(EA_Magic,_Symbol,WhenToBreak,BreakBy);

        }

      if(UseTrailing)

        {

         TrailingStopLoss(EA_Magic,_Symbol,WhenToTrail,TrailBy);

        }



      //Check if we have a Bull Trend

      if((Day_lows[1]>Day_lows[2])&&(Day_lows[2]>Day_lows[3]))

        {

         BullTrend=true;

        }

      //Check if we have a Bear Trend

      if((Day_high[1]<Day_high[2])&&(Day_high[2]<Day_high[3]))

        {

         Bear=true;

        }



      //Buy order conditions

      if((H1ClosePrice[1]<Day_lows[1])&&(H1ClosePrice[2]>Day_lows[1]))

        {

         BuyCondition=true;

        }



      //Sell order conditions

      if((H1ClosePrice[1]>Day_high[1])&&(H1ClosePrice[2]<Day_high[1]))

        {

         SellCondition=true;

        }



      //Obtaining  the value of our lotsize

      double UsedLots;



      if(UseMoneyManagement)

     {

      UsedLots=MoneyManagement(Funds_ToUse,MM_Type,STP,ATR_Multiplier,Fixed_Balance,Fixed_RiskMoney,Percentage_risk);

        }

      else

        {

         UsedLots=LotSize;

        }



      //Executing a Buy Trade

      if(!TradeOpen)

     {

      if(BullTrend)

           {

            if(BuyCondition)

              {

               fBuy(UsedLots);

              }

           }

        }



      //Executing a Sell Trade

      if(!TradeOpen)

      {

      if(BearTrend)

        {

         if(SellCondition)

           {

            fSell(UsedLots);

              }

     }

   }



//Buy Function

void fBuy(double lot)

  {

   Trade.Buy(lot,_Symbol,Ask,Ask-STP,Ask+TKP,Comments);

   return;

    }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

void fSell(double lot)

  {

   Trade.Sell(lot,_Symbol,Bid,Bid+STP,Bid-TKP,Comments);

   return;

   ();

 }

 }











//+------------------------------------------------------------------+



//+------------------------------------------------------------------+



Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2022.12.27
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

Please edit your post (don't create a new one) and post your code properly ... (or simply "+Attach" the file instead).

 
0796214726: Hi Guys? Please tell me how I can fix these 4 errors:

12 &13:  Can't open ''C:\Users\hp\AppDataRoaming\MetaQuotes\Terminal\DOE8209F77C8CF37AD8BF550E51FF075\MQ...
72.'if'-Open parentheses expected
242.'}'-Not all control paths return a value

These are not part of MQL5's Standard Library. If you did not code them yourself, then did you get from some other library are you just assuming that they exist by default?

#include <Risk_Management.mqh>
#include <Trade_Manager.mqh>

As for the rest, there are several unbalanced braces "{ ... }" which you will have to correct.

And while you are at it, remove all the extra blank lines which is just making the whole thing difficult to read.

Use the built-in code styler in MetaEditor to tidy up your code and spot where the unbalanced braces are.

However, judging from your other posts, I have a feeling that this is not your code and you are just copy/pasting it from somewhere and don't have an ideia of how to apply it properly.