Record a Value

epicable

New member
Hi, I have a question which I couldnt find an answer in the forums and I couldnt find a solution.
How can I record a value of the low price in the buy candle until there is a close signal but in between I have another buy signal.
I have tried recording the low price when there is a buy signal but when I have another buy signal then it overwrites the genuine low price that triggered the trade.
I want to have the original low price until there is a profit or stop signal.
The problem is that stop signal is when the price is lower thant the low of the buy candle so I cant have that value wrong.
 
Hi, I have a question which I couldnt find an answer in the forums and I couldnt find a solution.
How can I record a value of the low price in the buy candle until there is a close signal but in between I have another buy signal.
I have tried recording the low price when there is a buy signal but when I have another buy signal then it overwrites the genuine low price that triggered the trade.
I want to have the original low price until there is a profit or stop signal.
The problem is that stop signal is when the price is lower thant the low of the buy candle so I cant have that value wrong.

This hopefully helps. It is one way that uses a counter and when plotting that limits the arrow to plot only when the counter == 1 in a direction. It also has an input showallarrows so you can see there are arrows that are not plotted more than once without an arrow plotted in the opposite direction.

Ruby:
input length        = 8;
input trigger       = 25;
input showallarrows = no; #show only one arrow per direction or all

def price  = close + low + high;
def linDev = LinDev(price, length);
def CCI    = if linDev == 0
             then 0
             else (price - Average(price, length)) / linDev / 0.015;

def Up   = CCI[1] <= trigger and CCI > trigger;
def Down = CCI[1] >= -trigger and CCI < -trigger;

def count  = if Up == 1 and count[1] == 0
             then 1
             else if count[1] >= 1 and CCI >= -trigger
             then count[1] + 1 else 0;
def count1 = if Down == 1 and count1[1] == 0
             then 1
             else if count1[1] >= 1 and CCI <= trigger
             then count1[1] + 1
             else 0;

plot ArrowUp = if (Up and count == 1) or (Up and showallarrows == yes) then low else Double.NaN;
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowUp.SetDefaultColor(Color.YELLOW);
ArrowUp.SetLineWeight(5);

plot ArrowDn = if Down and count1 == 1 or (Down and showallarrows == yes) then high else Double.NaN;
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowDn.SetDefaultColor(Color.BLUE);
ArrowDn.SetLineWeight(5);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

This hopefully helps. It is one way that uses a counter and when plotting that limits the arrow to plot only when the counter == 1 in a direction. It also has an input showallarrows so you can see there are arrows that are not plotted more than once without an arrow plotted in the opposite direction.
Thank you SleepyZ. I will try with your suggestion.
The code tweaked for me is:


def count = if buy == 1 and count[1] == 0
then 1
else 0;

def low_ = if (buy and count == 1) then low[1] else low_[1];
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
257 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top