Differences using "THEN BEGIN ... END;" - EasyLanguage Programming | futures io social trading
futures io futures trading


Differences using "THEN BEGIN ... END;"
Updated: Views / Replies:284 / 7
Created: by djvie11 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 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
 

Differences using "THEN BEGIN ... END;"

  #1 (permalink)
Trading Apprentice
Chicago, IL
 
Futures Experience: Advanced
Platform: Tradestation + Multicharts
Favorite Futures: Forex, Futures
 
Posts: 42 since Jul 2013
Thanks: 25 given, 1 received

Differences using "THEN BEGIN ... END;"

Hey guys

Just curious is there are any big differences between using "THEN BEGIN...END;" and not using them. Below are the sets of instructions I'm trying to compare. I'd like to figure out what (if any) differences would appear when the code executes (the 1st example does not have "THEN BEGIN," and the 2nd one does).

ex1
 
Code
IF
Condition1 
Then 
BUY ("goLong") THIS BAR ; 
IF Condition2
THEN SELL ("coverLong")   THIS BAR ;  

IF Condition5 AND Condition6
THEN SELL ("Trailing_Long") next bar at market ;

  
IF
Condition3
Then 
SELL SHORT ("goShort")  THIS BAR ;
IF
condition4 
THEN BUY to COVER ("coverShort")  THIS BAR ; 

IF condition5 AND Condition6
THEN BUY TO COVER ("Trailing_Short") next bar at market ;
ex2
 
Code
IF
Condition1 
Then BEGIN
BUY ("goLong") this bar ; 
IF Condition2
THEN SELL ("coverLong")   this bar ;  
IF Condition5 AND Condition6
THEN SELL ("Trailing_Long") NEXT BAR AT MARKET ;
END ;
  
IF
Condition3
Then BEGIN
SELL SHORT ("goShort") this bar ;
IF
condition4 
THEN BUY to COVER ("coverShort")  this bar ; 
IF condition5 AND Condition6
THEN BUY TO COVER ("Trailing_Short") NEXT BAR AT MARKET ;
END ;
Any insight would be greatly appreciated!
-Brandon


Last edited by djvie11; November 16th, 2016 at 12:19 PM.
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,373 since Apr 2013
Thanks: 215 given, 783 received
Forum Reputation: Legendary


Brandon,

there will be a difference between the codes and the reason simply is that in case you are using a "if ... then begin... end; " everything within the "begin" and "end" can only be executed while the condition you check for is true.

For you example 1 this means that you "goLong" order will trigger when Condition1 is true and your "coverLong" order triggers in case of Condition2 being true.
In your second example the goLong triggers when Condition1 is true, but due to the "begin" your "coverLong" can only trigger while both Condition1 and Condition2 are valid. Which depending on the actual checks for the conditions can be quite different.

You will have the same effect for your other orders as described for goLong and coverLong.

Regards,

ABCTG

Reply With Quote
The following 3 users say Thank You to ABCTG for this post:
 
  #4 (permalink)
Trading Apprentice
Chicago, IL
 
Futures Experience: Advanced
Platform: Tradestation + Multicharts
Favorite Futures: Forex, Futures
 
Posts: 42 since Jul 2013
Thanks: 25 given, 1 received


ABCTG View Post
Brandon,

there will be a difference between the codes and the reason simply is that in case you are using a "if ... then begin... end; " everything within the "begin" and "end" can only be executed while the condition you check for is true.

For you example 1 this means that you "goLong" order will trigger when Condition1 is true and your "coverLong" order triggers in case of Condition2 being true.
In your second example the goLong triggers when Condition1 is true, but due to the "begin" your "coverLong" can only trigger while both Condition1 and Condition2 are valid. Which depending on the actual checks for the conditions can be quite different.

You will have the same effect for your other orders as described for goLong and coverLong.

Regards,

ABCTG

This is incredibly helpful, thank you ABCTG! Something like this changes how strategies perform a great deal.

I had no idea that when using "THEN BEGIN," All the above conditions had to trigger in order for the others below to trigger as well (ie, not covering a position when needed).

Reply With Quote
 
  #5 (permalink)
Trading Apprentice
Chicago, IL
 
Futures Experience: Advanced
Platform: Tradestation + Multicharts
Favorite Futures: Forex, Futures
 
Posts: 42 since Jul 2013
Thanks: 25 given, 1 received


ABCTG View Post
Brandon,

there will be a difference between the codes and the reason simply is that in case you are using a "if ... then begin... end; " everything within the "begin" and "end" can only be executed while the condition you check for is true.

For you example 1 this means that you "goLong" order will trigger when Condition1 is true and your "coverLong" order triggers in case of Condition2 being true.
In your second example the goLong triggers when Condition1 is true, but due to the "begin" your "coverLong" can only trigger while both Condition1 and Condition2 are valid. Which depending on the actual checks for the conditions can be quite different.

You will have the same effect for your other orders as described for goLong and coverLong.

Regards,

ABCTG

Also, would something like this make more sense as far as order execution goes? Or is "THEN BEGIN / END;" unnecessary for each condition?


 
Code
// long trades
IF
Condition1 
Then BEGIN
BUY ("goLong") this bar ; 
END;

IF MarketPosition = 1 AND Condition2
THEN BEGIN
SELL ("coverLong")   this bar ;  
END;

IF MarketPosition = 1 AND Condition5 AND Condition6
THEN BEGIN
SELL ("bk_Trailing_Long") NEXT BAR AT MARKET ;
END;


// short trades 
IF
Condition3
Then BEGIN
SELL SHORT ("goShort") this bar ;
END;

IF
MarketPosition = -1 AND condition4 
THEN BEGIN
BUY to COVER ("coverShort")  this bar ; 
END;

IF MarketPosition = -1 AND Condition5 AND Condition6
THEN BEGIN
BUY TO COVER ("bkTrailing_Short") NEXT BAR AT MARKET ;
END;
thanks again for your time!


Last edited by djvie11; November 16th, 2016 at 05:29 PM.
Reply With Quote
The following user says Thank You to djvie11 for this post:
 
  #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,373 since Apr 2013
Thanks: 215 given, 783 received
Forum Reputation: Legendary

Brandon,

for the above code the result would be the same when you use "if... then" or "if... then begin... end;".
No advantage, but no disadvantage either.

Regards,

ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #7 (permalink)
Trading Apprentice
Chicago, IL
 
Futures Experience: Advanced
Platform: Tradestation + Multicharts
Favorite Futures: Forex, Futures
 
Posts: 42 since Jul 2013
Thanks: 25 given, 1 received


ABCTG View Post
Brandon,

for the above code the result would be the same when you use "if... then" or "if... then begin... end;".
No advantage, but no disadvantage either.

Regards,

ABCTG

That makes sense, thanks so much! And one last thing .. what about assigning each condition a "MarketPosition" instead of leaving them without one? Would that matter at all?

example 1, all having a "MarketPosition":

 
Code
//buying conditions
IF Marketposition = 0 AND // (currently flat)
Condition1 
Then
BUY ("goLong") THIS BAR ;

IF Marketposition = 1 AND
Condition12
THEN SELL ("coverLong")   THIS BAR ; 

IF Marketposition = 1 AND
Condition5 AND Condition6
THEN SELL ("Trailing_Long") next bar at market ;

//selling conditions  
IF Marketposition = 0 AND // (currently flat)
Condition3
Then SELL SHORT ("goShort")  THIS BAR ;

IF Marketposition = -1 AND
condition13 
THEN BUY to COVER ("coverShort")  THIS BAR ;

IF Marketposition = -1 AND
condition5 AND Condition6
THEN BUY TO COVER ("Trailing_Short") next bar at market ;
example 2, no "MarketPosition" mentioned

 
Code
//buying conditions
IF Condition1 
Then
BUY ("goLong") THIS BAR ;

IF Condition12
THEN SELL ("coverLong")   THIS BAR ; 

IF Condition5 AND Condition6
THEN SELL ("Trailing_Long") next bar at market ;

 // short conditions 
IF Condition3
Then SELL SHORT ("goShort")  THIS BAR ;

IF Condition13 
THEN BUY to COVER ("coverShort")  THIS BAR ;

IF condition5 AND Condition6
THEN BUY TO COVER ("Trailing_Short") next bar at market ;
Your time is appreciated!
-Brandon

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

Brandon,

not knowing your conditions I can't really comment on that. However think about what you do, you add another condition that has to be valid in order for the order to trigger. So it can make a huge difference of course.

I would suggest to test it yourself and see if it makes a difference. After all you must have a rational for adding the MarketPosition as condition and don't just add something because you can.

Regards,

ABCTG

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

Reply



futures io > > > > > Differences using "THEN BEGIN ... END;"

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

July Journal Challenge w/$1100 in prizes from TopstepTrader

July

John @ No BS Day Trading (TBA)

Elite only

An Afternoon with FIO member Softsoap (being rescheduled)

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
NinjaTrader Support on EVERY problem: "we are unable to replicate it in our end" little leo NinjaTrader 30 April 15th, 2016 09:16 PM
Is a front end necessary for TWS and if so which is "best" ......... Overview IB Trader Workstation 12 February 2nd, 2014 08:14 AM
Fukushima: "China Syndrome Is Inevitable" ... "Huge Steam Explosions", or "Nuclear Bo Quick Summary News and Current Events 0 November 22nd, 2011 01:50 AM
How to change "Stop Loss" and "Take Profit" in "shElderImpulse" Strategy javed759 NinjaTrader 1 November 1st, 2011 10:44 PM
"mid", "buy", "sell" volumes lokgotkent Traders Hideout 6 September 30th, 2011 01:24 PM


All times are GMT -4. The time now is 11:22 PM.

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-06-26 in 0.12 seconds with 20 queries on phoenix via your IP 54.224.86.148