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 JayC with 2 posts (3 thanks)
    3. looks_3 xplorer with 2 posts (0 thanks)
    4. looks_4 kevingoldman9090 with 1 posts (0 thanks)
    1. trending_up 1,584 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 1 attachments




 
Search this Thread

Find Low of Bar the Last Time a Condition Was True

  #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?
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 5,972 since Sep 2015
Thanks Given: 15,487
Thanks Received: 15,382

@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: 5,972 since Sep 2015
Thanks Given: 15,487
Thanks Received: 15,382


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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts