why tradingview pine editor showing this error "Undeclared identifier 'period'" - editor

I am trying to create an indicator where I want the current price of the script and for that, I want to use tickerid and security()
this is my code
// © Tiger2dec
//#version=4
strategy("suresh banknifty", overlay=true)
src = input(close, title="Source")
// current volume
cvolume= volume
//vwap
close1=close
vwap1=vwap(close1)
plot(vwap1)
//rsi
rsi=rsi(close,14)
//current price
price = security(syminfo.tickerid, period, src)
longCondition = cvolume>50000 and rsi>50
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
shortCondition = crossunder(sma(close, 14), sma(close, 28))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)```
but its showing error `Save operation failed, reason: line 19: Undeclared identifier 'period'`

Use Period like this
price = security(syminfo.tickerid, timeframe.period, src)
plot(price)
price = security(syminfo.tickerid, timeframe.period, src)
plot(price)

Related

Trying to use add = True and I get an error message

I am Trying to use add = True and I get an error message. How can I do it?
This is my code
quadratcount(schools.pp)
plot(schools.sp, col = "red")
plot(quadratcount(schools.pp), add= T)`
and this is the error message I get
Error in (function (x, y = NULL, density = NULL, angle = 45, border = NULL, : plot.new has not been called yet
Looks like you made a simple typo: In the first plot command you write plot(schools.sp, col = "red"), where you probably meant plot(schools.pp, col = "red"). For future questions please provide a reproducible example where we can run each line including library(spatstat) and the definition of schools.pp etc. If you can't share your data just either:
use the first few points of your data
use a built-in dataset
generate artificial data

how to display symbol of currency according to country

I have a sheet below in which I would like to display the symbol of currency according to region selected in column C. If we select America, the symbol of dollar must appear before the cost in B column, like when we select Europe, the symbol of euro must appear before the cost in column B.
https://docs.google.com/spreadsheets/d/1dlfXRcSDy7XhQmRuVa3dEmx6zjHukOlOoRp5V-Em1c0/edit#gid=0
You can use VLOOKUP or CONCATENATE whatever you want, the symbol must appear before the price.
Thanks in advance
I created a onEdit script for you. Try it our for yourself. I added some comment if you want to change the sheetname / column to check. Hope that this fits your needs.
Go to tools -> Script editor
Choose setNumberFormat from the dropdown and run it with the little play button. Give premission.
(maybee repeate 2 with the onEdit from the dropdown.)
Close. And now you should have a working script.
The Script for others
function onEdit(){
const ss = SpreadsheetApp.getActiveSpreadsheet();
//Change sheet name to check
const sheet = "Purchase Sheet";
const activeSheet = ss.getActiveSheet().getName();
const cell = ss.getActiveSheet().getActiveCell();
// 3 = column c. So change this to you needs
if (activeSheet == sheet && cell.getColumn() == 27){
console.log("True");
setNumberFormat();
}
}
function setNumberFormat() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const cell = ss.getActiveSheet().getActiveCell();
let numberFormat = "";
//With this as example, you can extend to your needs.
switch (cell.getValue()) {
case "AMERICA":
numberFormat = "$#,##0.00";
break;
case "EUROPE":
numberFormat = "€#,##0.00";
break;
}
cell.offset(0, -21).setNumberFormat(numberFormat);
}

AddDataField function fails with Microsoft.Office.Interop.Excel

I am trying to recreate VBA code in C# to generate a pivot table
The VBA code is
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:= xlDatabase, SourceData:= _
"Sheet1!R1C1:R6C4", Version:= 6).CreatePivotTable TableDestination:= _
"Sheet2!R3C1", TableName:= "PivotTable1", DefaultVersion:= 6
Sheets("Sheet2").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("First Name")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables(_
"PivotTable1").PivotFields("Salary"), "Sum of Salary", xlSum
using Excel = Microsoft.Office.Interop.Excel;
...
//Start of pivot code
workbook.Worksheets.Add();
//ideally would want a "used range" here not specific cell addresses Sheet1!R1C1:R6C4
pivotcache = (Excel.PivotCache)excel.ActiveWorkbook.PivotCaches().Create(Excel.XlPivotTableSourceType.xlDatabase, "Sheet1!R1C1:R6C4", 6); // Const xlDatabase = 1 Member of Excel.XlPivotTableSourceType
pivot = pivotcache.CreatePivotTable("Sheet2!R3C1", "PivotTable1", 6);
sheet = (Excel.Worksheet) workbook.Worksheets["Sheet2"];
range = sheet.get_Range("A3");
range.Select();
pf = pivot.PivotFields("First Name");
pf.Orientation=XlPivotFieldOrientation.xlRowField; //1=xlrowfield
pf.Position = 1;
//*****Code fails here ***
df = pivot.AddDataField(pivot.PivotFields("Salary"), "Sum of Salary", XlConsolidationFunction.xlSum); //Const xlSum = -4157 (&HFFFFEFC3) Member of Excel.XlConsolidationFunction
The last line fails with console error message: Error: Operation is not supported on this platform. Line: System.Private.CoreLib
Can anyone give me some pointers?
Disaggregating the code and adding orientation xlDataField like this worked
df = pivot.PivotFields("Salary");
df.Orientation = XlPivotFieldOrientation.xlDataField;
df.Function = Excel.XlConsolidationFunction.xlSum;
df.Caption = "Sum of Salary";

LSXLC ODBC Stored Procedure

I'm trying to connect to an Oracle RDB database using LSXLC (ODBC Connector).
But when it comes to stored procedures I'm having a hard time getting it to work.
The code below always results in "Error: Parameter name not supplied: fnl_date, Connector 'odbc2', Method -Call-". The error is triggered on "count = connection.Call(input, 1, result)"
Can anyone tell me what I'm doing wrong?
Public Function testLsxlcProc()
On Error GoTo handleError
Dim connection As LCConnection("odbc2")
connection.Server = "source"
connection.Userid = "userid"
connection.Password = "password"
connection.procedure = "proc_name"
connection.Connect
If connection.IsConnected Then
Dim input As New LCFieldList()
Dim result As New LCFieldList()
Dim break As LCField
Set break = input.Append("fnl_date", LCTYPE_TEXT)
break.Text = "2014-07-01"
Dim agrNo As LCField
Set agrNo = input.Append("fnl_agreement_no", LCTYPE_TEXT)
agrNo.Text = "123456"
Dim curr As LCField
Set curr = input.Append("fnl_currency_code", LCTYPE_TEXT)
curr.Text = "SEK"
Dim stock As LCField
Set stock = input.Append("fnl_stock_id", LCTYPE_TEXT)
stock.Text = "01"
connection.Fieldnames = "status, value"
Dim count As Integer
count = connection.Call(input, 1, result)
Call logger.debug("Count: " & count)
Else
Error 2000, "Unable to connect to database."
End If
handleExit:
connection.Disconnect
Exit Function
handleError:
On Error Resume Next
Call logger.error(Nothing)
Resume handleExit
End Function
Thanks in advance!
I had made a stupid mistake and had a mismatch between the name of the input parameter in Domino and the name of the input parameter in the stored procedure.
Make sure all names match up and there shouldn't be a problem.
Stored-Procedure "mylib.MyStoredProc" wird aufgerufen ...
LcSession.Status = 12325: LC-Error: errCallStoredProc 12325 (Error: Parameter name not supplied: P_S651_AC, Connector 'odbc2', Method -Call-)
Solution: changed "mylib" into "MYLIB" and all was well.
Check not only Parameter-Names, but also the Search-Path.

How do I create a multi-level TreeView using F#?

I would like to display a directory structure using Gtk# widgets through F#, but I'm having a hard time figuring out how to translate TreeViews into F#. Say I had a directory structure that looks like this:
Directory1
SubDirectory1
SubDirectory2
SubSubDirectory1
SubDirectory3
Directory2
How would I show this tree structure with Gtk# widgets using F#?
EDIT:
gradbot's was the answer I was hoping for with a couple of exceptions. If you use ListStore, you loose the ability to expand levels, if you instead use :
let musicListStore = new Gtk.TreeStore([|typeof<String>; typeof<String>|])
you get a layout with expandable levels. Doing this, however, breaks the calls to AppendValues so you have to add some clues for the compiler to figure out which overloaded method to use:
musicListStore.AppendValues (iter, [|"Fannypack" ; "Nu Nu (Yeah Yeah) (double j and haze radio edit)"|])
Note that the columns are explicitly passed as an array.
Finally, you can nest levels even further by using the ListIter returned by Append Values
let iter = musicListStore.AppendValues ("Dance")
let subiter = musicListStore.AppendValues (iter, [|"Fannypack" ; "Nu Nu (Yeah Yeah) (double j and haze radio edit)"|])
musicListStore.AppendValues (subiter, [|"Some Dude"; "Some Song"|]) |> ignore
I'm not exactly sure what you're looking for but here is a translated example from their tutorials. It may help you get started. Image taken from tutorial site.
I think the key to a multi-level tree view is to append values to values, iter in this line musicListStore.AppendValues (iter, "Fannypack", "Nu Nu (Yeah Yeah) (double j and haze radio edit)") |> ignore
// you will need to add these references gtk-sharp, gtk-sharp, glib-sharp
// and set the projects running directory to
// C:\Program Files (x86)\GtkSharp\2.12\bin\
module SOQuestion
open Gtk
open System
let main() =
Gtk.Application.Init()
// Create a Window
let window = new Gtk.Window("TreeView Example")
window.SetSizeRequest(500, 200)
// Create our TreeView
let tree = new Gtk.TreeView()
// Add our tree to the window
window.Add(tree)
// Create a column for the artist name
let artistColumn = new Gtk.TreeViewColumn()
artistColumn.Title <- "Artist"
// Create the text cell that will display the artist name
let artistNameCell = new Gtk.CellRendererText()
// Add the cell to the column
artistColumn.PackStart(artistNameCell, true)
// Create a column for the song title
let songColumn = new Gtk.TreeViewColumn()
songColumn.Title <- "Song Title"
// Do the same for the song title column
let songTitleCell = new Gtk.CellRendererText()
songColumn.PackStart(songTitleCell, true)
// Add the columns to the TreeView
tree.AppendColumn(artistColumn) |> ignore
tree.AppendColumn(songColumn) |> ignore
// Tell the Cell Renderers which items in the model to display
artistColumn.AddAttribute(artistNameCell, "text", 0)
songColumn.AddAttribute(songTitleCell, "text", 1)
let musicListStore = new Gtk.ListStore([|typeof<String>; typeof<String>|])
let iter = musicListStore.AppendValues ("Dance")
musicListStore.AppendValues (iter, "Fannypack", "Nu Nu (Yeah Yeah) (double j and haze radio edit)") |> ignore
let iter = musicListStore.AppendValues ("Hip-hop")
musicListStore.AppendValues (iter, "Nelly", "Country Grammer") |> ignore
// Assign the model to the TreeView
tree.Model <- musicListStore
// Show the window and everything on it
window.ShowAll()
// add event handler so Gtk will exit
window.DeleteEvent.Add(fun _ -> Gtk.Application.Quit())
Gtk.Application.Run()
[<STAThread>]
main()

Resources