Hi
I am writing an indicator that draws lines on a separate window, also should draw arrows to indicator buy/sell on the main price chart.
So I write the following code, but it doesn't draw, any idea why please?
GoUp[i] = Low[i] - Range*0.75;
DrawBuyArrow(Time[i],GoUp[i],Red, STYLE_SOLID);
void DrawBuyArrow(datetime x1, double y1, color lineColor, double style)
{
string label = "CustomIndicator# " + DoubleToStr(x1, 0);
ObjectDelete(label);
ObjectCreate(label, OBJ_ARROW_BUY, 0, x1, y1);
ObjectSet(label, OBJPROP_COLOR, lineColor);
ObjectSet(label, OBJPROP_STYLE, style);
ObjectSet(label, OBJPROP_WIDTH, 1);
}
Have you added enough indicator buffers?
#property indicator_separate_window
#property indicator_buffers X?
are they having correct values in log print?
Have you added enough indicator buffers?
#property indicator_separate_window
#property indicator_buffers X?
are they having correct values in log print?
Do I need buffer for this?
I actually learn the code from this page.
https://docs.mql4.com/constants/objectconstants/enum_object/obj_arrow_buy
- docs.mql4.com
- When you post code please use the CODE button (Alt-S)!
(For large amounts of code, attach it.) Please edit your (original) post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - Your code sets GoUp[], but we don't know what that is (post all relevant code.) If it isn't a buffer, then you have array exceed and the indicator dies.
- You can create individual arrows (since you said your learning.) But for real code, you should make your buffer an arrow buffer and the terminal will draw them for you
SetIndexArrow - Custom Indicators - MQL4 Reference
- When you post code please use the CODE button (Alt-S)!
(For large amounts of code, attach it.) Please edit your (original) post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - Your code sets GoUp[], but we don't know what that is (post all relevant code.) If it isn't a buffer, then you have array exceed and the indicator dies.
- You can create individual arrows (since you said your learning.) But for real code, you should make your buffer an arrow buffer and the terminal will draw them for you
SetIndexArrow - Custom Indicators - MQL4 Reference
Hi Whroeder1
Thanks for giving me feedback.
1. I have changed the format.
2. GoUp is a buffer of type double, it is used in a for loop, the counter 'i' represents the index of the time bar, but I am not using it to draw, just for calculating the price and hence the drawing point.
3. I have done this exercise of using individual arrow. The reason I am using the create object is because I think it is a way to draw on the indicator_chart_window, while I can use SetIndexArrow to draw on indicator_separate_window.
So may I ask whether I can draw on two windows in the same indicator? e.g. on chart windows I draw arrows to show the buy/sell, and at the same time I can draw the indicator on the the separate window.
Many thanks
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I am writing an indicator that draws lines on a separate window, also should draw arrows to indicator buy/sell on the main price chart.
So I write the following code, but it doesn't draw, any idea why please?