Pinescript Conditional Inputs - algorithmic-trading

In Tradingview pinescript, is there any way to make conditional inputs? Let's say I have 3 categories and each category has 3 different options:
CATEGORY1: AAA, BBB, CCC
CATEGORY2: DDD, EEE, FFF
CATEGORY3: GGG, HHH, III
The code below creates 3 input fields for the same variable 'selectoption' in the form after adding to chart:
selectcategory = input(title="Select Category", defval="CATEGORY1", options=["CATEGORY1", "CATEGORY2", CATEGORY3"])
if selectcategory == "CATEGORY1"
selectoption = input(defval="AAA", title="Select Option", options=["AAA", "BBB", "CCC"])
else
if selectcategory == "CATEGORY2"
selectoption = input(defval="DDD", title="Select Option", options=["DDD", "EEE", "FFF"])
else
if selectcategory == "CATEGORY3"
selectoption = input(defval="GGG", title="Select Option", options=["GGG", "HHH", "III"])
What I intend to do is to have a single field for 'Select Category' and another single field for "Select Option" in the form when the strategy is added to chart. The option list in the'Select Option' will update depending on the selected category in the "Select Category' field.
e.g. if I select CATEGORY1, the 'Select Option' field will show AAA, BBB, CCC as options; if I select CATEGORY2, the 'Select Option' field will show DDD, EEE, FFF.
I would appreciate any help or advice on this. Thanks!

There is not yet such a feature, but it's requested for future development.

Related

finding tables and columns used in oracle sql view

Is there any easy way to find the tables and columns used to create a view ?
i opened all the views and tried to find the tables and column used in it, but I feel I might have missed something. Is there any commands that displays all the columns and tables used in a view ?
Open the view.
Open the Dependencies panel.
There's my list of tables.
Or...that's right, you wanted COLUMNS as well.
Do a SELECT * FROM for your view in the SQL Worksheet. Mouse over the SELECT keyword.
This invokes the SQL Text Expansion feature in the database. Note that if your underlying SQL includes wildcards, generating the DDL won't help you with column names.
If I click on the text of the view source after the mouse-over, you'll get the actual SQL in your worksheet.
For example this is what I get for 'SELECT * FROM EMP_DETAILS_VIEW'
SELECT "A1"."EMPLOYEE_ID" "EMPLOYEE_ID",
"A1"."JOB_ID" "JOB_ID",
"A1"."MANAGER_ID" "MANAGER_ID",
"A1"."DEPARTMENT_ID" "DEPARTMENT_ID",
"A1"."LOCATION_ID" "LOCATION_ID",
"A1"."COUNTRY_ID" "COUNTRY_ID",
"A1"."FIRST_NAME" "FIRST_NAME",
"A1"."LAST_NAME" "LAST_NAME",
"A1"."SALARY" "SALARY",
"A1"."COMMISSION_PCT" "COMMISSION_PCT",
"A1"."DEPARTMENT_NAME" "DEPARTMENT_NAME",
"A1"."JOB_TITLE" "JOB_TITLE",
"A1"."CITY" "CITY",
"A1"."STATE_PROVINCE" "STATE_PROVINCE",
"A1"."COUNTRY_NAME" "COUNTRY_NAME",
"A1"."REGION_NAME" "REGION_NAME"
FROM (
SELECT "A7"."EMPLOYEE_ID" "EMPLOYEE_ID",
"A7"."JOB_ID" "JOB_ID",
"A7"."MANAGER_ID" "MANAGER_ID",
"A7"."DEPARTMENT_ID" "DEPARTMENT_ID",
"A6"."LOCATION_ID" "LOCATION_ID",
"A4"."COUNTRY_ID" "COUNTRY_ID",
"A7"."FIRST_NAME" "FIRST_NAME",
"A7"."LAST_NAME" "LAST_NAME",
"A7"."SALARY" "SALARY",
"A7"."COMMISSION_PCT" "COMMISSION_PCT",
"A6"."DEPARTMENT_NAME" "DEPARTMENT_NAME",
"A5"."JOB_TITLE" "JOB_TITLE",
"A4"."CITY" "CITY",
"A4"."STATE_PROVINCE" "STATE_PROVINCE",
"A3"."COUNTRY_NAME" "COUNTRY_NAME",
"A2"."REGION_NAME" "REGION_NAME"
FROM "HR"."EMPLOYEES" "A7",
"HR"."DEPARTMENTS" "A6",
"HR"."JOBS" "A5",
"HR"."LOCATIONS" "A4",
"HR"."COUNTRIES" "A3",
"HR"."REGIONS" "A2"
WHERE "A7"."DEPARTMENT_ID" = "A6"."DEPARTMENT_ID"
AND "A6"."LOCATION_ID" = "A4"."LOCATION_ID"
AND "A4"."COUNTRY_ID" = "A3"."COUNTRY_ID"
AND "A3"."REGION_ID" = "A2"."REGION_ID"
AND "A5"."JOB_ID" = "A7"."JOB_ID"
) "A1";
select * from all_dependencies where type = 'VIEW' and name = :your_view

Tarantool - Named fields?

Is there any way to name fields similar to columns in SQL?
The idea is that I might want to insert a customer record with:
- Name
- Phone
- Email
- Website
some fields might be present sometimes, other not, and they might be presented in different order.
Is there any other way to insert the records into a tuple referencing them by field name?
Something in pseudocode like:
s:insert(1, "name": "foo name", "phone": "foo phone")
s:insert(2, "phone": "bar phone", "name": "bar name", "email": "bar email")
You can assign field names using not yet documented space:format() function when you define schema for a space, afterwards and you can use these names for index definitions. [available in Tarantool 1.7+]
Sample code:
box.once("testapp:schema:1", function()
local customer = box.schema.space.create('customer')
customer:format({
{'customer_id', 'unsigned'},
{'name', 'string'},
})
customer:create_index('customer_id', {parts = {'customer_id'}})
local account = box.schema.space.create('account')
account:format({
{'account_id', 'unsigned'},
{'customer_id', 'unsigned'},
{'balance', 'unsigned'},
{'name', 'string'},
})
account:create_index('account_id', {parts = {'account_id'}})
account:create_index('customer_id', {parts = {'customer_id'}, unique = false})
box.snapshot()
end)
Unfortunately, you can't use field names in space:insert() or similar functions.

power query how to extract data from text file

I have a text file - in fact a report - that has several pages, each page having a header and a footer. The header has a string that indicates the topic covered in the body of the page. I would like to extract the body of the pages that relate to a specific topic. Headers and Footers have the same number of lines, and body has the same structure as shown in an example at the bottom of the note. How to extract the information about claims type BBB only ?
The number of rows to skip at the top of the report is unknown, as well as the number of rows to drop at the bottom of the report. Could somebody point me in the right direction ? Thank you.
Page 1
Claims type: AAA
Claim # Amount $
11111 10
11112 20
.....
End of Page 1
Page 2
Claims type : AAA
...etc.
End of Page 2
Page 3
Claims type : BBB
Claim # Amount $
21111 100
21112 200
.....
End of Page 3
Page 4
Claims type : CCC
You Can do it with UI only:
let
Source= Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
AddCustom = Table.AddColumn(Source, "Custom", each if Text.Start([Column1],6)="Claims" then Text.End([Column1],3) else if Text.Start([Column1],6)="End of" then "Trash" else null),
ReplErrs = Table.ReplaceErrorValues(AddCustom, {{"Custom", null}}),
FillDown = Table.FillDown(ReplErrs,{"Custom"}),
FilterBBB = Table.SelectRows(FillDown, each ([Custom] = "BBB")),
Rem1st = Table.Skip(FilterBBB,1),
Promoted = Table.PromoteHeaders(Rem1st)
in
Promoted
I don't think there's a way to do this purely through the UI. You'll want to use the Table.PositionOf and List.PositionOf methods.
Here is what I have:
let
Source = Table // however you get the table
#"Position of Claims" = Table.PositionOf(Source, [Column1 = "Claims type : BBB", Column2 = null]),
// Remove entries above the table belonging to Claims type BBB.
#"Remove Top Rows" = Table.Skip(Source, #"Position of Claims" + 2),
// Check which column has the "End of Page" tag
#"Added Custom" = Table.AddColumn(#"Remove Top Rows", "Custom", each if [Column1] is text and Text.StartsWith([Column1], "End of Page") then 1 else 0),
#"Position of End of Page" = List.PositionOf(#"Added Custom"[Custom], 1),
// Remove rows that don't belong to this page's table
#"Remove Bottom Rows" = Table.FirstN(#"Added Custom", #"Position of End of Page"),
// Remove the column that told us which row had End of Page on it
#"Removed Columns" = Table.RemoveColumns(#"Remove Bottom Rows",{"Custom"})
in
#"Removed Columns"`

how to insert an array of id's into linq-to-sql query line in .net mvc 3

i want to get an array of id's which is like ["15", "26", "37", "48", "90"] and i want to get my remaining items from my remaining table that doesnt includes these supplier id's..
here what i done so far:
string[] arrgroupdetails;
arrgroupdetails = dataContext.GroupDetails.Select(c => c.supplier_id).ToArray();
var items = from thingies in dataContext.remainings where thingies.supplier_id.ToString() != arrgroupdetails.Any().ToString() select thingies;
so how can i achive this?
By heart, so do check syntax but someething like this should work:
var items = from thingies in dataContext.remainings
where !arrgroupdetails.Contains(thingies.supplier_id.ToString())
select thingies;

How to find records that have duplicate data using Active Record

What is the best way to find records with duplicate values in a column using ruby and the new Activerecord?
Translating #TuteC into ActiveRecord:
sql = 'SELECT id,
COUNT(id) as quantity
FROM types
GROUP BY name
HAVING quantity > 1'
#=>
Type.select("id, count(id) as quantity")
.group(:name)
.having("quantity > 1")
Here's how I solved it with the AREL helpers, and no custom SQL:
Person.select("COUNT(last_name) as total, last_name")
.group(:last_name)
.having("COUNT(last_name) > 1")
.order(:last_name)
.map{|p| {p.last_name => p.total} }
Really, it's just a nicer way to write the SQL. This finds all records that have duplicate last_name values, and tells you how many and what the last names are in a nice hash.
I was beating my head against this problem with a 2016 stack (Rails 4.2, Ruby 2.2), and got what I wanted with this:
> Model.select([:thing]).group(:thing).having("count(thing) > 1").all.size
=> {"name1"=>5, "name2"=>4, "name3"=>3, "name4"=>2, "name5"=>2}
With custom SQL, this finds types with same values for name:
sql = 'SELECT id, COUNT(id) as quantity FROM types
GROUP BY name HAVING quantity > 1'
repeated = ActiveRecord::Base.connection.execute(sql)
In Rails 2.x, select is a private method of AR class. Just use find():
klass.find(:all,
:select => "id, count(the_col) as num",
:conditions => ["extra conditions here"],
:group => 'the_col',
:having => "num > 1")
Here is a solution that extends the other answers to show how to find and iterate through the records grouped by the duplicate field:
duplicate_values = Model.group(:field).having(Model.arel_table[:field].count.gt(1)).count.keys
Model.where(field: duplicate_values).group_by(&:field).each do |value, records|
puts "The records with ids #{records.map(&:id).to_sentence} have field set to #{value}"
end
It seems a shame this has to be done with two queries but this answer confirms this approach.

Resources