NexusFi: Find Your Edge


Home Menu

 





Find Low of Bar the Last Time a Condition Was True


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one EKTrade with 4 posts (0 thanks)
    2. looks_two xplorer with 2 posts (0 thanks)
    3. looks_3 JayC with 2 posts (3 thanks)
    4. looks_4 kevingoldman9090 with 1 posts (0 thanks)
    1. trending_up 2,712 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
EKTrade
SANTA CLARITA
 
Posts: 8 since Mar 2021
Thanks Given: 2
Thanks Received: 0

I want to be able to search back on a chart to find the last time that a condition was TRUE. One condition I was searching for is below.

PPS()."BuySignal" is true and close is greater than MovAvgExponential("length" = 200)."AvgExp"

The reason I am searching backwards is to find out what the low of that bar would be...

If that is possible, can I check what the low of the bar before the condition was... - 1 bar?

Basically, is there code to help me pinpoint a bar and determine facts about it? open, close, etc.

Thanks for your help!
EK


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
No book, only a stair: journaling fills where price move …
Cryptocurrency
EA
Platforms and Indicators
My Rant with AMP Futures
Trading Reviews and Vendors
Trump Media to sell instant access to market-moving soci …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Mes vs MNQ
6 thanks
NexusFi site changelog and issues/problem reporting
5 thanks
BERN ALGOS algo trading journal
3 thanks
TopStep Trader disappointment
2 thanks
Johnnys Journal
2 thanks
  #2 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 6,339 since Sep 2015
Thanks Given: 16,037
Thanks Received: 16,239

@EKTrade what trading platform?


Reply With Quote
  #3 (permalink)
EKTrade
SANTA CLARITA
 
Posts: 8 since Mar 2021
Thanks Given: 2
Thanks Received: 0


Sorry. TD Ameritrade / thinkorswim


Reply With Quote
  #4 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 6,339 since Sep 2015
Thanks Given: 16,037
Thanks Received: 16,239


EKTrade View Post
Sorry. TD Ameritrade / thinkorswim

Ok, I don't use that platform so I can't advise, but I have moved your question to the ThinkOrSwim thread - you should have better chances to get a reply here.

Good luck.


Reply With Quote
  #5 (permalink)
 JayC 
San Diego, CA
 
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43

Its a bit awkward, but you reference the previous value using a positive offset, but mark the candle condition with a negative one.

Hope this helps,
Jay

 
Code
def condition = PPS()."BuySignal" is true and close is greater than MovAvgExponential("length" = 200)."AvgExp";

AddChartBubble(condition, high, "Prev Low: " + low[1], Color.CYAN);

AddChartBubble(condition[-1], low, "Bar Low: " + low, Color.GRAY, up = No);


Reply With Quote
Thanked by:
  #6 (permalink)
EKTrade
SANTA CLARITA
 
Posts: 8 since Mar 2021
Thanks Given: 2
Thanks Received: 0

Thank you. That works great for putting the indicator on the chart. How would I use this date in a formula? I want to look back and find the low of the code below.

PPS()."BuySignal" is true and close is greater than MovAvgExponential("length" = 200)."AvgExp"[-1], low;

I am missing a couple of things though. I am trying to setup an autosell feature based on price falling below the code that you provided. Do you know how to best write that? I can't find code that references the present price. I found EntryPrice () to calculate other formulas, but I want to sell based on present price... not close from 1 bar ago.

Appreciate the feedback!
EK


Reply With Quote
  #7 (permalink)
 JayC 
San Diego, CA
 
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43

I think you're asking how to capture the low value for use on the current bar. The general idea is to store it, overwrite it anytime the condition is true, otherwise use the stored value.

 
Code
def condition = PPS()."BuySignal" is true and close is greater than MovAvgExponential("length" = 200)."AvgExp";
AddChartBubble(condition, high, "Prev Low: " + low[1], Color.CYAN);
AddChartBubble(condition[-1], low, "Bar Low: " + low, Color.GRAY, up = No);

def lastCondLow = if condition then low[1] else lastCondLow[1];
def LastBar = !IsNaN(open) and IsNaN(open [-1] );
AddChartBubble(LastBar, high, "Last Cond Low: " + lastCondLow, Color.YELLOW);


Reply With Quote
Thanked by:
  #8 (permalink)
EKTrade
SANTA CLARITA
 
Posts: 8 since Mar 2021
Thanks Given: 2
Thanks Received: 0

That worked like a charm! Much appreciated... I put up a different post a minute ago... if you can take a look at that. You'd really be helping me out. Again, thanks a lot!


Reply With Quote




Last Updated on March 10, 2021


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts