Close Price based on X Date - ThinkOrSwim | futures io social day trading
futures io futures trading


Close Price based on X Date
Updated: Views / Replies:128 / 5
Created: by jimderbehr Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

Close Price based on X Date

  #1 (permalink)
Rowland Heights, CA USA
 
Trading Experience: Beginner
Platform: TOS
 
Posts: 3 since Jul 2019
Thanks: 1 given, 0 received

Close Price based on X Date

I am trying to get a close price based on certain previous date, right now is based on EX-Dividend date, however TOS doesnt allow me to use that date. Below code for reference


#I can declare the X amount of days since last Ex Div Date
def LastXDiv= (GetEventOffset(Events.DIVIDEND, -1));

#But unable to put it under close parameters as below, it does not accept the Def variable LastXDiv or if I type out it all out.
#def LastXDivClose = close[GetEventOffset(Events.DIVIDEND, -1)];
#However I can get TOS to accept as below, but this would the result would be the next amount dividend days, not for previous.

def LastXDivClose = close[Events.DIVIDEND];



#right now I can only way I can get it to semi-working is to put label and find out X amount of days then change the input manually each time, but too tedious and wondering any work around for it.

input DaySinceLastXDiv = 2;
input CloseDay= 1;

def LastXDiv= (GetEventOffset(Events.DIVIDEND, -1));
def PrevDivClose = close(period = dayagg)[DaySinceLastXDiv];
def CurrentDayClose = close(period = dayagg)[CloseDay];
def PercentGain = (PrevdivClose - CurrentDayClose)/CurrentDayClose;

AddLabel(yes, LastXDiv + ": " + round(Percentgain,2) + "%" );

Reply With Quote
 
  #2 (permalink)
Minneapolis Minnesota
 
Trading Experience: Intermediate
Platform: ThinkOrSwim
 
Posts: 9 since Jul 2019
Thanks: 0 given, 3 received

Try this

 
Code
def dayClose = close(period = AggregationPeriod.DAY);
def divvieClose = if !IsNaN(GetDividend()) then dayClose else divvieclose[1];
def dow = GetDayOfWeek(GetYYYYMMDD());
def daysSinceDivvie = if !IsNaN(GetDividend()) then 
                        0 else if dow != dow[1] then
                                 daysSinceDivvie[1] + 1 else
                                 daysSinceDivvie[1];

plot ClosePriceOnDivviDate = divvieClose; 
AddLabel(1, "Days Since Last Dividend: "+daysSinceDivvie, Color.Gray);


Last edited by Nube; July 4th, 2019 at 03:40 PM.
Reply With Quote
 
  #3 (permalink)
Rowland Heights, CA USA
 
Trading Experience: Beginner
Platform: TOS
 
Posts: 3 since Jul 2019
Thanks: 1 given, 0 received


Thanks, but I tried that and seems doesn't work, as I want to get the DayClose of the Last Previous Div date, but when I use your code and just add one extra line, and use the "daysSinceDivvie" as the length number for Close it doesn't accept it as says it only accepts constant. Which is the same error I got when I did it my way.

def prevdivclose = close(period = AggregationPeriod.DAY)[daysSinceDivvie];

Reply With Quote
 
  #4 (permalink)
Minneapolis Minnesota
 
Trading Experience: Intermediate
Platform: ThinkOrSwim
 
Posts: 9 since Jul 2019
Thanks: 0 given, 3 received


jimderbehr View Post
Thanks, but I tried that and seems doesn't work, as I want to get the DayClose of the Last Previous Div date, but when I use your code and just add one extra line, and use the "daysSinceDivvie" as the length number for Close it doesn't accept it as says it only accepts constant. Which is the same error I got when I did it my way.

def prevdivclose = close(period = AggregationPeriod.DAY)[daysSinceDivvie];

Don't add anything. It's already plotting the close price for the day of the last dividend.

Reply With Quote
The following user says Thank You to Nube for this post:
 
  #5 (permalink)
Rowland Heights, CA USA
 
Trading Experience: Beginner
Platform: TOS
 
Posts: 3 since Jul 2019
Thanks: 1 given, 0 received

Sorry I was being dumb, I was fixated on just what the label was showing didnt actually saw the plot itself. It works now thanks for your help.

Reply With Quote
 
  #6 (permalink)
Minneapolis Minnesota
 
Trading Experience: Intermediate
Platform: ThinkOrSwim
 
Posts: 9 since Jul 2019
Thanks: 0 given, 3 received


jimderbehr View Post
Sorry I was being dumb, I was fixated on just what the label was showing didnt actually saw the plot itself. It works now thanks for your help.

No problem. It isn't obvious when skimming the code. The value not being [indexed] makes it a little confusing.

Reply With Quote

Reply



futures io > > > > Close Price based on X Date

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

Thanks for everything -- $250 in Amazon Gift Cards ready to give away

Right now
 

Journal in July -- over $2,500 in prizes w/NinjaTrader

July
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Function to get Close price for given date and time vmodus EasyLanguage Programming 7 March 6th, 2019 08:22 AM
Rewriting DATE NEXT BAR <> DATE - Simple Help fiverr Traders Hideout 7 May 11th, 2016 05:56 AM
Defining closing price for a given date AlexanderKors ThinkOrSwim Programming 0 April 7th, 2014 11:37 AM
Rollover date vs Expiration date grego Currency Futures 3 March 10th, 2014 06:03 AM
'From' date needs to be smaller than 'To' date DavidHP NinjaTrader Programming 2 January 3rd, 2010 10:09 PM


Tags
ai, code, dayofweek, dow, error, ma, think or swim, thinkorswim, tos, type, variable

All times are GMT -4. The time now is 06:30 PM. (this page content is cached, log in for real-time version)

Copyright © 2019 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432 WhatsApp Business, 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