Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 158

 
-Aleks-:

I have this design

static datetime TimeN=0;  


void OnTick()
  {

datetime TimeC=iTime(NULL,TF,0);
   if(TimeN==0)TimeN=TimeC;
   if(TimeN==TimeC) return;
   TimeN=TimeC;


thank you!!!
 
Tell me why I should create a topic if none of the experts won't even read the posts. Why did I ask for help if all the experts in this thread don't give a damn about anyone.
 
vannoo:
Tell me just why I have to create a topic if none of the experts do not even want to read the messages. I don't know why I asked for help. If everyone in this thread gives a shit about everyone.

You wrote this:

Forum on trading, automated trading systems and trading strategy testing

Any newbie questions on MQL4, help and discussion on algorithms and codes

vannoo, 2017.03.17 15:57

Folks can you advise me here what i have done wrong .Not so ; I have been learning for about three weeks to write MQL4 EAs myself ! I wrote a compiled EA, no errors or warnings and everything seems fine. I found a big BUT it doesn't want to work . Maybe I can ask here where I made a mistake and what I did wrong. If someone tells me what to do, let me know. I am afraid this is my first time here and how to do it. Although I see how.
Well, here's where they can give you an answer.
 
Hello! Help ... My MT4 is dead... I tried everything (reboot, restore the system, delete the old one with all the guts, download the new one), nothing helps. It is deadlocked ... if you open it, to close it you have to do it through Task Manager
 

hello all

I am new to programming, but trying to learn)

I have a little problem with closing the order according to the indicator readings

I can tell straight away about the conditions of opening and closing a position by the indicator readings and close the order in the opposite direction without any stops and profit

if(r > 50 && p > m) //conditions for openingof a Buy order

{

ticketB = OrderSend(Symbol(),OP_BUY,0.1,Ask,5,0,0,",111,0,Green); //open Buy order

}

am I writing the order close condition correctly?

if(r < 50 && p < m) --- this is a Sell condition and a Close condition

{

OrderClose(ticketB,0.1,Bid,5,Red);

}

and printspossible use of uninitialized variable 'ticketB' and return value of 'OrderClose' should be checked

Can you guys tell me where I wrote it wrong?

 

Can you please tell me how to make a cycle of dates - I need to search ranges - years and quarters.

For example the first range from 01.01.2010 to 31.12.2010, the second from 01.01.2011 to 31.12.2011 - how to organize it in the cycle?

 

If I didn't make myself clear earlier, here's an example of a design I'd like to clench somehow...


   for(int Ti=0; Ti<18; Ti++)
     {
      if(Ti==0)  {start_time=D'01.01.2000'; stop_time=D'31.12.2000';}
      if(Ti==1)  {start_time=D'01.01.2001'; stop_time=D'31.12.2001';}
      if(Ti==2)  {start_time=D'01.01.2002'; stop_time=D'31.12.2002';}
      if(Ti==3)  {start_time=D'01.01.2003'; stop_time=D'31.12.2003';}
      if(Ti==4)  {start_time=D'01.01.2004'; stop_time=D'31.12.2004';}
      if(Ti==5)  {start_time=D'01.01.2005'; stop_time=D'31.12.2005';}
      if(Ti==6)  {start_time=D'01.01.2006'; stop_time=D'31.12.2006';}
      if(Ti==7)  {start_time=D'01.01.2007'; stop_time=D'31.12.2007';}
      if(Ti==8)  {start_time=D'01.01.2008'; stop_time=D'31.12.2008';}
      if(Ti==9)  {start_time=D'01.01.2009'; stop_time=D'31.12.2009';}
      if(Ti==10) {start_time=D'01.01.2010'; stop_time=D'31.12.2010';}
      if(Ti==11) {start_time=D'01.01.2011'; stop_time=D'31.12.2011';}
      if(Ti==12) {start_time=D'01.01.2012'; stop_time=D'31.12.2012';}
      if(Ti==13) {start_time=D'01.01.2013'; stop_time=D'31.12.2013';}
      if(Ti==14) {start_time=D'01.01.2014'; stop_time=D'31.12.2014';}
      if(Ti==15) {start_time=D'01.01.2015'; stop_time=D'31.12.2015';}
      if(Ti==16) {start_time=D'01.01.2016'; stop_time=D'31.12.2016';}
      if(Ti==17) {start_time=D'01.01.2017'; stop_time=D'31.12.2017';}
    }
 

I want to change a full stop in a line to a comma - it doesn't work - what am I doing wrong?


string str_avrMassSell=DoubleToString(avrMassSell,2);
str_avrMassSell=StringReplace(str_avrMassSell,".",",");
 
-Aleks-:

If I didn't make myself clear earlier, here is an example of a construction I would like to clench somehow...



If by year, it could be something like this

//+------------------------------------------------------------------+
//|                                                    Year_Test.mq4 |
//|                                            Copyright 2017, Vinin |
//|                                             http://vinin.ucoz.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Vinin"
#property link      "http://vinin.ucoz.ru"
#property version   "1.00"
#property strict
#property script_show_inputs
//--- input parameters
 input int      Ti=18;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   datetime start_time=D'01.01.2000';
   datetime stop_time=D'31.12.2000';

   for (int ti=1;ti<Ti;ti++)
   {   
   
   start_time=start_time+31536000;
   if (TimeDay(start_time)==31) start_time+=86400;


   stop_time=stop_time+31536000;

   if (TimeDay(stop_time)==30) stop_time+=86400;

   Print("ti = ", ti, " Start = ", TimeToStr(start_time,TIME_DATE)," Stop = ",TimeToStr(stop_time,TIME_DATE));
   }
   
  }

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 17 Start = 2017.01.01 Stop = 2017.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 16 Start = 2016.01.01 Stop = 2016.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 15 Start = 2015.01.01 Stop = 2015.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 14 Start = 2014.01.01 Stop = 2014.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 13 Start = 2013.01.01 Stop = 2013.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 12 Start = 2012.01.01 Stop = 2012.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 11 Start = 2011.01.01 Stop = 2011.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 10 Start = 2010.01.01 Stop = 2010.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 9 Start = 2009.01.01 Stop = 2009.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 8 Start = 2008.01.01 Stop = 2008.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 7 Start = 2007.01.01 Stop = 2007.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 6 Start = 2006.01.01 Stop = 2006.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 5 Start = 2005.01.01 Stop = 2005.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 4 Start = 2004.01.01 Stop = 2004.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 3 Start = 2003.01.01 Stop = 2003.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 2 Start = 2002.01.01 Stop = 2002.12.31

2017.03.20 21:24:14.002 Year_Test EURUSD,M15: Ti = 1 Start = 2001.01.01 Stop = 2001.12.31


 
-Aleks-:

I want to change a full stop in a line to a comma - it doesn't work - what am I doing wrong?



It works

//+------------------------------------------------------------------+
//|                                                StringReplace.mq4 |
//|                                            Copyright 2017, Vinin |
//|                                             http://vinin.ucoz.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Vinin"
#property link      "http://vinin.ucoz.ru"
#property version   "1.00"
#property strict
#property script_show_inputs
//--- input parameters
input double   Temp=999.99;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   string stemp1=DoubleToStr(Temp,2);
   string stemp2=stemp1;
   StringReplace(stemp2,".",",");
   Print(stemp1," = ", stemp2);
   
  }
//+------------------------------------------------------------------+

2017.03.20 21:39:02.802 StringReplace EURUSD,M15: 999.99 = 999.99


Reason: