Off-topic posts - page 95

 

Hi guys , I just built my first EA using the trade class. The code compiles without errors but during the strategy testing in the strategy tester , the EA does not open any trades. In the journal tab , there are no error messages . Please help . Below is my code : 

-------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2020, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, DAVID BUTA"

#include  <Trade/Trade.mqh>
CTrade trade;
input ENUM_TIMEFRAMES tf = PERIOD_CURRENT;
input int periods = 20;
input double dev = 2.0;
input string expire = "03:00";
input ENUM_APPLIED_PRICE pr = PRICE_CLOSE;
int handlebb;
/// add values here
int OnInit()
  {
   handlebb = iBands(_Symbol,tf,periods,0,dev,pr);

   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {


  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   double upper[],lower[],middle[];
   CopyBuffer(handlebb,BASE_LINE,1,2,middle);
   CopyBuffer(handlebb,UPPER_BAND,1,2,upper);
   CopyBuffer(handlebb,LOWER_BAND,1,2,lower);
   double bbupper = upper[1];
   double bblower = lower[1];
   double bbmiddle =  middle[1];
   double low1 = iLow(_Symbol,tf,1);
   double low2 = iLow(_Symbol,tf,2);
   double high1 = iHigh(_Symbol,tf,1);
   double high2 = iHigh(_Symbol,tf,2);
   double close1 = iClose(_Symbol,tf,1);
   double open1 = iOpen(_Symbol,tf,1);

   double low_index = iLowest(_Symbol,tf,MODE_LOW,10,1);
   double high_index = iHighest(_Symbol,tf,MODE_HIGH,10,1);
   double range = high1 - low1;
   double kt = high1 - (0.3 * range);
   double kt1 = low1 + (0.3 * range);
   
   double range_value = range  / 2;
   datetime exp = StringToTime(expire);
   
   
   if(close1 > open1 || close1 < open1) // bullish or bearish
     {
      double body = close1 > open1 ? close1 - open1 : open1 - close1; // bullish ? then body is that value

      if(low1 < low2 && high1 > high2) // engulfs
        {
         if(body > range_value) // not a weakie
           {
            if(low_index == 1  && at_zone(high1,low1)) // highest low value of the previous 10 candles, starting from 
           { // position 1
            if(at_bands(high1,low1,bbupper,bblower) == "buy") // bands function signals a buy
                 { double tp = high1 + range *1.5;
                 tp = NormalizeDouble(tp,3);
                  trade.BuyStop(1.0,high1,_Symbol,low1,tp,ORDER_TIME_GTC,exp,"me");
                 }
              }
            else
               if(high_index == 1 && at_zone(high1,low1))
              {
               if(at_bands(high1,low1,bbupper,bblower) =="sell")
                    {  double tp1 = low1 - range * 1.5;
                     tp1 = NormalizeDouble(tp1,3);
                     trade.SellStop(1.0,high1,_Symbol,low1,tp1,ORDER_TIME_GTC,exp,"me");
                    }
                 }
           }
        }
     }





   else
      if((close1 >= kt && open1 >= kt) ||(close1 <= kt1 && open1 <= kt1))  // bullish or bearish kt
     {
      if(low_index == 1  && at_zone(high1,low1))
           {
            if(at_bands(high1,low1,bbupper,bblower) == "buy")
              {
               trade.BuyStop(1.0,high1,_Symbol,low1,high1 + range * 1.2,ORDER_TIME_GTC,exp,"me");

              }
           }
         else if(high_index == 1 && at_zone(high1,low1))
        {
         if(at_bands(high1,low1,bbupper,bblower) == "sell")
              {
               trade.SellStop(1.0,high1,_Symbol,low1,low1 - range * 1.2,ORDER_TIME_GTC,exp,"me");
              }

           }
        }
}
//+------------------------------------------------------------------+

   bool at_zone(double high,double low)// this function proves whether the setup is on a support and resistance zone or not
     {
      int v = 0;
      double zones [] = {102.839,134.560,126.212,119.395,122.873,110.074,105.622,108.462,107.042,115.933,111.364,
      112.043,124.640,121.182,117.662,132.729,123.775,128.715,114.053,104.511,109.226,116.932,120.298,118.628,
      127.912,131.377};
      for(int i=0; i< ArraySize(zones); i++)
        {
         if(high > zones[i] && low < zones[i])   // INCLUDE THE PIPS FOR SLIPPAGE, as well as the indication values
           {
            v +=1;
           }
        }
      if(v == 1)
        {
         return true;
        }
      else
         return false;
     }
   string at_bands(double high, double low,double ub,double lb) // this function proves that the setup is either in
     { // one of the upper and lower bands or above or below them
      if((high >= lb && low <= lb) || high < lb)
        {
         return "buy";
        }
      else
         if((high >= ub && low <= ub) || low > ub)
           {
            return "sell";
           }
           else return "false";
     }
     
    
  
 

I've been trying to purchase a utility program with no success. I can't even get a reasonable response, or email with an explanation as to why I can't make a purchase. Who is the seller here? m I dealing with MQL or the owner of the program? If I have a valid credit card and bank account why can't I do business with the owner and not the robot of MQL. My ticket was closed with no action taken or action taken to resolve an issue unknown to me. As you may have guessed, I'm very frustrated dealing with a site that has no humans on duty during my working hours.

Support Team  2023.05.07 00:19  EN
Status: Open  Closed
We are closing this ticket due to inactivity. If the problem still exists, please open a new ticket. Did you fix the problem???
 
5012815896 #:
Idont have a broker idownload metatrader5

Windows: https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe?utm_source=www.mql5.com&utm_campaign=download

Like the one for Linux, Mac, .. at the bottom of the page.

 
Joao David Ngululia Buta #:

Hi guys , I just built my first EA using the trade class. The code compiles without errors but during the strategy testing in the strategy tester , the EA does not open any trades. In the journal tab , there are no error messages . Please help . Below is my code : 

If your program compiles without error but doesn't do what it should use the debugger:

Code debugging:  https://www.metatrader5.com/en/metaeditor/help/development/debug
Error Handling and Logging in MQL5:  https://www.mql5.com/en/articles/2041
Tracing, Debugging and Structural Analysis of Source Code, scroll down to: "Launching and Debuggin": https://www.mql5.com/en/articles/272

Code debugging - Developing programs - MetaEditor Help
  • www.metatrader5.com
MetaEditor has a built-in debugger allowing you to check a program execution step by step (by individual functions). Place breakpoints in the code...
 
mercano9 #:

I've been trying to purchase a utility program with no success. I can't even get a reasonable response, or email with an explanation as to why I can't make a purchase. Who is the seller here? m I dealing with MQL or the owner of the program? If I have a valid credit card and bank account why can't I do business with the owner and not the robot of MQL. My ticket was closed with no action taken or action taken to resolve an issue unknown to me. As you may have guessed, I'm very frustrated dealing with a site that has no humans on duty during my working hours.

This might help:

https://www.mql5.com/en/articles/498
https://www.mql5.com/en/articles/1776

How to purchase a trading robot from the MetaTrader Market and to install it?
How to purchase a trading robot from the MetaTrader Market and to install it?
  • www.mql5.com
A product from the MetaTrader Market can be purchased on the MQL5.com website or straight from the MetaTrader 4 and MetaTrader 5 trading platforms. Choose a desired product that suits your trading style, pay for it using your preferred payment method, and activate the product.
 
Javier Santiago Gaston De Iriarte Cabrera: no errors, but no trades are done while testing ... why?
Please can some one help me I created an EA but it's not uploading on the chart and not opening trade during testing. I compiled it and no error on it.
 
@Michael Dede #: Please can some one help me I created an EA but it's not uploading on the chart and not opening trade during testing. I compiled it and no error on it.

If you need help with your code, then you will need to show your code.

Remember to also check your "Experts" log and "Journal" log for any related messages.

Also, please don't hijack other users threads for your unrelated issue.

 
rrocchi #:

Faster is to use _Symbol because it is a definition.


Symbol() is a function, so it has to be executed to retrieve the symbol name every time it is called. 


Your code is returning error because your Func() definition expects a CONST string. So it only accepts Static parameters. And you cannot pass a function return to it.

Either modify it removing CONST so you can pass Symbol() to it as a parameter. Or use _Symbol which is faster and ALSO IS a Static Variable ;)

Hi, I have a problem when try to check order at market. I'd like put two parameters into the function as magic and symbol but symbol optional.

If I write "findPos("right magic") doesn't work because it wants the second parameter _Symbol compulsorily...

bool findPos(int_mNumber, string _symbol = NULL)
  {
   for(int i = PositionsTotal() - 1; i >= 0; i--)
   {
      if(position.SelectByIndex(i))
            if(position.Symbol() == _symbol && position.Magic() == _mNumber)
               return true;
   }
   
return false;
  }
 
Marcus92 #:
I'm currently looking for an ECN broker that has good spreads and proper regulation from either ASIC or FCA. Any recommendations?

Broker spread comparison tool.

 

Hello,

     I have Creat a Expert Adviser Based on Moving Average.  I want to Modify my SL ,TP and Pending Order Price to the Moving Average Price.I have a problim With Trade Modefication Function I have Geting 4756 ERROR.Some one Please Help me with the Example. I am send A pending Buyy and Sell Limit.

Best Regards.

  Thank You !