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

 
satorifx:

Good afternoon.

Can you tell me how to programmatically link 2 coordinate systems in a graph: (X,Y) and (time,price)? You need a label with coordinates (X,Y) that will always be at the minimum price on the chart.

artmedia70:
There are differences. On the chart in general, i.e. on all available history in the terminal, or on the visible chart (within the monitor screen) ?


Exactly on the visible chart within the monitor screen

 
satorifx:

Exactly on the visible graph within the monitor screen

Throw this script on the chart:

//+------------------------------------------------------------------+
//|                                       sc_LowestPricePerChart.mq4 |
//|                               Copyright 2013, Artyom A. Trishkin |
//|                          artmedia70@gmail.com, Skype: Artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, Artyom A. Trishkin"
#property link      "artmedia70@gmail.com, Skype: Artmedia70"
//+------------------------------------------------------------------+
//|           script program start function                                    |
//+------------------------------------------------------------------+
int start() {
   int count=WindowBarsPerChart();                             // количество видимых баров 
   int LowestBar=iLowest(Symbol(),Period(),MODE_LOW,count,0);  // бар с минимальной ценой
   double LowestPricePerChart=Low[LowestBar];                  // минимальная цена из видимых баров
   SetArrow(5, Yellow, "sc_LowestPricePerChart_LowestPrice", Time[LowestBar], LowestPricePerChart, 1);
   return(0);
}
//+------------------------------------------------------------------+
void SetArrow(int cd, color cl, string nm="", datetime t1=0, double p1=0, int sz=0) {
   if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_ARROW, 0, 0, 0);
   ObjectSet(nm, OBJPROP_TIME1    , t1);
   ObjectSet(nm, OBJPROP_PRICE1   , p1);
   ObjectSet(nm, OBJPROP_ARROWCODE, cd);
   ObjectSet(nm, OBJPROP_COLOR    , cl);
   ObjectSet(nm, OBJPROP_WIDTH    , sz);
}
//+------------------------------------------------------------------+

Do the same for the maximum

 
artmedia70:

Throw this script on the chart:

Do the same for the maximum


The point is that the ARROW object has coordinates (time, price) but no coordinates (x,y). If you extend the indicator window at the bottom of the screen, the object will move together with the window, but at the same time, the coordinates (x,y) of the object in the window will change and they cannot be calculated because there is no connection between the two coordinate systems. In principle, you could use a TEXT object or any other object instead ofan ARROW object, but this does not solve the problem.
 
satorifx:
The point is that the ARROW object has coordinates (time, price), but no coordinates (x,y). If we go wider up the indicator window at the bottom of the screen, the object will move together with the window, but at the same time the coordinates (x,y) of the object in the window will change and they cannot be calculated because there is no connection between the two coordinate systems. In principle, you could use a TEXT object or any other object instead of an ARROW object, but this does not solve the problem.

Well then tie the white to the hot. You have been shown how to know the minimum price on visible bars, and you have been shown how to mark it on the chart.

The rest is your obscure wishful thinking ;)

 
Sepulca:



I'm not quite sure what you mean? If there was no file (it was not opened) or there was a reading error. It would have given a message, but there is no news...
 
The code should be written so that on the bar where the trade is opened, the position is exited if a spike is formed on the next bar immediately after the bar with the spike, but the signals on the bars after the bar where the trade is opened, where the spike occurred, are ignored. There is no problem with the code describing the spike. The difficulty is how to tell the program that the signal to use only the bar at which the trade was opened.
 
Forexman77:
The code should be written so that on the bar where the trade is opened, the position is exited if a spike is formed on the next bar immediately after the bar with the spike, but the signals on the bars after the bar where the trade is opened, where the spike occurred, are ignored. There is no problem with the code describing the spike. The difficulty is how to indicate to the program that only the bar at which the trade is open is used for the signal.
The deal has an opening time OrderOpenTime(); There is a function that shows you the number of bar by time iBarShift(); Use this bar as "... we use only the bar at which the deal is open for the signal ...".
 
artmedia70:
The trade has an opening time OrderOpenTime(); And there is a function that will show you the bar number by time iBarShift(); This is the bar and use it as "... that for the signal we use, only the bar on which the trade is open...".

Thanks, I'll look into it.
 
Zolotai:

I'm not quite sure what you mean? If there was no file (it wasn't opened) or there was an error when reading. You would get a message, but you don't get any news...

Handle=FileOpen(File_Name,FILE_CSV|FILE_READ|FILE_WRITE,";");// Open file.

If FILE_WRITE is not combined with FILE_READ, a file with zero length will be opened. Even if there was data in the file before it was opened, it will be destroyed.
If you want to append data to an existing file, you need to open it using the FILE_READ | FILE_WRITE combination..
If FILE_READ is not combined with FILE_WRITE, the file will only be opened if the file already exists. If the file does not exist, it can be created using FILE_WRITE mode.

 
artmedia70:

Well then tie the white to the hot. You have been shown how to know the minimum price on visible bars, and you have been shown how to mark it on the chart.

The rest is your obscure wishful thinking ;)


I see, thanks for the "help".

Who has a real solution and not a "show what's too far away from solving the issue"?

satorifx:

Can you tell me how to programmatically link 2 coordinate systems on a graph: (X, Y) and (time, price)? I need a label with coordinates (X,Y) that will always be at the minimum price on the chart.

Let me explain: we have a label with coordinates (x,y) (these are the same coordinates in the MT4 window). You need to set this label to the level of the minimum price in the chart (you can get it through WindowPriceMin() ). If the label will not appear at the price minimum (eg, after increasing the height of the indicator at the bottom of the screen), then set the required coordinates (x,y), so that it is at the price minimum.

The tricky part is linking the (x,y) and (time, price) coordinates to each other.

Maybe someone has done something similar?

Reason: