How to code this set up ? - futures io
futures io futures trading



How to code this set up ?


Discussion in ThinkOrSwim

Updated by Ty199
      Top Posters
    1. looks_one Ty199 with 11 posts (5 thanks)
    2. looks_two mtzimmer1 with 5 posts (8 thanks)
    3. looks_3 CodingDummy with 3 posts (1 thanks)
    4. looks_4 wldman with 1 posts (0 thanks)
    1. trending_up 981 views
    2. thumb_up 14 thanks given
    3. group 6 followers
    1. forum 20 replies
    2. attach_file 2 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
 

How to code this set up ?

(login for full post details)
  #1 (permalink)
Joplin, Mo. Jasper
 
 
Posts: 34 since Sep 2019
Thanks: 16 given, 39 received

I dont know anything about coding. I tried and just not that smart lol. But been playing with a formula that seems to work pretty good. But instead of adding it all up, is there a way to have it coded so TOS does it?
Pretty simple maybe ?
It is previous day High and Low subtracted from each other.
Then that value would be divided by 4
That would then be added on the next day open and also be subtracted from the next day open.
So there would be 2 lines, a high and a low applied to the chart.

It is figured like this.
Previous day High 58.70 Previous day Low 53.20
These are now subtracted for the difference which is 5.50
That value is divided by 4 which values at 1.375
Now 1.375 is added to the next day open price (ex. open price is 56.10 + 1.375 = 57.475 )
It is also subtracted from the open price ( ex. open price is 56.10 - 1.375 = 54.725 )
Now you have a high and a low that is calculated automatically and placed on the chart for that day of trading.
High 57.475 Low 54.725. There is no need the number to be odd as it is not rounded. (ex. 54.725 change up or down to a whole number such as 54.72)
I tried to write something up and it just dont even come close to working. Is there a way to even calculate this to be added as a study ?
All help is much welcome.

Reply With Quote

Can you help answer these questions
from other members on futures io?
FYI plot bug & workaround: changing color or width is delayed 1 bar
EasyLanguage Programming
Scan by comparing SMAs within 5 mins
ThinkOrSwim
Think or swim earnings move calculation
Brokers
Two Data Series in Ninjatrader 7 for Order confirmation
NinjaTrader
TOS script
ThinkOrSwim
 
 
(login for full post details)
  #2 (permalink)
Legendary Market Wizard
Chicago Illinois USA
 
Experience: Advanced
Broker: IB, ToS
Trading: /ES, US Equities/Options
 
wldman's Avatar
 
Posts: 3,222 since Aug 2011
Thanks: 1,878 given, 7,947 received

Like you I am not a code guy, but I persist in at least trying because the code community, especially on ToS, will respect the effort and maybe point the way.

What you are thinking about or something very similar was/is and idea that has been widely used in the past by someone whose name I'm not going to mention.

Daily Range Projections do lend themselves to the notion of a statistical model. The "data run" for which is quite simple.

Here is what I used. Even I was able to script this for Ninjatrader.

If period close < period open use: (H+L+L+C)/2 = X
If period close > period open use: (L+H+H+C)/2= X
If period close = period open use: (H+L+L+C)/2 = X

To calculate range projections for the next period..

For each of the formulas, to calc next period projected high, subtract current period L from X. To Calc next period projected low, subtract current period H from X.

So a basic model could be when price moves this direction from open some number of ticks 70% of the time it continues some distance before/without retrace.

Here is the thing. If you SHOW the attempt and the result, guys with the skill will believe you. Otherwise it just looks like you want someone else to do the work for you. When they see that you are trying they will correct your errors and give advice.

Good Luck.

-Dan

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #3 (permalink)
Joplin, Mo. Jasper
 
 
Posts: 34 since Sep 2019
Thanks: 16 given, 39 received


Thank you, I will keep trying and post results. I have a hard time making the plot
<high of previous day - low of previous day = A>
<A / 4 = B>
<B + open price = C placed on chart>
<B - open price = D placed on chart>

I try to put this in and it dont recognize any values. Its like I watch all the videos that show how to code but for some reason I dont get the same or formula or anything. I would love to be able to code on TOS . I have several methods I would love to try that would would alert at a price point and trend directions , pivot points, possible buy and sell signals. I love just testing new strategies and seeing what works under normal market behavior.
Thanks for the help and I will keep plugging away at it.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
Legendary Market Wizard
Bluffton, SC
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 606 since Dec 2018
Thanks: 1,594 given, 1,294 received

I can code this up when I get back to my computer tonight!

Visit my futures io Trade Journal Reply With Quote
The following 2 users say Thank You to mtzimmer1 for this post:
 
(login for full post details)
  #5 (permalink)
Joplin, Mo. Jasper
 
 
Posts: 34 since Sep 2019
Thanks: 16 given, 39 received


mtzimmer1 View Post
I can code this up when I get back to my computer tonight!

That would be awesome. But would you be able to help me understand what everything means? I dont understand where I go wrong. I try and I am putting things in wrong spaces or leaving something out.

Reply With Quote
The following user says Thank You to Ty199 for this post:
 
(login for full post details)
  #6 (permalink)
Legendary Market Wizard
Bluffton, SC
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 606 since Dec 2018
Thanks: 1,594 given, 1,294 received

declare upper;


def y_high = high(period=aggregationperiod.day)[1];
def y_low = low(period=aggregationperiod.day)[1];

def y_range = y_high-y_low;

def d_open = open(period=aggregationPeriod.DAY);

plot upper = d_open+(.25*y_range);

plot lower = d_open-(.25*y_range);

#########

This should work nicely. I'm headed to bed now but tag me with any questions and I'm happy to respond tomorrow!

Visit my futures io Trade Journal Reply With Quote
The following 2 users say Thank You to mtzimmer1 for this post:
 
(login for full post details)
  #7 (permalink)
Joplin, Mo. Jasper
 
 
Posts: 34 since Sep 2019
Thanks: 16 given, 39 received


mtzimmer1 View Post
declare upper;


def y_high = high(period=aggregationperiod.day)[1];
def y_low = low(period=aggregationperiod.day)[1];

def y_range = y_high-y_low;

def d_open = open(period=aggregationPeriod.DAY);

plot upper = d_open+(.25*y_range);

plot lower = d_open-(.25*y_range);

#########

This should work nicely. I'm headed to bed now but tag me with any questions and I'm happy to respond tomorrow!

Thank you so much !! this is awesome. I need to learn this coding more. I can get close but I still need work.
But Im running this on /QM /CL /NG /PL you can see how it breaks out of the high and low lines. So cool !! I added some daily support and resistance lines to my chart and looks like it gives some great exit points of the trade. It also looks like you can do a 2 to 1 risk management. Risk $50 and look at $100 to cover. Most looks like it will go more than 2 to 1, about 4 to 1 LOL..... This is sweet, Please I need to learn more on this coding. How do you do this ??

Reply With Quote
The following user says Thank You to Ty199 for this post:
 
(login for full post details)
  #8 (permalink)
Legendary Market Wizard
Bluffton, SC
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 606 since Dec 2018
Thanks: 1,594 given, 1,294 received

Hey I'm glad it is working for you!

Coding is one of those things you just need to look at and troubleshoot over and over again until it sinks in.

I would be more than happy to work with you on learning the basics of coding. You come up with ideas and I'll code them up and try to explain why each function does what it does. Win for both of us!

Cheers my friend,
Zimmer

Visit my futures io Trade Journal Reply With Quote
The following 4 users say Thank You to mtzimmer1 for this post:
 
(login for full post details)
  #9 (permalink)
Joplin, Mo. Jasper
 
 
Posts: 34 since Sep 2019
Thanks: 16 given, 39 received


mtzimmer1 View Post
Hey I'm glad it is working for you!

Coding is one of those things you just need to look at and troubleshoot over and over again until it sinks in.

I would be more than happy to work with you on learning the basics of coding. You come up with ideas and I'll code them up and try to explain why each function does what it does. Win for both of us!

Cheers my friend,
Zimmer

Sounds Great and I appreciate it so much ! I have one that involves a few indicators for US bonds. It does ok and made a few good trades from it. But Im going to run this on Paper for a few days and see the profit / loss ratio is and how many trades that are positive and negative. Im trying to come up with a good buy area after it shows a break out and a stop loss and target profit. I will make a few rules on trading it and sticking by it and post the results back here. I appreciate your help so much and will be sending you a PM here soon on the coding. Thanks !!!

Reply With Quote
The following user says Thank You to Ty199 for this post:
 
(login for full post details)
  #10 (permalink)
Legendary Market Wizard
Calgary, Alberta
 
Experience: Advanced
Platform: NinjaTrader 8
Broker: Kinetick
Trading: ES
 
JonnyBoy's Avatar
 
Posts: 1,329 since Apr 2012
Thanks: 519 given, 2,894 received



mtzimmer1 View Post
declare upper;


def y_high = high(period=aggregationperiod.day)[1];
def y_low = low(period=aggregationperiod.day)[1];

def y_range = y_high-y_low;

def d_open = open(period=aggregationPeriod.DAY);

plot upper = d_open+(.25*y_range);

plot lower = d_open-(.25*y_range);

#########

This should work nicely. I'm headed to bed now but tag me with any questions and I'm happy to respond tomorrow!

I don't use T.O.S but when guys have completed development of this, consider uploading to the download section. I like what you doing here, and it could help out others.

--------------------------------------------------------
- Trade what you see. Invest in what you believe -
--------------------------------------------------------
Reply With Quote


futures io Trading Community Platforms and Indicators ThinkOrSwim > How to code this set up ?


September 18, 2019


Upcoming Webinars and Events
 

Free BloodHound Licenses for everyone!

June
 

Every journal equals ten meals for the hungry

June
     



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