I ploted some arrows in my MQL4 indicator so i am able to increase the width of the arrow but i want to increase the height of the arrow only so please help me.
The arrow symbols do not have separate adjust-ability in width and height, its just 'size'. An option would be to plot the arrow head, then draw a trend line object vertically above it to the length that you want.
MQL4 solution
Indicator can instruct an Arrow instance to have "bigger" size using OBJPROP_WIDTH instance attribute:
{ string anInterimObjNAME = "S" + sSellCntr;
ObjectCreate( anInterimObjNAME, OBJ_ARROW, 0, Time[0], Bid );
ObjectSet( anInterimObjNAME, OBJPROP_COLOR, Red );
if ( Action == 0 ) ObjectSet( anInterimObjNAME, OBJPROP_ARROWCODE, 1 );
if ( Action < 0 ) ObjectSet( anInterimObjNAME, OBJPROP_ARROWCODE, 5 );
ObjectSet( anInterimObjNAME, OBJPROP_WIDTH, 1 ); //<--
//ObjectSet( anInterimObjNAME, OBJPROP_WIDTH, 32 );//<--
}
New-MQL4 extension
Since Build 509+ there started to be new and new modifications of the MQL4 language syntax. So far, many times opening an integrated help system launches just another language update, so be carefull on coding limits, suddenly changed or unsupported syntax elements and even check several new syntax constructs. This is the life as it goes.
So, for the OBJ_ARROW, there is a possibility to extend it's size beyond a value of 5, which is ( as of Build 670 ) a limit for a manual GUI entry.
Help says:
Large arrows (more than 5) can only be created
by setting the appropriate OBJPROP_WIDTH property value
when writing a code in MetaEditor.
So, manually you still cannot enter more than 5, but via MQL4 code, you can go BIGGER :o)
Related
Is there a way in Vaadin 14 (or higher) to create what's called a "spectra" chart? Essentially, it's 99% identical to a "scatter" chart, except that a line is drawn from the point all the way down to the x-axis (please see figures 1 and 2 below which more or looks like a correct spectra chart.). I created a "hack" to achieve these quasi spectrum charts in Vaadin using "line charts" and by adding two "fake" points of intensity 0 to the left and to the right of my immediate point (as shown in code snippet below entitled "code snippet 1"). While my hack more-or-less works (pls see fig 1 image below), it causes a few problems: 1) it seems to make the lines appear more like bar-chart rectangles (please see fig 2) instead of points with narrow lines; 2) it seems to cause slight mistakes in the x-axis location. For example, in figure 2, the black line is to the left of the blue line; but in figure 3 (which is nothing more than the zoomed in perspective), it's to the right; and 3) it causes the x-axis to appear in the same color as the series, since my hack causes a line to appear to connect the fake right "0" of one point with the fake left "0" of the next point. (Plus, it means my chart has 3x the number of points than it needs to have, since I have two fake 0 points for every real point.)
Code snippet 1:
private void addTheSeries(DataSeries series, final float mz, final float intensity) {
//14.1.19
series.add(new DataSeriesItem(mz, 0));
series.add(new DataSeriesItem(mz, intensity));
series.add(new DataSeriesItem(mz, 0));
}
Figure 1:
Figure 2:
I'm using Vaadin 14.1.19 on Open jdk 11 and with Chrome on Chromebook as the browser.
I think it this case instead of using a Line type which is the default you'd benefit from using Column type. You can configure columns to be thin, configure zoomType and use axis configuration to get the extremes you want.
Chart chart = new Chart(ChartType.COLUMN);
Configuration configuration = chart.getConfiguration();
configuration.setTitle("Spectrum example");
configuration.getChart().setZoomType(Dimension.XY);
DataSeries series = new DataSeries();
series.add(new DataSeriesItem(120, 5));
series.add(new DataSeriesItem(180, 50));
series.add(new DataSeriesItem(290, 350));
series.add(new DataSeriesItem(420, 500));
series.add(new DataSeriesItem(740, 450));
PlotOptionsColumn options = new PlotOptionsColumn();
options.setPointWidth(1);
series.setPlotOptions(options);
configuration.addSeries(series);
YAxis y = configuration.getyAxis();
y.setTitle("");
configuration.getLegend().setEnabled(false);
add(chart);
Result looks like this:
And the width is kept after zooming in:
I know how to draw an object arrow on the chart, which I usually do like this:
ObjectCreate(0,"prevHigh",OBJ_ARROW_DOWN,0,Time[0],High[highestCandle]);
ObjectSetInteger(0, "prevHigh", OBJPROP_COLOR, clrRed);
Now I have an indicator which (I didn't code myself and is a .ex4 file which) draws up/down arrows on the chart as seen in the image (https://imgur.com/a/8yG0suw).
How can I when for example a Magenta down arrow has been drawn and the candle (index) at which it is drawn?
Please note that the arrows not in the list of objects on the chart
Q : "How can I recognise programmatically when an up/down arrow is drawn on a chart?"
Given the facts above, your test ought evaluate the moment the CustomIndicator ( via a published / used iCustom()-call signature ) by checking it as it goes from EMPTY_VALUE to any value != EMPTY_VALUE.
Given the CustomIndicator is a closed source ( *.ex4 ) you may need to check, if it did set its own ( hidden from our sight ) value, other than a current visible EMPTY_VALUE, yet this "re-calibration" will work, after you get a few manual tests of the CustomIndicator values for bars, that do not show any arrow - like for the 2020-Apr-08 09:30 et al v/s the displayed arrows are not the MQL4-Objects on their own, they are the closed-source CustomIndicator's SetIndexStyle() / SetIndexArrow() by-products, thus not inspectable either in the Object-List, or in the *.mq4 source-code.
Yet, detectable
I'm making a custom indicator.
I want to show theoretical brake out lines. So like, straight horizontal line segments. At the moment I have it working, using the semantics of DRAW_SECTION, except - obviously - all my segments are connected.
Is there a way to hide sections of the line that I don't need?
Or is there a better way to do it?
Two scenarios:
1.
SetIndexStyle( i, DRAW_NONE ); where i is the number of your buffer.
2.
#property indicator_buffers 3
IndicatorBuffers(4);
where
3 is a number of buffers to display,
4 is a total number of buffers. Even though you cannot see the buffer line on the chart, it is still accessed by iCustom( _Symbol, 0, indicator_name, ..., 3, shift );
where 3 is a zero-based reference to the buffer #4.
There is a way in MQL4 Indicators :
As documented, there is a special value == EMPTY_VALUE to serve exactly this purpose.
The EMPTY_VALUE constant usually corresponds to the values of indicators that are not shown in the chart.
Just assign, where plausible in your indicator code - either per-bar in assignment BreakOutBUFFER[i] = ( isHereBreakOut( i ) ) ? aLevel : EMPTY_VALUE;
or
by a pre-initialised ArrayInitialize( BreakOutBUFFER, EMPTY_VALUE ); and re-assigning only those cells, where your BreakOut-logic is POSACK'd, yet this is not a preferred way, as the first sooner-or-later coming ( automatic or not ) ArrayResize() will extend this Buffer, as documented:
... the elements will be added at the end of the array, their values will be undefined and in most cases will not be equal to init_value.
but .... not with the pre-set EMPTY_VALUE initialiser...
My option is, obviously, to go the former way
Introduction
I am using the TChart component and am finding the options rather confusing and hard to find what I need.
The Left Axis of the chart has a minimum of 0 and a maximum of 5000, the Bottom Axis has a minimum of 0 and a maximum of 52 (weeks in a year).
In my chart I have 2 series that are populated based on values from a record I have created which can be edited at runtime, everything is working good so far.
Problem
Take a look at the below image of part of the chart filled with some random values:
I am not sure if such an option exists or not, but notice from week 4 onwards where no values have been added there is a solid red line.
I don't want the chart to plot values that are less than 0, so in this example from week 4 onwards there should be no more lines (I can confirm that from week 4 onwards I have the values set at -1)
Week 1 to 4 does not show this bottom red line, obviously because the values are greater than 0 and are therefore plotted above the line, but this should make my problem a bit more clearer.
So, how do I prevent the chart from plotting / drawing values that are less than 0, importantly for the Bottom Axis of the chart?
I am sure there must be a simple option somewhere, I just cannot find it if there is one as I am not too familiar with the TChart Component.
You have the possibility when adding values to a series to add them as null.
This will prevent them from showing.
Ken is correct saying that a tricky situation is to handle a single value surrounded by null values.
Picking another series type than FastLine and show dots as well as lines might work better.
For a FastLine series to show gaps, set:
Series1.IgnoreNulls := False;
And to discriminate values below zero:
if (y < 0) then
Series1.AddNullXY(x, y, '')
else
Series1.AddXY(x, y, '');
if y < 0 then
LineSeries1.AddXY(x, y, '', clNone)
else
LineSeries1.AddXY(x, y, '', clRed);
Can anyone help me understand why the displayed labels for a TListView are truncated with an ellipsis at program startup, but are completely displayed after switching to vsIcon and back
again? I don't want any truncation or ellipse...
Edit 1: Columns[0].AutoSize is TRUE, MaxWidth is 50, Width is 50.
Edit 2: Left hand screen capture corrected so source text is the same as the right side's.
TIA
Assuming you are using ViewStyle=vsReport, make sure you have a column defined whose Width is large enough to accomodate your longest text value. TListColumn.AutoSize does not always work correctly, especially when the Listview is intially loaded.
Peter Below posted an answer on the Embarcadero forum (https://forums.embarcadero.com/thread.jspa?threadID=45670&tstart=0) pointing to an identical question asked a year ago here: https://forums.embarcadero.com/thread.jspa?threadID=27079.
Synopsis is to manually set the column width:
Uses CommCtrl;
ListView_SetColumnWidth( listview.handle, 0, NewWidthOfColumnInPixels );