[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 105

 

Hi all,

I made an indicator, it draws two lines at 45 degrees. When it intersects, I want it to be horizontal.

So how do I calculate the intersection?

I drew with Low/High of previous day, through one point.

To get such a line I draw from a point to the beginning of the day and in the other side from the point of the ray.

How do I write the code to re-calculate it? I have not done it yet:

Вот начну искат как цена двигается-толко надо увидет ее-первая ест,но вторая 0:
price1 = NormalizeDouble(ObjectGet("Dn",OBJPROP_PRICE1),Digits);
price2 = NormalizeDouble(ObjectGet("Dn",OBJPROP_PRICE2),Digits);
Time_start - ето синяя вертикалная линия
double b3=iBarShift(Symbol(),0,Time_start);      
double b4=iBarShift(Symbol(),0,TimeCurrent());
ну и цикл поиска
for(int j = b4;j <= b3;j++){
Ну що искат,если я не вижу то,что ищу?
Застрял.
 
bond007:
.... and how can they find this out???)
i just do not understand.... they say you can trade with EAs, others say you cannot - if for example a brokerage company allows you to use an EA, then how?

the brokerage company cannot see the code.... they only see the intensity of order placement and comments in the orders ... there are some DTs where the work of EAs in the terminal is prohibited ... it means when you stick an EA to a chart it just doesn't trade ... if it is not allowed by the server settings the client will give an error xxx or something like 2013.01.18 22:45:03 '30xxxxx': trading by experts is prohibited



i.e., i don't know why i got so worried about the code?

 
hoz:

Thank you, now you'll get an appetite :)
Good for you, and gradually from simple to complex you will program your understanding, which is necessary for writing any program. Good luck!
 
mario065:

Hi all,

I made an indicator, it draws two lines at 45 degrees. When it intersects, I want it to be horizontal.

So how do I calculate the intersection?

I drew with Low/High of previous day, through one point.

To get such a line I draw from a point to the beginning of the day and in the other side from the point of the ray.

How do I write the code to re-calculate it? I have not done it yet:

To help.
 
drknn:

What do you mean by the term "logarithmic graph"? Please give me an example. I, for example, have only ever encountered the concept of a logarithmic chart scale. The MT4 terminal already has this scale.
I mean the logarithmic scale. How can I find it in MT? I have been using it for so many years and I don't know what is already there.
 
mario065:

Hi all,

I made an indicator, it draws two lines at 45 degrees. When it intersects, I want it to be horizontal.

So how do I calculate the intersection?

I drew with Low/High of previous day, through one point.

To get such a line I draw from a point to the beginning of the day and in the other side from the point of the ray.

How do I write the code to re-calculate it? I have not done it yet:



Igor Kim's:

Function CrossPointOfLines()

 

Alexei, Artem, thank you.

I'm going to learn Igor Kim's functions.

 

So I don't have two dots, I only have one.

Here's the sors:

//+------------------------------------------------------------------+
//|                                                     TRIANGLE.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2013,mario"
#property link      ""

#property indicator_chart_window
extern string   TimeStart  = "Час за начало";
extern datetime Time_start = D'17.01.2013';
extern int      Days       = 1;
bool            New_Bar    = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){return(0);}
int deinit(){
   ObjectsDeleteAll(0,OBJ_TRENDBYANGLE);
   ObjectsDeleteAll(0,OBJ_VLINE);
   Comment("");return(0);}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  { 
   datetime New_Time,time_next,time_barh,time_barl;
   time_next = Time_start + Days*86400;
   datetime new_day = iTime(Symbol(),PERIOD_D1,0);
//+------------------------------------------------------------------+
   if(New_Time != new_day)                        
           {
           New_Time = new_day;                         
           New_Bar  = true;
           }
//+------------------------------------------------------------------+ 
//Шифтвам 
   double b1=iBarShift(Symbol(),0,Time_start);      
   double b2=iBarShift(Symbol(),0,time_next);
   double min = 3,max = 0;
   for(int i = b2;i <= b1;i++){
      if(iHigh(Symbol(),0,i)>max){ max=iHigh(Symbol(),0,i);time_barh = Time[i];}
      if(iLow (Symbol(),0,i)<min){ min=iLow (Symbol(),0,i);time_barl = Time[i];}
      }
   if(New_Bar == true){ 
      ObjectsDeleteAll(0,OBJ_TRENDBYANGLE);
      ObjectsDeleteAll(0,OBJ_VLINE);
      DrawLine("Start",0,Time_start,0,Time_start,0,0,0,2,Aqua,false);
      DrawLine("Up",3,time_barh,max,0,0,315.0,0,2,DeepSkyBlue,true);
      DrawLine("Up1",3,time_barh,max,Time_start,0,315.0,0,2,DeepSkyBlue,false);
      DrawLine("Dn",3,time_barl,min,0,0,45.0,0,2,Orange,true);
      DrawLine("Dn1",3,time_barl,min,Time_start,0,45.0,0,2,Orange,false);
    }
//+------------------------------------------------------------------+
   double spead = MarketInfo(Symbol(),MODE_SPREAD);
//+------------------------------------------------------------------+ 
   Comment("\nВреме на брокера: ",TimeToStr(TimeCurrent(),TIME_SECONDS),", Локално време: "+TimeToStr(TimeLocal(),TIME_SECONDS),
           "\nТекущ спред: ",DoubleToStr(spead/10,1),
           "\n min:        ",DoubleToStr(min,Digits),
           "\n max:       ",DoubleToStr(max,Digits)
           );
   return(0);
  }
//+------------------------------------------------------------------+
void DrawLine(string name,int lines,datetime time1,double value,datetime time2,double value1,double grd,int style,int wid,color col,bool ray)
{
   ObjectCreate(name,lines,0,time1,value,time2,value1);
   ObjectSet(name,OBJPROP_ANGLE,grd);
   ObjectSet(name,OBJPROP_COLOR,col);
   ObjectSet(name,OBJPROP_STYLE,style);
   ObjectSet(name,OBJPROP_WIDTH,wid);
   ObjectSet(name,OBJPROP_RAY,ray);
}
//+------------------------------------------------------------------+
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 12.10.2007                                                     |
//|  Описание : Вычисляет координаты точки пересечения двух прямых.            |
//|             Каждая прямая задаётся парой координат своих точек.            |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    x - массив абсцисс              x[0], x[1] - первая прямая              |
//|                                    x[2], x[3] - вторая прямая              |
//|    y - массив ординат              y[0], y[1] - первая прямая              |
//|                                    y[0], y[1] - вторая прямая              |
//|    t - массив искомых координат    t[0]       - абсцисса                   |
//|                                    t[1]       - ордината                   |
//+----------------------------------------------------------------------------+
void CrossPointOfLines(double& x[], double& y[], double& t[]) {
  double z=(y[3]-y[2])*(x[1]-x[0])-(y[1]-y[0])*(x[3]-x[2]);
  ArrayResize(t, 2);
  ArrayInitialize(t, 0.0);

  if (z==0) Print("CrossPointOfLines(): Не удалось найти точку пересечения!");
  else {
    double xy1=x[1]*y[0]-x[0]*y[1];
    double xy2=x[3]*y[2]-x[2]*y[3];
    t[0]=NormalizeDouble((xy1*(x[3]-x[2])-xy2*(x[1]-x[0]))/z, 0);
    t[1]=(xy1*(y[3]-y[2])-xy2*(y[1]-y[0]))/z;
  }
}

The code itself is very simple. But there is only one dot.

 

Who knows why the DailyPivotPoints indicator in the tester in visual mode shows only today's data on all dates?

And if possible, what should be added to it to show what was on the history? Thank you!

 
lenalebedeva:
I mean the logarithmic scale specifically, how do you find it in MT? I've been using it for so many years and don't know what's already there.

See

P.S.

For example, you look at a past low trend on the chart and see that towards the edge of the chart it shifts even lower out of the window. You scroll down the chart to the future and watch as the chart shifts automatically upwards, freeing up space to view the candles of the underlying chart. And what was previously visible at the top of the chart window is now moved even higher, out of the chart window. This is the implementation of a logarithmic price scale on the chart. If it did not exist, you would have to scroll the chart not only right-left, but also up and down. That is why the time scale is linear and the price scale is logarithmic, in order to display the data in the chart window easily.

In the past, when computers were unavailable, traders used a millimeter chart and plotted prices on it for predicting trends and turning points. Therefore, there were two scales on paper - price and time. These are two linear scales. Can you imagine how big a sheet of millimetre paper would have to be to contain all the fifteen-minute candlesticks of the last year? Surely it would be as big as the wall of a room (if not bigger). So, when you are scrolling the chart on the screen, you can imagine this model: a candlestick chart of prices is drawn on the wall. There is also a rectangular (e.g. red) frame - it is your monitor. Moving along the chart is nothing more than moving this red rectangle along the trend. But then you would say that both scales in your monitor are linear. This is true, but only partially - note that when scrolling the chart, the candle that was large (visually perceived as large) will become smaller in size after a slight shift, although if we measure the distance between its extremums, the number of points remains the same.

Look, here are 2 screenshots of the same chart. The first screenshot is just a screenshot. The second is a screenshot of the same screen but after spinning the mouse wheel one click, the chart has shifted back a few candles. Take a piece of paper, attach it to the first screenshot and mark high and low prices of the candle marked in red. Then move the marked risks to the same candle in the second screenshot. You will understand what we are talking about and what a shift in the logarithmic scale is (what is the essence of the uneven use of scales here).

And why do you need to get into the nuances of logarithmic scales? What were you hoping to find in them?

Reason: