pine script with two indicators one overlaid on the chart and another on its own? - moving-average

I am trying to write a pine script with two indicators one overlaid on the chart (EMA) and another on its own?(Stoch) I cannot seem to find any info on how to separate these (Visually) but keep them within 1 pine script, ie to be able to take trading decisions based on these.

The earlier answer from Luc is right, unfortunately. Each script can either create plots that are overlaid on the default price chart, or shown in a different pane, but not both. But there is a workaround.
Suppose you've made some non-trivial calculation in your script and you'd like to put it in different pane. E.g. the next code:
//#version=4
study(title="Stochastic", shorttitle="Stoch", format=format.price, precision=2)
periodK = input(14, title="K", minval=1)
periodD = input(3, title="D", minval=1)
smoothK = input(3, title="Smooth", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)
plot(k, title="%K", color=color.blue)
plot(d, title="%D", color=color.orange)
h0 = hline(80)
h1 = hline(20)
fill(h0, h1, color=color.purple, transp=75)
// This next plot would work best in a separate pane
someNonTrivialCalculatedSeries = close
plot(ema(someNonTrivialCalculatedSeries, 25), title="Exporting Plot")
Because they have different scale, one of them most likely will break another indicator's scale.
So you'd like show Stoch in different pine, whereas ema() should be overlayed with the main chart. For that you should make the next steps:
Turn off in the study's the extra plot to return scale to normal:
Apply to the chart the next script:
//#version=4
study("NonOverlayIndicator", overlay=true)
src = input(defval=close, type=input.source)
plot(src)
Choose in the second's script inputs source required plot from the first script:
And voilĂ  - you got the plots in different pines:
But if you want split the plots because you have retrictions on amount of studies you allowed to apply (e.g. 3 for free-account) - that won't help you.

It cannot be done. A script runs either in overlay=true mode on the chart, in which case it cannot direct plots elsewhere, or in a separate pane when overlay=false (the default).
When the script is running in a pane, it can change the color of the chart bars using barcolor(), but that's the only way it can modify the chart.
It is possible to rescale signals so that multiple bounded (e.g., 0-100, -1 to +1) signals generated by one script appear one on top of the other, but this is typically impossible in overlay mode, as the vertical scale varies with the bars on the chart. The only way for an overlay script to work with its own scale is when it uses No scale, but this prevents the indicator's plots to plot relative to price, and so the chart's bars.

Nice workaround from Michael.
Unfortunately, this only seems to work to pass data for one plot.
I would like to pass data for 3 different plots to the stock price graph.
If I try this, for 'input.source' I can only select the standard sources: "open, high, low, close ...". I can not select the data from other indicators.
If I remove plots 2 and 3, it works as Michael described.
Anybody has a workaround for the workaround..? ;-)

Related

Remove black values in a modis merge image

the following image shows my actuall result of a merged modis image.
I used pyhdf.SD to open and manipulate and plot the data in a loop. It started on the right upper corner.
The plot is ok... put on some areas overlaped. The easiest way is to remove the black borders.
I wanted to use this:
np.ma.masked_where(rgb_projected==0.,rgb_projected)
rgb_projected is the original rgb matix.
rgb_projected = np.zeros((1000, 1000,3))
rgb_projected[:,:,0] = z_01[:,:]
rgb_projected[:,:,1] = z_02[:,:]
rgb_projected[:,:,2] = z_03[:,:]
rgb_projected.shape
whereAreNaNs = np.isnan(rgb_projected);
rgb_projected[whereAreNaNs] = 0.;
rgb_plot=np.ma.masked_where(rgb_projected==0.,rgb_projected)
The interesting thing is, that everything is True although the first valueas are 0.
Any ideas?

How to display more than one image dynamically with python (pyqt5)?

I'm using python to build an application by PyQt5, the main idea is to display images from a directory and for each image some masks show up next to it to select one of them (i.e. for each image there are different number of masks). So, I want to display these masks in a "container" that can handle this dynamically.
I tried QlistWidget in a scroll area and the masks are displayed as icons in it, but I want to use something else to handle them easier and retrieve any mask as Qpixmap or QImage to use it in another operations without convert it multiple times (which slows down the program)
this is the part that displays the masks (this is the only way that worked with me)
for ann in annotations:
mask = self.coco.annToMask(ann)
mask_img = Image.fromarray((mask*255).astype(np.uint8))
qt_img = ImageQt.ImageQt(mask_img) # convert Image to ImageQt
icon = QtGui.QIcon(QtGui.QPixmap.fromImage(qt_img))
item = QtWidgets.QListWidgetItem(icon, f"{annIndex}")
self.listWidget.addItem(item)
annIndex += 1

WSO2: Dashboard Issues and Personalization

I am using wso2cep dashboard for displaying network traffic related information by exploiting various graphs. I was wondering if there is any way I can customize legend for each type of graph or set it globally as its create confusion for the viewer, elaborated in screen shot.
In piechart others = blue
In dest port vs src ip other = orange
One thing more
Scatter plot is shifted to left side of the window cutting ips on the y-axis and there is a space left on right side which can be used.
How can I drag the chart towards right side?
And also scatter chart is not rendering multiple y-axis values against single x-axis value. Here is the screen shot for that and values against it is plotted.
source_ip, source_port, destination_ip, destination_port, protocol
192.168.227.102,123,192.168.227.101,21,ftp
192.168.227.102,101,192.168.227.101,21,ftp
192.168.227.105,445,192.168.227.101,21,ftp
192.168.227.105,123,192.168.227.101,21,ftp
192.168.227.105,65576,192.168.227.101,22,ssh
192.168.227.109,123,192.168.227.101,22,ssh
192.168.227.109,123,192.168.227.101,22,ssh
192.168.227.109,3345,192.168.227.101,22,ssh
192.168.227.233,123,192.168.227.101,445,smb
192.168.227.233,123,192.168.227.101,445,smb
192.168.227.233,111,192.168.227.101,445,smb
192.168.227.202,123,192.168.227.101,3302,smtp
192.168.227.202,233,192.168.227.101,3302,smtp
192.168.227.102,123,192.168.227.101,3302,smtp
192.168.227.102,123,192.168.227.101,25,sql
192.168.227.102,123,192.168.227.101,25,sql
This is happening because generated gadgets are deciding the the color scale and domain dynamically based on the data that has been passed to chart.
If you want to explicitly specify the color domain and color scale you can configure those in generated gadgets by modifying the VizGrammar (which is the chart library used) configuration of the charts.
This can be done by changing chart api js file, there will be a config creation like this [1] and there add colorDomain for you predefined options like below. Then the domain will be defined statically without dynamically changing the order and the colors has to be constant
conf.colorDomain = ["MySQL","SMB","OTHER"]
Even you can define your own colors to
[1] https://github.com/wso2/carbon-analytics-common/blob/master/features/analytics-gadget-templates/org.wso2.carbon.analytics.gadget.chart.template.feature/src/main/charts/line-chart/api.js#L116

How to create json rectangle data from a Photoshop script

I have a photoshop script that is cutting up layers of a PSD file into tiles (it's for a parallax game engine). This works well, but now I want to be able to create regions (rectangles) in the PSD that can be detected by the script and exported as json data.
Can anyone suggest a good way in Photoshop to a) visually create this information in the PSD and b) the script that would write out this data?
Any help would be greatly appreciated - this would remove about 3 manual, error prone steps from our current process if we can solve it...
If it's just rectangles that will hold the data for you then that's easy. You can just create a layer with a unique name, select the area that you need the data for, fill that with a single colour - say bright orange or something that will stand out. So now you have a layer with your region data. In your script get the layer by name
app.documents.getByName("Data_for_Region_1");
...and then you can then export that layer's data (co-ordinates - presumably) as a JSON file with layer bounds.
var x = parseFloat(app.activeDocument;.activeLayer.bounds[0])
var y = parseFloat(app.activeDocument;.activeLayer.bounds[1])
var x1 = parseFloat(app.activeDocument;.activeLayer.bounds[2])
var y1 = parseFloat(app.activeDocument;.activeLayer.bounds[3])
Hope this helps

Legend options in Stata graphs

http://imageshack.us/photo/my-images/339/41988730.jpg/
I'm trying to figure out how to tweak the options for the legend in this graph (see link above). Specifically I'd like the new = part of the label to disappear. Next to each line I'd like just the name of the company. I'm using the xtline command to generate the graph. Each line on the graph should represent a distinct value of the variable "company" (there should be 11 distinct values).
xtline revenue, overlay t(week_name) i(company)
Thanks!
Use the label() sub-option of the legend() option. Here's the example on p. 474 of the Stata 12 manual:
line le_m le_f year, legend(label(1 "Males") label(2 "Females"))
You can also use the order() sub-option to order the legend entries according to the order of the curves on the graph. Type "help graph legend" for more information and links to the Manual.
However I don't find legends with so many entries to be helpful. You'd have a more readable plot if you specify "legend(off)"; "yscale(log)"; and add the appropriate label next to each curve with the Graph Editor.