Fix pine script code where I need to compare previous two prices with actual price
€8-30 EUR
Completed
Posted 5 months ago
€8-30 EUR
Paid on delivery
I need to fix my code where I want compare two previous open prices with specific condition and actual open price candle with same condition. I am showing only part of the code which is not working. All variables are set correctly but I am not able to get open price information for xxOpen1 and xxOpen2 and then plot in label. I am getting study error. Compiling is without any error but overall study is not working on chart.
Here is my code:
openHistory = [login to view URL]([login to view URL], "15S", open, lookahead=barmerge.lookahead_on)
for i = 0 to 30
wt101Condition = wt101[i] > wt201[i] and wtDot[i] == 1 and (wt102[i] < 0 or wt202[i] < 0)
if (wt101Condition)
// Calculate historical xxPrice, xxOpen1, and xxOpen2 using an offset
xxPrice := open[i]
xxWT101 := wt101[i]
xxWT201 := wt201[i]
// Extract historical open prices using array indexing
xxOpen1 := openHistory[i - 1]
xxOpen2 := openHistory[i - 2]
// Set the flag to color the next XX
shouldColorNextXX := true
// Create or update the label for each bar
if ([login to view URL](xxLabels) <= i)
[login to view URL](xxLabels, [login to view URL](x=bar_index - i, y=xxPrice, text="XPrice: " + [login to view URL](xxPrice) + " Open1: " + [login to view URL](xxOpen1) + " Open2: " + [login to view URL](xxOpen2) + " WAVE" + [login to view URL](xxWT101) + " WAVE" + [login to view URL](xxWT201), style=label.style_label_lower_left, color=[login to view URL], textcolor=[login to view URL], size=[login to view URL]))
else
label.set_xy([login to view URL](xxLabels, i), x=bar_index - i, y=xxPrice)
label.set_text([login to view URL](xxLabels, i), "XPrice: " + [login to view URL](xxPrice) + " Open1: " + [login to view URL](xxOpen1) + " Open2: " + [login to view URL](xxOpen2) + " WAVE" + [login to view URL](xxWT101) + " WAVE" + [login to view URL](xxWT201))
Please check my past work, coding ability and reviews on my portfolio.
I offer a range of Pine Script services:
Creating Custom Indicators
Debugging Pine Script Code
Combining Existing Indicators
Updating Existing Indicators
Generating Trading Signals
Creating Custom Alerts
Building Custom Screeners
Plotting Custom Visualization
Developing Backtesting Systems
Implementing Risk Management
Creating Trading Systems
Hi. I already did similar projects to this job successfully.
I am a professional coder in the development of EAs, Indicators and Scripts for MT4/MT5 and TradingView.
Please let us talk about the details of the job, so that we can do this job as you expect.
Hey,
As a professional trader and a Pinescript developer with more than 5 years of experience, this project seems straightforward for me and I can complete it within a few minutes. Please reach out to discuss further.
Sincerely,
BAGGAR Nassim
Hello Client , i am a professional programmer for financial markets. I have over 10 years experienced, Tradingview platforms, so I’m sure I can modify your code and i have coded similar before .lets discuss more.
Hello there, the problem in your script is that "openHistory[i - 1]" and "openHistory[i - 2]" result in negative indices "openHistory[-1]" and "openHistory[-2]" because your loop starts from 0, which PineScript doesn't allow. If you still need a freelancer for the job, I would be happy to discuss further details over the chat.