-
Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
No free help (2017)Or pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum (2018)We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
No free help (2017) - Perhaps you should read the manual. ObjectGetValueByTime - Object Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
I would do it like this but I only coded EA that I don't know how to handle the visual effect. So you may need to search the api yourself.
1.count the bar difference between two bars
2. Divide the price difference by the bar difference count so that you get the approximate increment of each bar
3. Thus you could get the trendline value on each bar.
4. Store the last Ask or Bid price, and compare the last Ask or Bid price with the trendline value, and the current Ask or Bid price with the trendline value.
5. If the last Ask/Bid value is smaller than the trendline value and the current one is larger than the trendline value, or vice versa. Then it's a cross and you could use the value in your popup.
I would do it like this but I only coded EA that I don't know how to handle the visual effect. So you may need to search the api yourself.
1.count the bar difference between two bars
2. Divide the price difference by the bar difference count so that you get the approximate increment of each bar
3. Thus you could get the trendline value on each bar.
4. Store the last Ask or Bid price, and compare the last Ask or Bid price with the trendline value, and the current Ask or Bid price with the trendline value.
5. If the last Ask/Bid value is smaller than the trendline value and the current one is larger than the trendline value, or vice versa. Then it's a cross and you could use the value in your popup.
My major problem is getting the trendline values "
If the last Ask/Bid value is smaller than the trendline value and the current one is larger than the trendline value, or vice versa."-
Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
No free help (2017)Or pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum (2018)We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
No free help (2017) - Perhaps you should read the manual. ObjectGetValueByTime - Object Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
Ok but i don't if am wrong, this line of code should store the trendline prices
int TrendPrices = ObjectGetInteger(0,"SimpleLowTrendLine",OBJPROP_PRICE_SCALE,true);
Now how will i extract the prices so that i can access them as arrays
My major problem is getting the trendline values "
If the last Ask/Bid value is smaller than the trendline value and the current one is larger than the trendline value, or vice versa."Step 1-3 is how I would do to get the trendline value on each bar. You may not easily get the bar count from API calls. You may use Low[y] and Low[x] if you draw the line using lows.
I am not sure if you could get the total bar counts on both Low[y] and Low[x] so that you could get both bars difference and the price difference to get the increment of the trendline value on each bar. I never tried that in my codes.
Forum on trading, automated trading systems and testing trading strategies
Fernando Carreiro, 2022.04.25 01:13
No! Do you even understand what the ObjectGetValueByShif() does?
The function, does exactly the same thing as the "y=mx+c" equation. It calculates the price for the bars either inside or outside of the two connecting points of the trend-line.
Here is an example code of a Script, to demonstrate the two methods, that has been fully tested with log results:
#property strict #property script_show_inputs // Script input parameters input uint nStartPointBarShift = 5, // Bar shift of starting point of trend-line nEndPointBarShift = 15, // Bar shift of ending point of trend-line nQueryPointBarShift = 10; // Bar shift of query point of trend-line // Script start event handler void OnStart() { // Check if parameters are acceptable if( nStartPointBarShift == nEndPointBarShift ) { Print( "Invalid Parameters!" ); return; }; // Calculate values int nDeltaBarShift = (int) nEndPointBarShift - (int) nStartPointBarShift; // Change in bar shift datetime dtStartPointTime = iTime( _Symbol, _Period, nStartPointBarShift ), // Time at starting point dtEndPointTime = iTime( _Symbol, _Period, nEndPointBarShift ); // Time at ending point double dbStartPointPrice = iClose( _Symbol, _Period, nStartPointBarShift ), // Price at starting point dbEndPointPrice = iClose( _Symbol, _Period, nEndPointBarShift ), // Price at ending point dbDeltaPrice = dbEndPointPrice - dbStartPointPrice, // Change in price dbLineSlope = dbDeltaPrice / nDeltaBarShift, // Slope is the value of "m" dbOffset = dbEndPointPrice - dbLineSlope * nEndPointBarShift; // Offset is the value of "c" // Draw trend-line object string sObjectName = "Test-Trendline"; if( ObjectCreate( sObjectName, OBJ_TREND, 0, // Create trend-line object dtStartPointTime, dbStartPointPrice, // Starting point of trend-line dtEndPointTime, dbEndPointPrice ) ) // Ending point of trend-line { // Get price by both methods double dbValueByShift = ObjectGetValueByShift( sObjectName, nQueryPointBarShift ), dbPriceByShift = dbLineSlope * nQueryPointBarShift + dbOffset; // Print out the values to the log PrintFormat( "Starting Point: %s @ %d", DoubleToString( dbStartPointPrice, _Digits ), nStartPointBarShift ); PrintFormat( "Ending Point: %s @ %d", DoubleToString( dbEndPointPrice, _Digits ), nEndPointBarShift ); PrintFormat( "Query Point: %s @ %d (by ObjectGetValueByShift)", DoubleToString( dbValueByShift, _Digits ), nQueryPointBarShift ); PrintFormat( "Query Point: %s @ %d (by y=mx+c calculation)", DoubleToString( dbPriceByShift, _Digits ), nQueryPointBarShift ); // Delete Object ObjectDelete( sObjectName ); // Delete trend-line object }; };2022.04.25 00:07:12.139 Compiling '(Test)\TestTrendlineValue' 2022.04.25 00:07:53.150 Script (Test)\TestTrendlineValue EURUSD,H1: loaded successfully 2022.04.25 00:07:56.080 TestTrendlineValue EURUSD,H1 inputs: nStartPointBarShift=5; nEndPointBarShift=15; nQueryPointBarShift=10; 2022.04.25 00:07:56.111 TestTrendlineValue EURUSD,H1: initialized 2022.04.25 00:07:56.111 TestTrendlineValue EURUSD,H1: Starting Point: 1.07855 @ 5 2022.04.25 00:07:56.111 TestTrendlineValue EURUSD,H1: Ending Point: 1.07973 @ 15 2022.04.25 00:07:56.111 TestTrendlineValue EURUSD,H1: Query Point: 1.07914 @ 10 (by ObjectGetValueByShift) 2022.04.25 00:07:56.111 TestTrendlineValue EURUSD,H1: Query Point: 1.07914 @ 10 (by y=mx+c calculation) 2022.04.25 00:07:56.111 TestTrendlineValue EURUSD,H1: uninit reason 0 2022.04.25 00:07:56.111 Script TestTrendlineValue EURUSD,H1: removed

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Please i need help, i have a simple trendline that draws a line from lowest low at a point to the current low of the most recent candle.
So what i want is to get price of the trendline at any given candlestick, for example let say my trendline crosses at the center of a candlestick i want to be able to get the price at that point.
This is code so far
I attach an image below, from the image how can i get the price in that popup on the trendline.