Creating TrueFalse Function - EasyLanguage Programming | futures io social day trading
futures io futures trading


Creating TrueFalse Function
Updated: Views / Replies:1,678 / 6
Created: by JGSmith Attachments:1

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

Creating TrueFalse Function

  #1 (permalink)
Elite Member
Duisburg, Germany
 
Futures Experience: Intermediate
Platform: TWS, NinjaTrader, MT4
Broker/Data: FXCM, Interactive Brokers, Oanda
Favorite Futures: Forex
 
Posts: 129 since Aug 2013
Thanks: 55 given, 44 received

Creating TrueFalse Function

Now that I have turned the basic trading strategy into an easier to read indicator (Link: TALKING COW - YouTube), I now would like to turn it into a function in order to develop an automated trading strategy. (let me know if this should actually go in the previous thread - it seems like a brand new topic to me and that is why I am creating a new thread).

I understand the basic premise of creating numeric functions as I have done that in order to create the indicator. But taking all of this information that the indicator uses and turning it into a function seems a little bit more daunting.

Obviously, I have read the EasyLanguage Essentials portion on creating functions but that really did not help me so much.

Could someone help me break this down in to smaller, bite sized, bites? I am not asking anyone to do my work for me, but just help me to think about this correctly so that I can learn how to create this the best.

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)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary


JGSmith,

you could use a numeric return type for your function and return +1 for true and 0 for false.
For a true/false type you simply have to change the return type.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Another thing you can do is use multiple output functions, where you reference back values through inputs. Take a look at the pivot function for an example.

Here is the definition from a Tradestation function:

A multiple-output function has two types of parameters or "inputs" - input parameters
and input/output parameters. The values of the input parameters are passed into the
multiple-output function, but not modified by the function. The values of the input/
output parameters are passed into the multiple-output function, modified by it, and
the modified values are then inherited by - or output to - the calling routine.

The input/output parameters are often used for output purposes only, i.e., the
incoming values are ignored. The outputs are in addition to the function return. In
multiple-output functions, the function return is generally used to return an error
code, though sometimes the return may simply be a dummy value.

The input/output parameters are declared with a "ref" suffix (such as "numericref") in
the multiple-output function's declaration statements. For further clarity, the names
of the input/output parameters are generally prefixed with an "o" in the function as
well as in all the routines that call the function.


Regards,
ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #4 (permalink)
Elite Member
Duisburg, Germany
 
Futures Experience: Intermediate
Platform: TWS, NinjaTrader, MT4
Broker/Data: FXCM, Interactive Brokers, Oanda
Favorite Futures: Forex
 
Posts: 129 since Aug 2013
Thanks: 55 given, 44 received


ABCTG View Post
For a true/false type you simply have to change the return type.

Thank you. I have chosen to go with a TrueFalse function.

Here is the work that I have done so far with this now. It is loosely based on the indicator that was created in the other post referenced above.

I have gotten the function to compile so at least I have done something correct. I will post the code and then explain a bit of what I am trying to do.

 
Code
Inputs:
	SMA( TrueFalse ) ,
	maLength ( Numeric ) ,
	kcLength ( Numeric ) ,
	kcATR (numeric ) ,
	AroonUpLength( numeric ) ;
	

condition1 =  SMA = True ;
condition3 = __AroonUp( AroonUpLength ) = 100 ;
condition4 = Close > Open ;
condition5 = Close > KeltnerChannel( close , kcLength , kcATR ) ;
My goal in writing this the way that I am is to make various elements optimizable.

Obviously, the ultimate strategy will say, "When each of these conditions are met, then buy..." and the conditions are probably self-explanatory in the code.

But the interesting thing in this code is the "SMA". That is a Simple Moving Average and I want to be able to test if using the SMA in this strategy actually makes a difference. Once I know if the SMA actually makes a difference then I can either just throw that condition away, or I can begin the process of determining if there is a better sma than another one. (hopefully, without over-optimizing).

The issue that I am now running into is that it seems that this function will work fine if the SMA is "true". But how can I still use this same function if the SMA was false? Or do I need to create an entirely new function for that? But it seems as though that would unnecasarily start eating up resources.

Hopefully my questions makes sense.

Reply With Quote
 
  #5 (permalink)
Elite Member
Duisburg, Germany
 
Futures Experience: Intermediate
Platform: TWS, NinjaTrader, MT4
Broker/Data: FXCM, Interactive Brokers, Oanda
Favorite Futures: Forex
 
Posts: 129 since Aug 2013
Thanks: 55 given, 44 received

I forgot to mention that I want the reset element that was talked about in post #15 of here.

In that case it was for an indicator and making it to not plot the paintbar until it has "reset".

I would imagine that the code is a bit different in a function because I am not actually plotting anything - but the function would cease to be true if it has not reset it self. I have thought about a couple of ways to make that happen in the function, but it would never compile.

Reply With Quote
 
  #6 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary

JGSmith,

it should be possible to handle both SMA = true and SMA = false within this function. What happens in the code when SMA is true, as I can't see that from the piece you posted? What should happen if SMA is false?

Post the full function code if you can and your approach to the reset element, too. I will gladly take a look at it and see what needs to be changed.

Regards,
ABCTG



JGSmith View Post
Thank you. I have chosen to go with a TrueFalse function.

Here is the work that I have done so far with this now. It is loosely based on the indicator that was created in the other post referenced above.

I have gotten the function to compile so at least I have done something correct. I will post the code and then explain a bit of what I am trying to do.

 
Code
Inputs:
	SMA( TrueFalse ) ,
	maLength ( Numeric ) ,
	kcLength ( Numeric ) ,
	kcATR (numeric ) ,
	AroonUpLength( numeric ) ;
	

condition1 =  SMA = True ;
condition3 = __AroonUp( AroonUpLength ) = 100 ;
condition4 = Close > Open ;
condition5 = Close > KeltnerChannel( close , kcLength , kcATR ) ;
My goal in writing this the way that I am is to make various elements optimizable.

Obviously, the ultimate strategy will say, "When each of these conditions are met, then buy..." and the conditions are probably self-explanatory in the code.

But the interesting thing in this code is the "SMA". That is a Simple Moving Average and I want to be able to test if using the SMA in this strategy actually makes a difference. Once I know if the SMA actually makes a difference then I can either just throw that condition away, or I can begin the process of determining if there is a better sma than another one. (hopefully, without over-optimizing).

The issue that I am now running into is that it seems that this function will work fine if the SMA is "true". But how can I still use this same function if the SMA was false? Or do I need to create an entirely new function for that? But it seems as though that would unnecasarily start eating up resources.

Hopefully my questions makes sense.


Reply With Quote
 
  #7 (permalink)
Elite Member
Duisburg, Germany
 
Futures Experience: Intermediate
Platform: TWS, NinjaTrader, MT4
Broker/Data: FXCM, Interactive Brokers, Oanda
Favorite Futures: Forex
 
Posts: 129 since Aug 2013
Thanks: 55 given, 44 received


ABCTG View Post
JGSmith,

it should be possible to handle both SMA = true and SMA = false within this function. What happens in the code when SMA is true, as I can't see that from the piece you posted? What should happen if SMA is false?

Post the full function code if you can and your approach to the reset element, too. I will gladly take a look at it and see what needs to be changed.

The funny part, is that this was the entire code. lol. I am really working hard to get this figured out.

Today, when I should have been working on other things, my mind was on this thinking of how it possibly should be written. Here is what I have now. I will post the code and then comment.

 
Code
Inputs:
	SMA( TrueFalse ) , 
	maLength ( Numeric ) ,
	kcLength ( Numeric ) ,
	kcATR (numeric ) ,
	AroonUpLength( numeric ) ;
	
Condition1 = SMA = True ;
Condition2 = SMA = False ;

__PracticeFunctionForStrategy( Condition1 , maLength , kcLength , kcATR , AroonUpLength ) = 
	__AroonUp( AroonUpLength ) = 100 and
	Close > Average( Close , maLength ) and
	Close > Open and
	Close > KeltnerChannel(close , kcLength , kcATR ) ;

__PracticeFunctionForStrategy( condition2 , maLength , kcLength , kcATR , AroonUpLength ) =
	__AroonUp( AroonUpLength ) = 100 and 
	Close > Open and
	Close > KeltnerChannel(close , kcLength , kcATR ) ;
As you can probably quickly figure out, this is not compiling now....but I have no idea why. The error shows that it has to do with the "=". This is where I start getting confused. Obviously there is nothing wrong an "=" in general because I have other functions that use it in order to define what the function is supposed to do.

Here is a bit more of my train of thought and that might help to explain why I am trying to do this in the way that I am.

All of this is geared toward automation and i think that I should be able to write something like:

 
Code
If __PracticeFunctionForStrategy( Condition1 , maLength , kcLength , kcATR , AroonUpLength ) = True 
then Buy....etc.
That should, in my understanding, allow me to test the results using the SMA as part of the criteria for my buy signals.

Otherwise, I can, through the inputs, say that SMA = False and therefore:

 
Code
If __PracticeFunctionForStrategy( Condition2 , maLength , kcLength , kcATR , AroonUpLength ) = True 
then Buy....etc.
This should allow me to test what the results are without the SMA and can then determine if one is more profitable than the other or if it simply does not matter (which I would then remove the SMA from the strategy so as to lower processing requirements)

Of course, it is quite possible that my mental logic is wrong and therefore my coding logic is equally, if not more, wrong.

Does this help to clarify what I am trying to do?

After we are through tackling this part, then I will start back with the "reset" so as to not overload my brain with too much information at one time...(I like small bite size pieces )


Last edited by JGSmith; September 5th, 2013 at 11:12 AM. Reason: a bit more clarity
Reply With Quote

Reply



futures io > > > > > Creating TrueFalse Function

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
DateTime2ELTime Function westsider EasyLanguage Programming 2 October 28th, 2012 05:36 PM
Square root Function sudhirc NinjaTrader 3 March 27th, 2012 02:32 PM
Tables function aquarian1 Feedback and Announcements 3 December 23rd, 2011 10:42 PM
Creating a function to condense code brightredmegaphone NinjaTrader Programming 10 December 17th, 2010 12:27 AM


All times are GMT -4. The time now is 05:11 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-12-18 in 0.13 seconds with 20 queries on phoenix via your IP 23.22.136.56