finding the minimum of an equation - Traders Hideout | futures io social day trading
futures io futures trading


finding the minimum of an equation
Updated: Views / Replies:1,107 / 12
Created: by adamov Attachments:3

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 90,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
 3  
 
Thread Tools Search this Thread
 

finding the minimum of an equation

  #1 (permalink)
Elite Member
Budapest, Hungary
 
Futures Experience: None
Platform: ninjatrader
Favorite Futures: FGBL / FESX / ES / ZN / ZB
 
adamov's Avatar
 
Posts: 84 since Jun 2012
Thanks: 37 given, 48 received

finding the minimum of an equation

Hey
I am trying to get the minimum value of curves in NT7 (C#) in the most resource efficient way.
The equation of one curve is:

y= |-22-16x|+|44-22x|+|21-25x|+|40-22x|+|6-11x|+|12-4x|

They always have and only one minimum point and they look like something like this:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).



Actually I am looking for the value of x when y is lowest.
Any help is appreciated!

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,312 since Sep 2013
Thanks: 1,627 given, 3,421 received
Forum Reputation: Legendary


The vertex equals the point where the first derivative is zero

Reply With Quote
The following user says Thank You to rleplae for this post:
 
  #4 (permalink)
Elite Member
Manchester, NH
 
Futures Experience: Beginner
Platform: thinkorswim
Broker/Data: TD Ameritrade
Favorite Futures: Stocks
 
Posts: 900 since Jul 2012
Thanks: 601 given, 1,781 received

@rleplae's answer is correct, a simple numerical solution to implement is the Newton-Raphson method.

Reply With Quote
The following 2 users say Thank You to artemiso for this post:
 
  #5 (permalink)
Elite Member
Salt Lake City, UT
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Dormans/Zen-fire
Favorite Futures: 6E ES YM
 
Posts: 233 since Mar 2010
Thanks: 46 given, 321 received

this might help

https://www.symbolab.com/solver/derivative-calculator/%5Cfrac%7Bd%7D%7Bdx%7D%5Cleft(12-4x%5Cright)


Last edited by tulanch; March 17th, 2017 at 01:32 AM.
Reply With Quote
The following 2 users say Thank You to tulanch for this post:
 
  #6 (permalink)
Elite Member
Budapest, Hungary
 
Futures Experience: None
Platform: ninjatrader
Favorite Futures: FGBL / FESX / ES / ZN / ZB
 
adamov's Avatar
 
Posts: 84 since Jun 2012
Thanks: 37 given, 48 received

Thank you for all the inputs.

So after differentiating I got this:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


This is what I should solve to 0

I looked into this Newton-Raphson method, its really interesting and could provide a really good approximation of root this function in a couple of steps but I should differentiate this again, and it makes it way too complicated.
only the first part looked like this:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).



wouldn’t be more efficient just increasing/decreasing the value of x in a cycle In the original equation until the value of y won’t get any smaller?
Whole numbers are fine for me, I don’t need any decimals.

Reply With Quote
 
  #7 (permalink)
Elite Member
Manchester, NH
 
Futures Experience: Beginner
Platform: thinkorswim
Broker/Data: TD Ameritrade
Favorite Futures: Stocks
 
Posts: 900 since Jul 2012
Thanks: 601 given, 1,781 received

You need to distinguish between symbolic and numerical differentiation here. There's 3 different approaches depending on what you're trying to do:

If you're trying to find the analytical form of the first derivative, f' and solve the root for it, and you know the analytic formula of f at compile-time, you can solve f'=0 by hand and hard-code that into your program. Or you can find f' and then get quadratic convergence on the minimum with Newton-Raphson.

If you know the analytic form of f at runtime, there's different ways to perform symbolic differentiation, and chain rule-based approaches are popular, e.g. in backpropagation literature for neural networks.

If you don't know the analytic formula of f either at compile-time or runtime, you can still use Newton-Raphson but approximate f' numerically with any finite difference method (secant, forward difference, backward difference, central difference), then converge on f'=0 iteratively.

Reply With Quote
The following 2 users say Thank You to artemiso for this post:
 
  #8 (permalink)
Elite Member
Manchester, NH
 
Futures Experience: Beginner
Platform: thinkorswim
Broker/Data: TD Ameritrade
Favorite Futures: Stocks
 
Posts: 900 since Jul 2012
Thanks: 601 given, 1,781 received

Also if you do know the analytic form and decide to solve the first order necessary condition, do make sure that your function is strictly convex. (The derivative does not exist at x=0 for f(x) = |x|.)

Reply With Quote
The following user says Thank You to artemiso for this post:
 
  #9 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,618 since Mar 2010
Thanks: 4,223 given, 25,455 received
Forum Reputation: Legendary

Answer
This post has been selected as an answer to the original posters question Answer


adamov View Post
Hey
I am trying to get the minimum value of curves in NT7 (C#) in the most resource efficient way.
The equation of one curve is:

y= |-22-16x|+|44-22x|+|21-25x|+|40-22x|+|6-11x|+|12-4x|

They always have and only one minimum point and they look like something like this:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).



Actually I am looking for the value of x when y is lowest.
Any help is appreciated!


This is a funny little puzzle!

If I look at your function it is built from six components, each component being the absolute amount of a linear function. Now let us look at a component function, for example

y1 = |-22-16x|

This function has two linear legs, a descending leg on the left side and and a rising leg on the right side. For x = -1.375 it takes the value zero.

The same is true for the other five component functions. Each of them is built from two legs and has a low point, where it takes the value 0. I conclude that the function y that you have exposed, has six points where it is not differentiable. Newton-Raphson cannot be used.

However, your function has another property, which makes a solution easy. With the exception of the low points of the six component functions your function can be built by adding six linear functions. Therefore it is linear itself between two low points. As a consequence one of the low points of the component function is the minimum for which you are looking.

Therefore you just need to calculate x1, x2, x3, x4, x5, x6 representing the low points of the component functions and then find out for which of those the function

y = |-22-16x|+|44-22x|+|21-25x|+|40-22x|+|6-11x|+|12-4x|

takes the lowest value.

Reply With Quote
The following 4 users say Thank You to Fat Tails for this post:
 
  #10 (permalink)
Elite Member
Budapest, Hungary
 
Futures Experience: None
Platform: ninjatrader
Favorite Futures: FGBL / FESX / ES / ZN / ZB
 
adamov's Avatar
 
Posts: 84 since Jun 2012
Thanks: 37 given, 48 received



Fat Tails View Post
This is a funny little puzzle!

If I look at your function it is built from six components, each component being the absolute amount of a linear function. Now let us look at a component function, for example

y1 = |-22-16x|

This function has two linear legs, a descending leg on the left side and and a rising leg on the right side. For x = -1.375 it takes the value zero.

The same is true for the other five component functions. Each of them is built from two legs and has a low point, where it takes the value 0. I conclude that the function y that you have exposed, has six points where it is not differentiable. Newton-Raphson cannot be used.

However, your function has another property, which makes a solution easy. With the exception of the low points of the six component functions your function can be built by adding six linear functions. Therefore it is linear itself between two low points. As a consequence one of the low points of the component function is the minimum for which you are looking.

Therefore you just need to calculate x1, x2, x3, x4, x5, x6 representing the low points of the component functions and then find out for which of those the function

y = |-22-16x|+|44-22x|+|21-25x|+|40-22x|+|6-11x|+|12-4x|

takes the lowest value.

Awsome!!
Thinking out of the box.

I had some similar reasoning in my head. I was sure the it has to be somewhere between the biggest and smallest root of the components like you explained.
I was experimenting to calculate the minimum point from all the roots somehow, but I wouldn't thought its gonna be one of them.

Flawless logic!
Thanks you and everybody who contributed!

Reply With Quote
The following user says Thank You to adamov for this post:

Reply



futures io > > > finding the minimum of an equation

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

FuturesTrader71: TBA

Elite only

Al Brooks: TBA

Elite only

Jigsaw Trading: TBA

Oct 19

RandBots: TBA

Oct 24
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Schrödinger Equation mroland19 Off-Topic 2 July 6th, 2015 05:19 AM
Need help formulating an equation in excel mmeyerin Off-Topic 0 March 7th, 2015 09:39 PM
Interesting Equation redratsal Off-Topic 13 December 14th, 2012 06:03 PM
Vant Tharp's Percent Volatility Position Sizing - FX equation - PLEASE ANYONE? fxhst329 Psychology and Money Management 5 November 16th, 2012 10:58 PM
The Trader's Equation: Should I Take This Trade? Anagami The Elite Circle 1 March 21st, 2011 05:33 PM


All times are GMT -4. The time now is 02:24 AM.

Copyright © 2017 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
Page generated 2017-09-22 in 0.15 seconds with 38 queries on phoenix via your IP 54.198.54.142