[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 161

 
chief2000 >> :

In the Indicator I set (to then compare them with Time[i]):


Then in the loop


As a result, StrToTime(StartRange) and StrToTime(EndRange) produce Zeros .

- Why and how do I fix it?



Oops. And how do you manage to put a datetime variable into the StrToTime function? There should be a string in it!

Or do you think the job form D'1970.12.24' is a string? You are mistaken.

Maybe you need TimeToStr?

 


This results inStrToTime(StartRange) and StrToTime(EndRange) producing Zeros .

- Why and how to fix it?



//функция 

bool isTradeTimeString(string TimeBegin="00:00", string TimeEnd="00:00") {
  datetime dtBegin, dtEnd;        // Время начала и окончания работы
  int      hc, he;                // Часы текущего времени и окончания работы

  dtBegin=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+ TimeBegin);
  dtEnd  =StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+ TimeEnd);
  hc     =TimeHour(TimeCurrent());
  he     =TimeHour( dtEnd);
  if ( dtBegin>= dtEnd) {
    if ( hc>= he) dtEnd+=24*60*60; else dtBegin-=24*60*60;
  }

  if (TimeCurrent()>= dtBegin && TimeCurrent()<= dtEnd) return( True);
  else return( False);
}

//+-------------------------------------------------------------------
вставить в глоб. переменные
//extern string TimeBegin = "00:00";
//extern string TimeEnd = "00:00";

а это уже в код - проверка 
/*
isTradeTimeString(); //торговля по времени
   if ( isTradeTimeString( TimeBegin, TimeEnd))
     {
       //торгуем
     }
*/
 

Obviously it was my mistake (misinterpreted Example

from documentation). It turned out that it's possible to compare "datetime" variable directly to Time[i].

Thanks for the help!

 
...... has a function... or a piece of code... that counts the number of pips traveled after an order is opened? I can't make it myself today (since yesterday the pot was out of water) but I really need it!
 
I'm telling you, my head doesn't work )))) I'll go get the code from the trawl)))
 

//+------------------------------------------------------------------+
//| Custom MACD.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Silver
#property indicator_color2 Red
#property indicator_color3 Blue

#property indicator_width1 2
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
extern int SMA=12;

//---- indicator buffers
double MacdBuffer[];
double SignalBuffer[];
double EMABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexDrawBegin(1,SignalSMA);
IndicatorDigits(Digits+1);
//---- indicator buffers mapping
SetIndexBuffer(0,MacdBuffer);
SetIndexBuffer(1,SignalBuffer);
SetIndexBuffer(2,EMABuffer);

//---- name for DataWindow and indicator subwindow label
IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+","+SMA+")");
SetIndexLabel(0,"MACD");
SetIndexLabel(1,"Signal");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
for(int i=0; i<limit; i++)
MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2-nd buffer
for(i=0; i<limit; i++)
SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
//---- done
for(i=0; i<limit; i++)
EMABuffer[i]=iMAOnArray(MacdBuffer,Bars,SMA,0,MODE_SMA,i);
//---- done
return(0);
}
//+------------------------------------------------------------------+

how do i make a MA with a negative offset for example -5 bars, when i set it to -5 it draws some bullshit?

 
evgenio >> :

как мне сделать МА с отрицательным смещением например на -5 баров, когда ставлю -5 рисует каюто фигню ??

Why bullshit? Is there something you don't want to see? Or am I missing something !!!!

ׂ

Above is your variant, below is the variant with a shift of -5 ! just by -5 bars shifted, what is wrong or wrong????????

 
Infinity >> :

Why bullshit? Is there something you don't want to see? Or am I missing something !!!!

Above is your variant, below is the variant with a shift of -5 ! just by -5 bars shifted, what is wrong or wrong????????

Well, that's true, but when I try to invoke the EA.

//+------------------------------------------------------------------+
//| fgfgfgfgfgf.mq4 |
//| Evgenio |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Evgenio"
#property link "http://www.metaquotes.net"

extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
extern int SMA=12;
//---переменные----------
double k,k1,k2;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
k=NormalizeDouble(iCustom(Symbol(),0,"MACD+мувинг",FastEMA,SlowEMA,SignalSMA,SMA,0,0),5);
k1=NormalizeDouble(iCustom(Symbol(),0,"MACD+мувинг",FastEMA,SlowEMA,SignalSMA,SMA,1,0),5);
k2=NormalizeDouble(iCustom(Symbol(),0,"MACD+мувинг",FastEMA,SlowEMA,SignalSMA,SMA,2,0),5);
if (OrdersTotal()<=2)
{
if (k>0 && k2>k1+0.0005)
ObjectCreate("down"+Time[1], OBJ_ARROW, 0, Time[1], Open[1]+100*Point);
ObjectSet("down"+Time[1], OBJPROP_ARROWCODE, 242);
ObjectSet("down"+Time[1], OBJPROP_COLOR, Yellow);
}
return(0);
}
//+------------------------------------------------------------------+

it doesn't work.

Here is what I do

1. run a test on a certain period

2. I attach an indicator

3 I get something strange.


 

How can I make

I want my EA to open an order only once a day.

If it opened an order, then closed it and switched off until the next day.

i understand, i need to fetch the latest deal from the history... compare it with the date and if the order has already been closed that day, then deactivate the EA...

are you thinking in the right direction?

I can't fully understand it. i am new to mql.

 

Good afternoon, colleagues.

Please advise how to explain points of line inflection in software, i.e. to the expert, i.e. the expert has to distinguish between two options of МА position: МА rising, МА falling.