Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 388

 
Zhunko:

Library.


It was ServiceTickExpert() that I tried to use before contacting the forum. Tried to run the test expert now

#import "ServicesMT4.dll"
   void ServiceTickExpert(int hwndChart);
   void ServiceRefreshChart(int hwndChart, int nPeriodMilliSec);
#import
int delay = 180;
datetime read_now;
int init(){
   read_now = TimeCurrent() + delay;
}
int start(){
   int hWnd = WindowHandle(Symbol(), Period());
   ServiceTickExpert(hWnd);
   ServiceRefreshChart(hWnd, 500);
   int how_many_remains = read_now - TimeCurrent();
   Comment(StringConcatenate(
      StringSubstr("-", (how_many_remains%60 >= 0), 0),
      StringSubstr("0", (MathAbs(how_many_remains/60) > 9), 0),
      MathAbs(how_many_remains/60),
      ":",
      StringSubstr("0", (MathAbs(how_many_remains%60) > 9), 0),
      MathAbs(how_many_remains%60)
   ));
   return(0);
}

- But silence.

 
Link_x:
The main thing is that they must be displayed. :)

We do so and boolean values evaporate, but the problem remains.

I think the problem is in this line:

R_time        = Seconds() * Minute() * Hour(); 

All values are multiplied by the same time - current server time, to be exact - last known time.

And also in declaration of variables of bool type where they should be double, and a couple of other small bugs. The primer is not yet completely bored, as I understand it ))))

#property indicator_separate_window
#property indicator_buffers 3
#property  indicator_color1 Gold
#property  indicator_color2 Gold
#property  indicator_color3 Gold
//+---------------------------------------------------------------------+
extern double _N_ = 1; 
extern double _M_ = -1; 
extern int History = 10000; //многовато, а вдруг столько на графике нету? Проверка нужна...
//+---------------------------------------------------------------------+
int p; 
//+---------------------------------------------------------------------+
double Buf_0[];
double Buf_1[];
double Buf_2[];
double RSI;
double ADX_Main; 
double ADX_dD;
double ADX_DD;
double price;
//+---------------------------------------------------------------------+  5 переменных ниже были обьявлены как bool, непонятно только с какого перепугу
double R_adx; 
double R_time;
double R_adx_time;
double R_rsi_time;
double R_rrsi_time;
//+---------------------------------------------------------------------+
int init()
{
//+---------------------------------------------------------------------+  
SetIndexBuffer(0,Buf_0);
SetIndexStyle(0,DRAW_LINE);
//+---------------------------------------------------------------------+  
SetIndexBuffer(1,Buf_1);
SetIndexStyle(1,DRAW_LINE);
//+---------------------------------------------------------------------+  
SetIndexBuffer(2,Buf_2);
SetIndexStyle(2,DRAW_LINE);
//+---------------------------------------------------------------------+  
return(0);
}
//+---------------------------------------------------------------------+
int start()
{
//+---------------------------------------------------------------------+  
for(
p=0;
p<History;
p++)
{
//+---------------------------------------------------------------------+  
//price = Bid;
//+---------------------------------------------------------------------+  
ADX_Main    = iADX(Symbol(),0,14,0,0,p);
ADX_dD      = iADX(Symbol(),0,14,0,1,p);
ADX_DD      = iADX(Symbol(),0,14,0,2,p);
RSI         = iRSI(Symbol(),0,14,0,p);
//+---------------------------------------------------------------------+  
R_adx         = (ADX_DD - ADX_dD) * ADX_Main; 
string R_time1        = TimeToString(Time[p],TIME_SECONDS); //Время отркытия свечи р
R_time        = StringToDouble(R_time1); 
//+---------------------------------------------------------------------+  
R_adx_time    = _N_ * (R_time + R_adx);
R_rsi_time    = _N_ * (R_time + RSI);
R_rrsi_time   = _M_ * (R_time + RSI);
//+---------------------------------------------------------------------+  
Buf_0[p] = R_adx_time;
Buf_1[p] = R_rsi_time;
Buf_2[p] = R_rrsi_time;
//+---------------------------------------------------------------------+  
}
return(0); //эта строка была чуть  выше чем надо :)
}
//+-------------------
 
evillive:

I think the problem is in this line:

All values are multiplied by the same time - the current server time, or more precisely, the last known time.

And also in declaration of variables of bool type where they should be double, and a couple of other small bugs. The primer is not yet completely bored, as I understand it ))))


Oh, thank you!
I can see the mistakes and the glitches.
I can't imagine how I could ever type that? :)

I noticed that the indicator draws pictures that I didn't even imagine.
Worked a little on the "body" of the code.
R_adx           = (ADX_DD - ADX_dD) * ADX_Main; 
string R_time_1 = TimeToStr(Time[p],TIME_SECONDS);
R_time          = StrToDouble(R_time_1); 
string T_time_1 = TimeToStr(Time[p],TIME_MINUTES);
T_time          = StrToDouble(T_time_1);
string B_time_1 = TimeToStr(Time[p],TIME_DATE);
B_time          = StrToDouble(B_time_1);
A_time          = R_time * T_time * B_time;
It's more like what I imagined.
But the "time waves" completely dampen the "price waves". Strengthen the "price waves" and weaken the "time waves".
R_rsi_time    = _N_ * (A_time + (RSI * 2000)) / 1.9;
A_time          = R_time * T_time * B_time / 4;
R_adx           = ((ADX_DD - ADX_dD) * ADX_Main) * 40; 
 
gyfto:


It was ServiceTickExpert() that I tried to use before contacting the forum. Tried to run the test expert now

- but it is silent.

It's not working code. Maybe you could still look at the example script?

There are 3 ways to update the chart.

1. Arrange the infinite loop in the Expert Advisor start. Single start of the Expert Advisor from the initial or remote program is necessary.
2. Start updating from another thread. Then every Expert Advisor will be executed regardless of its code.

3. Similar to point 2, the same, but with the help of system timer.

The first 2 are implemented in the library. What you have in your code requires independently arranging the cycle of chart refreshing or looping of the Expert Advisor. In the first case, a looped script is required. In the second case, the Expert Advisor needs to be started once.

The first 7 functions from that section (4.7) organize refreshing and manage independent chart refreshing in a separate thread. It is possible to start and unload the program once. The charts will continue to update without MQL programs.

#include <ServicesMT4.mqh>

int delay = 180;
datetime read_now;
int hWnd = 0;

void init()
 {
  read_now = TimeCurrent() + delay;
  hWnd = WindowHandle(Symbol(), Period());
  ServiceRefreshChart(hWnd, 500);
 }
void deinit()
 {
  ServiceStopRefreshChart(hWnd);
 }
void start()
 {
  int how_many_remains = TimeLocal() - read_now;
  Comment(StringConcatenate(StringSubstr("-", (how_many_remains%60 >= 0), 0),
                            StringSubstr("0", (MathAbs(how_many_remains/60) > 9), 0),
                            MathAbs(how_many_remains/60), ":",
                            StringSubstr("0", (MathAbs(how_many_remains%60) > 9), 0),
                            MathAbs(how_many_remains%60)));
 }
 
Link_x:

Oh, thank you!
I can see the mistakes and the glitches.
I can't even imagine how I could have typed that. :)

I noticed that the indicator draws pictures that I didn't even imagine.
I have worked a little on the "body" of the code.
It's more like what I imagined.
But the "time waves" completely dampen the "price waves". Reinforcing the "price waves" and weakening the "time waves".


May I ask what the scary thing is?

R_adx           = (ADX_DD - ADX_dD) * ADX_Main; 
string R_time_1 = TimeToStr(Time[p],TIME_SECONDS);
R_time          = StrToDouble(R_time_1); 
string T_time_1 = TimeToStr(Time[p],TIME_MINUTES);
T_time          = StrToDouble(T_time_1);
string B_time_1 = TimeToStr(Time[p],TIME_DATE);
B_time          = StrToDouble(B_time_1);
A_time          = R_time * T_time * B_time;
 
Zhunko:
Can you look into the example script though? This is not working code.


But... but it was by your script that I first modified the famous iTicks script! Here, now I ran it again, first the test EA (its code is on the previous page, not on this one), then iTicks next modification:

#include <ServicesMT4.mqh>
extern int  delay_MSecond = 2000;
int start(){
   while(!IsStopped()){
      string _symbol = Symbol(); int _period = Period();
      int hWnd = WindowHandle(_symbol, _period);
      ServiceTickExpert(hWnd);
      Sleep(delay_MSecond);
   }
   return(0);
}

by sample code from Check_ServicesMT4.dll.mq4

if (TickExpert) while (!IsStopped()) {ServiceTickExpert(hwndChart); Sleep(1000);}

No changes on the chart

The checkbox "allow dll call" is checked...

Added by

Zhunko:

There are 3 ways to update a chart.

I was replying to an old version of the post, sorry, I'll look into it now...
 

gyfto, the example in the test script is made to update the chart you set up. It is possible to set up for a remote (someone else's) chart.

It's obvious that it makes no sense to update the chart for the script.

Configure it on the chart with your Expert Advisor. The expert will work.

#include <ServicesMT4.mqh>

int hWnd = 0;

void init()
 {
  hWnd = WindowHandle(Symbol(), Period());
  ServiceRefreshChart(hWnd, 500);
 }
void deinit()
 {
  ServiceStopRefreshChart(hWnd);
 }
void start()
 {
  Comment(TimeToStr(TimeLocal(), TIME_DATE|TIME_SECONDS));
 }
 

Man, I'm a fool. I realised my mistake. Keyword.

void start()
 {
  Comment(TimeToStr(TimeLocal(), TIME_DATE|TIME_SECONDS));
 }

I did.

int init(){
   read_now = TimeCurrent() + delay;
}

And so on, which was a constant at startup (2013.12.31 18:59:59). That's how inattention fails.... Sorry for the inconvenience, it all makes sense now.

This code does work:

int delay = 180;
datetime read_now;
int init(){
   read_now = TimeLocal() + delay;
   start();
}
int start(){
   while(!IsStopped()){
      int how_many_remains = read_now - TimeLocal();
      Comment(StringConcatenate(
         StringSubstr("-", (how_many_remains%60 >= 0), 0),
         StringSubstr("0", (MathAbs(how_many_remains/60) > 9), 0),
         MathAbs(how_many_remains/60),
         ":",
         StringSubstr("0", (MathAbs(how_many_remains%60) > 9), 0),
         MathAbs(how_many_remains%60)
      ));
      Sleep(1000);
   }
   return(0);
}

Naturally, it's only for the weekend. Once again I apologise for the inconvenience.

 

That's not appropriate. That's the way to do it:

#include <ServicesMT4.mqh>

int delay = 180;
datetime read_now;
int hWnd = 0;

void init()
 {
  read_now = TimeLocal() + delay;
  hWnd = WindowHandle(Symbol(), Period());
  ServiceRefreshChart(hWnd, 100);
 }
void start()
 {
  ServiceStopRefreshChart(hWnd);
  while(!IsStopped())
   {
    int how_many_remains = read_now - TimeLocal();
    Comment(StringConcatenate(StringSubstr("-", (how_many_remains%60 >= 0), 0),
                              StringSubstr("0", (MathAbs(how_many_remains/60) > 9), 0),
                              MathAbs(how_many_remains/60), ":",
                              StringSubstr("0", (MathAbs(how_many_remains%60) > 9), 0),
                              MathAbs(how_many_remains%60)));
    Sleep(1000);
   }
 }
 
Vinin:


May I ask what it is that's so scary?


The product of minutes times seconds multiplied by hours.
The price movement is not chaotic, but "coded".
To decipher this movement, it is necessary to synthesise the price movement with a pattern - a moving line. I chose the time continuum.
Synthesis of price movement with time movement must be performed using a special formula that I will not reveal to you.
The indicator above is based on a reduced formula.
The full formula (I calculated to satisfy my interest) is 37 times more complicated than the reduced formula.

The indicator on the full formula was built today at 12:00 p.m. Moscow time.
The sight that I had imagined was revealed to my eyes.
I saw a pattern - moving lines whose subsequent movement can be calculated, and because their movement is directly related to price movement, price movement will be predictable.
Reason: