Calculate Indicator on Bar Close - futures io
futures io futures trading



Calculate Indicator on Bar Close


Discussion in ThinkOrSwim

Updated by InsideTheMarket
    1. trending_up 208 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 10 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Calculate Indicator on Bar Close

(login for full post details)
  #1 (permalink)
Orlando, Florida/USA
 
Experience: Master
Platform: ThinkorSwim, NinjaTrader
Trading: ES, NQ, YM, ZB, ZN, GC, SI, HG, CL, NG, ZS, ZC, ZW, 6E, 6B, 6A, 6J
 
InsideTheMarket's Avatar
 
Posts: 7 since Jul 2017
Thanks: 0 given, 1 received

I have an ThinkScript (ThinkOrSwim Platform) indicator that I created… how do I make it so it only calculates this indicator that I made on bar close and NOT every tick. It is a 1min chart. Thanks.

Update: I found this command: declare once_per_bar; but, it doesn't seem to consistently process the code in the indicator at the end of each bar... perhaps because I'm using 1m bars.

Any tips or guidance is appreciated.

Follow me on Twitter Visit my Facebook Reply With Quote

Can you help answer these questions
from other members on futures io?
TOS script help - crossover with alerts - help please?
ThinkOrSwim
Indicator that plots pivot highs and pivot lows
NinjaTrader
Chart text fixed and move with time
NinjaTrader
Two Data Series in Ninjatrader 7 for Order confirmation
NinjaTrader
Volume Chart Trend Lines
TradeStation
 
 
(login for full post details)
  #2 (permalink)
Houston, TX
 
Experience: Intermediate
Platform: TOS, Ninja, Tradestation
Trading: US Stock index futures
 
Skidboot's Avatar
 
Posts: 188 since Dec 2010
Thanks: 182 given, 276 received


InsideTheMarket View Post
I have an ThinkScript (ThinkOrSwim Platform) indicator that I created… how do I make it so it only calculates this indicator that I made on bar close and NOT every tick. It is a 1min chart. Thanks.

Can you not try your calc for previous bar (ex. MACD()."Value"[1] crosses above 0) and not for the current bar?

Reply With Quote
 
(login for full post details)
  #3 (permalink)
Orlando, Florida/USA
 
Experience: Master
Platform: ThinkorSwim, NinjaTrader
Trading: ES, NQ, YM, ZB, ZN, GC, SI, HG, CL, NG, ZS, ZC, ZW, 6E, 6B, 6A, 6J
 
InsideTheMarket's Avatar
 
Posts: 7 since Jul 2017
Thanks: 0 given, 1 received



Skidboot View Post
Can you not try your calc for previous bar (ex. MACD()."Value"[1] crosses above 0) and not for the current bar?

If I understand you right....I tried that but then it makes it one bar late...

The way I have it now for example:
def main = close("/ES");
def bullsigna1 = main > main[1];

Now if I use this at the top of the code: declare once_per_bar;
it does seem to test the indicator once per bar but not consistently at the same time... ie. at the close of the current bar.
And if I don't use that declaration... it tests the indicator each tick.

Now... if I use this code:
def bullsigna1 = main[1] > main[2];
Then obviously, the indicator is now lagging inherently by 1 bar...

Question is [0] the same as the current bar or is [0] referencing the last "closed" bar?
ie. is def bullsigna1 = main[0] > main[1]; what you're talking about?

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #4 (permalink)
Manhattan NY/USA
 
 
Posts: 4 since May 2020
Thanks: 0 given, 0 received

Def CURRENT= isnan(close[-1]) and !isnan(close);


I believe that’s what you need?
Makes the indicator only on current candle


Sent using the futures.io mobile app

Reply With Quote
 
(login for full post details)
  #5 (permalink)
Orlando, Florida/USA
 
Experience: Master
Platform: ThinkorSwim, NinjaTrader
Trading: ES, NQ, YM, ZB, ZN, GC, SI, HG, CL, NG, ZS, ZC, ZW, 6E, 6B, 6A, 6J
 
InsideTheMarket's Avatar
 
Posts: 7 since Jul 2017
Thanks: 0 given, 1 received


sunnydaze View Post
Def CURRENT= isnan(close[-1]) and !isnan(close);


I believe that’s what you need?
Makes the indicator only on current candle


Sent using the futures.io mobile app



But that doesn't prevent it from updating on every tick?

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #6 (permalink)
Manhattan NY/USA
 
 
Posts: 4 since May 2020
Thanks: 0 given, 0 received

Try this:
When the candle closes, you can use “plot signal = INDICATOR and !INDICATOR[-1]; ”

So it will only show when the candle closes and new candle opens (so will be a candle behind)


Sent using the futures.io mobile app

Reply With Quote
 
(login for full post details)
  #7 (permalink)
Orlando, Florida/USA
 
Experience: Master
Platform: ThinkorSwim, NinjaTrader
Trading: ES, NQ, YM, ZB, ZN, GC, SI, HG, CL, NG, ZS, ZC, ZW, 6E, 6B, 6A, 6J
 
InsideTheMarket's Avatar
 
Posts: 7 since Jul 2017
Thanks: 0 given, 1 received


sunnydaze View Post
Try this:
When the candle closes, you can use “plot signal = INDICATOR and !INDICATOR[-1]; ”

So it will only show when the candle closes and new candle opens (so will be a candle behind)


Sent using the futures.io mobile app


This looks promising... of course the market is closed now and I gotta wait until Sunday Night / Monday morning to test - lol.

When you say be a candle behind... you mean behind only the CURRENT bar - right? ie. say it's a 2min chart... it will be as current as the last closed bar... but not really "behind" in the context of what I'm trying to accomplish?

and in your example: plot signal = INDICATOR and !INDICATOR[-1];
isn't INDICATOR the current bar?
And !INDICATOR[-1] is the future bar?
So, how would that accomplish what I'm trying to make happen... with the indicator not getting processed until the end of the current bar? The future bar isn't even and shouldn't be... considered anyways... and using INDICATOR... would still have the indicator updating each tick, which is what I don't want? Not trying to be a jerk... just asking.


And how is the set of code you just gave... different than the other one: Def CURRENT= isnan(close[-1]) and !isnan(close);

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #8 (permalink)
Orlando, Florida/USA
 
Experience: Master
Platform: ThinkorSwim, NinjaTrader
Trading: ES, NQ, YM, ZB, ZN, GC, SI, HG, CL, NG, ZS, ZC, ZW, 6E, 6B, 6A, 6J
 
InsideTheMarket's Avatar
 
Posts: 7 since Jul 2017
Thanks: 0 given, 1 received


sunnydaze View Post
Def CURRENT= isnan(close[-1]) and !isnan(close);


I believe that’s what you need?
Makes the indicator only on current candle


Sent using the futures.io mobile app

I'm trying to just have the indicator process or be ran at the very end of the current candle... ie. not tick for tick throughout that candle's timeframe.
It could also process the indicator at the very beginning of the new candle for the previous candle... but needs to happen immediately on the new candle.

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #9 (permalink)
Manhattan NY/USA
 
 
Posts: 4 since May 2020
Thanks: 0 given, 0 received

Yea correct, this will only show on the previous bar that just closed, so only 1 bar behind.
The !indicator[-1] IS for the future bar, however the “!” In front of it means, “not true” for the next bar.

As far as the Isnan code, that you would use if you wanted your signal to appear on the CURRENT bar, not the PREVIOUS (which is the code i just provided). Hope that makes sense...im still new in coding but had the same issue and these codes worked for me



Sent using the futures.io mobile app

Reply With Quote
 
(login for full post details)
  #10 (permalink)
Manhattan NY/USA
 
 
Posts: 4 since May 2020
Thanks: 0 given, 0 received



InsideTheMarket View Post
I'm trying to just have the indicator process or be ran at the very end of the current candle... ie. not tick for tick throughout that candle's timeframe.

It could also process the indicator at the very beginning of the new candle for the previous candle... but needs to happen immediately on the new candle.



Yes, i believe the code i included will work, it will only show at the end of the candle/start of a new one


Sent using the futures.io mobile app

Reply With Quote


futures io Trading Community Platforms and Indicators ThinkOrSwim > Calculate Indicator on Bar Close


July 4, 2020


Upcoming Webinars and Events
 

Every journal equals ten meals for the hungry

Now
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts