Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 26
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Indicator buffers, as in the future the solution will not only be used for straight lines, but also for moving average and other types of lines.
Maybe you can specify what you want to end up with
I want to measure the slope of the middle and display like -35 degrees
What is -35° on the graph? What if the scale changes?
Maybe you should specify what you want to end up with
In the example above, the line is drawn using the indicator buffer along the whole length of the history.
It should be limited only to the last 20 bars. I.e., when a new bar appears, the line is extended to the right and shortened to the left, so that its length is always equal to 20 bars.
I don't fully understand what I'm writing in the code, but I keep seeing the same number on the screen, although when I move the cursor to the line, I see the degrees change.
ObjectDelete("TremdLineAverage");
ObjectCreate("TremdLineAverage", OBJ_TRENDBYANGLE,0,0,0,0,0,0); // ------------------------- trendline 2 coordinates
ObjectSet ("TremdLineAverage", OBJPROP_WIDTH, HirinaUgolAverage); // ---------------------------------------- Width
ObjectSet ("TremdLineAverage", OBJPROP_COLOR, colUgolAverage); // --------------------------------------------- Color
ObjectSet ("TremdLineAverage", OBJPROP_TIME1 ,Time[1]); // ------------------------------- 1 time coordinate
ObjectSet ("TremdLineAverage", OBJPROP_TIME2 ,Time[0]); // ------------------------------- 1 time coordinate
ObjectSet ("TremdLineAverage", OBJPROP_PRICE1,UgolAverage1_1); // ----------------------------- 1 price coordinate
ObjectSet ("TremdLineAverage", OBJPROP_PRICE2,UgolAverage1_0); // ----------------------------- 2 price coordinate
ObjectSet ("TremdLineAverage", OBJPROP_RAY, 15); Ugol=15;
ObjectCreate("TremdLineAverage", OBJ_TRENDBYANGLE,0,0,0,0,0,0); // ------------------------- trendline 2 coordinates
ObjectSet ("TremdLineAverage", OBJPROP_WIDTH, HirinaUgolAverage); // ---------------------------------------- Width
ObjectSet ("TremdLineAverage", OBJPROP_COLOR, colUgolAverage); // --------------------------------------------- Color
ObjectSet ("TremdLineAverage", OBJPROP_TIME1 ,Time[1]); // ------------------------------- 1 time coordinate
ObjectSet ("TremdLineAverage", OBJPROP_TIME2 ,Time[0]); // ------------------------------- 1 time coordinate
ObjectSet ("TremdLineAverage", OBJPROP_PRICE1,UgolAverage1_1); // ----------------------------- 1 price coordinate
ObjectSet ("TremdLineAverage", OBJPROP_PRICE2,UgolAverage1_0); // ----------------------------- 2 price coordinate
ObjectSet ("TremdLineAverage", OBJPROP_ANGLE, 15); Ugol=15;
Thank you for your feedback.
A ready-made function, try it out.
The SetTLineByAngle() function.
This function sets the OBJ_TRENDBYANGLE object by the slope angle in the current chart.
cl - Color of the TRENDBYANGLE object. Required parameter.
nm - Object name. When the default value is passed - "", the open time of the current bar is used as the name.
t1 - First coordinate of object setting time. Default value - 0 - open time of the tenth bar.
p1 - First coordinate of object setting price. Default value - 0 - minimum of the tenth bar.
t2 - Second coordinate of object setting time. Default value - 0 - open time of the current bar.
p2 - Second coordinate of object setting price. This parameter is a kind of switch. Its non-zero value equates this function to SetTLine(), i.e. a trend line will be drawn using the time/price coordinate pair, while the value of the slope angle of the trend line will be ignored. Default value - 0 - trend line construction by slope angle.
an - Slope angle in degrees. Default value - 0 - Horizontal line.
ry - Flag of the BOW property. The default value is False.
st - Line style. Valid values are STYLE_SOLID (default), STYLE_DASH, STYLE_DOT, STYLE_DASHDOT.
wd - Line width. Default value is 1.