The complier cannot call 'pivothighs' with argument - trading

I've been trying to make a pivot point high low multitimeframe indicator but still a new learner and have no idea how to fix.
I tried to put 'tf' function in multiple places of code but it's not working.
//#version=4
study("Pivot Prices", overlay=true)
tf=input('120')
leftbars = input(10, minval=1, title='Bars to the left')
rightbars = input(2, minval=1, title='Bars to the right')
phigh = pivothigh(high, tf, leftbars,rightbars)
plow = pivotlow(low, tf, leftbars, rightbars)
if phigh
label1 = label.new(bar_index[rightbars], high[rightbars], text=tostring(high[rightbars]), style=label.style_labeldown, color=color.orange)
if plow
label2 = label.new(bar_index[rightbars], low[rightbars], text=tostring(low[rightbars]), s``tyle=label.style_labelup, color=color.green)
I want it to be showing multitimeframe perspective but couldn't figure what is wrong in the code.

Read the documentation. pivothigh() and pivotlow() can take two or three arguments.
pivothigh(source, leftbars, rightbars) → series[float]
pivothigh(leftbars, rightbars) → series[float]
You are passing four arguments.

Related

cvxpy: Possible sign flip for Lagrange Multiplier/dual variable

I have encountered a very strange problem when using cvxpy. Consider the following two problems:
x = cvx.Variable(1, "x")
obj = cvx.Minimize(x)
cons = [x==1]
prob = cvx.Problem(obj, cons)
prob.solve()
print(cons[0].dual_value)
Output: -1
x = cvx.Variable(1, "x")
obj = cvx.Maximize(x)
cons = [x==1]
prob = cvx.Problem(obj, cons)
prob.solve()
print(cons[0].dual_value)
Output: 1
The only difference is that one is a minimization problem and the other is a maximization problem, but the sign of the dual variable is flipped.
Conceptually, this shouldn't happen as in both cases the Lagrangian is L=x + lambda*(x-1), but I cannot find the documentation on how it is defined.
Does anyone have an explanation on why this is happening?

Is it possible to vectorize this calculation in numpy?

Can the following expression of numpy arrays be vectorized for speed-up?
k_lin1x = [2*k_lin[i]*k_lin[i+1]/(k_lin[i]+k_lin[i+1]) for i in range(len(k_lin)-1)]
Is it possible to vectorize this calculation in numpy?
x1 = k_lin
x2 = k_lin
s = len(k_lin)-1
np.roll(x2, -1) #do this do bring the column one position right
result1 = x2[:s]+x1[:s] #your divider. You add everything but the last element
result2 = x2[:s]*x1[:s] #your upper part
# in one line
result = 2*x2[:s]*x1[:s] / (x2[:s]+x1[:s])
You last column wont be added or taken into the calculations and you can do this by simply using np.roll to shift the columns. x2[0] = x1[1], x2[1] = x1[2].
This is barely a demo of how you should approach google numpy roll. Also instead of using s on x2 you can simply drop the last column since it's useless for the calculations.

How to estimate? "simple" Nonlinear Regression + Parameter Constraints + AR residuals

I am new to this site so please bear with me. I want to
the nonlinear model as shown in the link: https://i.stack.imgur.com/cNpWt.png by imposing constraints on the parameters a>0 and b>0 and gamma1 in [0,1].
In the nonlinear model [1] independent variable is x(t) and dependent are R(t), F(t) and ξ(t) is the error term.
An example of the dataset can be shown here: https://i.stack.imgur.com/2Vf0j.png 68 rows of time series
To estimate the nonlinear regression I use the nls() function with no problem as shown below:
NLM1 = nls(**Xt ~ (aRt-bFt)/(1-gamma1*Rt), start = list(a = 10, b = 10, lamda = 0.5)**,algorithm = "port", lower=c(0,0,0),upper=c(Inf,Inf,1),data = temp2)
I want to estimate NLM1 with allowing for also an AR(1) on the residuals.
Basically I want the same procedure as we go from lm() to gls(). My problem is that in the gnls() function I dont know how to put contraints for the model parameters a, b, gamma1 and the model estimates wrong values for them.
nls() has the option for lower and upper bounds. I cant do the same on gnls()
In the gnls(): I need to add the contraints something like as in nls() lower=c(0,0,0),upper=c(Inf,Inf,1)
NLM1_AR1 = gnls( model = Xt ~ (aRt-bFt)/(1-gamma1*Rt), data = temp2, start = list(a =13, b = 10, lamda = 0.5),correlation = corARMA(p = 1))
Does any1 know the solution on how to do it?
Thank you

'=' expected got RH

i have been Programming Lua with the game Roblox!
but my code i'm trying to build does not work!
RH = Instance.new("Motor6D", T)
RH.DesiredAngle = -0.044
RH.MaxVelocity = 0.15
RH.Name = "Right Hip"
RH.Part0 = Torso
RH.Part1 = Right Leg
RS = Instance.new("Motor6D", T)
RS.DesiredAngle = 0.044
RS.MaxVelocity = 0.15
RS.Name = "Right Shoulder"
RS.Part0 = Torso
RS.Part1 = Right Arm
it says expected '=' got RH
Can anyone please tell me why
Also my theory is that
RH.Part1 = Right Leg
is causing the problem.
When i put it in quotes it says
RH.Part1 = "Right Leg" Object Needed not string
(something along those lines)
So can anybody tell me how to weld with two words?
You're right. Lua is complaining about RH.Part1 = Right Leg, which it sees as RH.Part1 = Right followed by Leg RS = Instance.new("Motor6D", T), and this is a syntax error.
The fix RH.Part1 = "Right Leg" does work at compile time but not at run time because of the semantics of Roblox. From what I could gather on line, RH.Part1 needs to be an object. And so does RH.Part0. Since Torso is not defined in that code, you get nil.
Bottom line: you need to define objects named Torso, Right_Leg, Right_Arm before you used them.

MS Chart Control Range Bar

I am trying to somehow replicate the range bar chart here.
I've found this reference but I don't fully grasp the code.
What I have is a series of task (sometimes accomplished in different periods).
let d = [("task1", DateTime.Parse("11/01/2014 08:30"), DateTime.Parse("12/01/2014 10:30"));
("task2", DateTime.Parse("15/01/2014 09:30"), DateTime.Parse("16/01/2014 10:30"));
("task3", DateTime.Parse("11/01/2014 08:30"), DateTime.Parse("16/01/2014 10:30"))]
let chart = d |> FSharp.Charting.Chart.RangeBar
chart.ShowChart()
I am struggling to understand the logic of the API.
I have also tried:
let chart = new Windows.Forms.DataVisualization.Charting.Chart(Dock = DockStyle.Fill)
let area = new ChartArea("Main")
chart.ChartAreas.Add(area)
let mainForm = new Form(Visible = true, TopMost = true, Width = 700, Height = 500)
mainForm.Controls.Add(chart)
let seriesColumns = new Series("NameOfTheSerie")
seriesColumns.ChartType <- SeriesChartType.RangeBar
type SupportToChart(serieVals: Series) =
member this.addPointXY(lbl, [<ParamArray>] yVals: Object[]) =
serieVals.Points.AddXY(lbl, yVals) |> ignore
let supporter = SupportToChart(seriesColumns)
supporter.addPointXY("AAA", DateTime.Parse("11/01/2014 08:30"), DateTime.Parse("12/01/2014 10:30") )
which results in
System.ArgumentOutOfRangeException: You can only set 1 Y values for
this data point.
Has something changed in the API since then?
I'm not entirely sure that F# Charting is currently powerful enough to be able to reconstruct the above chart. However, one of the problems seems to be that it treats dates as float values (for some reason) and incorrectly guesses the ranges. You can at least see the chart if you use:
Chart.RangeBar(d)
|> Chart.WithYAxis(Min=41650.0, Max=41660.0)
Please submit this as an issue on GitHub. If you want to dig deeper into how F# Charting works and help us get this fixed, that would be amazing :-)
The trick is initializing the Series with
let serie = new Series("Range", yValues)
where yValues defines the max number of "Y-values".

Resources