bool switch... simple.. - EasyLanguage Programming | futures io social day trading
futures io futures trading


bool switch... simple..
Updated: Views / Replies:3,254 / 37
Created: by toddma Attachments:10

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

bool switch... simple..

  #31 (permalink)
Elite Member
vancouver canada
 
Futures Experience: Intermediate
Platform: multicharts, ninjatrader
Favorite Futures: forex
 
toddma's Avatar
 
Posts: 53 since Jul 2012
Thanks: 14 given, 6 received

Ohhh! Clever...


That was just the "long signal basic" though correct? Does that resolve the issue seen in that close up image for you?

Reply With Quote
 
  #32 (permalink)
Elite Member
Dartmouth NS
 
Futures Experience: Intermediate
Platform: MC, MC.Net, NT, TWS
Broker/Data: IB / IQFeed / Kids
Favorite Futures: Forex, stocks
 
bnichols's Avatar
 
Posts: 638 since Feb 2010
Thanks: 64 given, 459 received

Thanks but in my case not clever so much as persevering :-/ I couldn't see the error until I could duplicate the problem--funny how the mind works.

Reply With Quote
 
  #33 (permalink)
Elite Member
vancouver canada
 
Futures Experience: Intermediate
Platform: multicharts, ninjatrader
Favorite Futures: forex
 
toddma's Avatar
 
Posts: 53 since Jul 2012
Thanks: 14 given, 6 received


Indeed.

Reply With Quote
 
  #34 (permalink)
Elite Member
Dartmouth NS
 
Futures Experience: Intermediate
Platform: MC, MC.Net, NT, TWS
Broker/Data: IB / IQFeed / Kids
Favorite Futures: Forex, stocks
 
bnichols's Avatar
 
Posts: 638 since Feb 2010
Thanks: 64 given, 459 received


toddma View Post
That was just the "long signal basic" though correct? Does that resolve the issue seen in that close up image for you?

You're getting multiple intrabar orders at exits likely because

1. bar magnifier is on
2. entry conditions exist at the time (i.e., fast MA > slow MA); and
3. Your profit exit*** is causing the trade to close very quickly--you might want to confirm you have the symbol settings (scale, movement and bigpointvalue) configured properly.

***
 
Code
// Just a long target
if positionprofit > 4000 then begin
sell ("target") quantity Contracts next bar at market;
CloseTrade = False;
end;
In general (i.e., even with bar magnifier off and no profit exit) new orders will be generated when the last trade closes if entry conditions exist.

Reply With Quote
The following user says Thank You to bnichols for this post:
 
  #35 (permalink)
Elite Member
Netherlands
 
Futures Experience: Advanced
Platform: Ensign, Multicharts
Favorite Futures: SP500
 
Posts: 95 since Nov 2009
Thanks: 66 given, 56 received

Yes, depending on what the entry signal is perhaps you better can use
Cross Above or Cross Below with the MA's

Also all the CloseTrade switches is rather confusing make a condition
and check it rather then switching it on or off

condition1 = close <= keltnerchannellower(close,25,2.5)

if marketposition = 1 AND condition1 then
etc etc



bnichols View Post
If you do not test for flat the line

 
Code
CloseTrade = False;
will be executed every time an entry signal is generated by the MA's whether or not a new position is opened. THIS IS WHAT IS CAUSING THE HAVOC.

Edited to add: not sure why it took so long to manifest itself on my system or why turning bar magnifier on finally triggered it.


Reply With Quote
The following user says Thank You to ehlaban for this post:
 
  #36 (permalink)
Elite Member
vancouver canada
 
Futures Experience: Intermediate
Platform: multicharts, ninjatrader
Favorite Futures: forex
 
toddma's Avatar
 
Posts: 53 since Jul 2012
Thanks: 14 given, 6 received

bnichols -
I have bar magnifier on, but it doesn't seem to be an issue with other scripts I use. I have that profit target turned off for simplicity and all of the exits that follow the entries are "CloseTrade" exits. So it must still have something to do with the CloseTrade code...
If you think about the order of events in the code the CloseTrade exit is last and the last thing in that block is to turn the CloseTrade variable to False. So how could the next bar after re-entering (which also has a CloseTrade = False in it) still execute the CloseTrade Exit further down the code (which requires CloseTrade = True)?

ehlaban -
I don't see how using conditions would replace using the bool variable we have- is that what you are suggesting? I agree it would be simpler and clearer but I don't think the same end goal can be achieved.. ? unless I am missing something?

Reply With Quote
 
  #37 (permalink)
Elite Member
Netherlands
 
Futures Experience: Advanced
Platform: Ensign, Multicharts
Favorite Futures: SP500
 
Posts: 95 since Nov 2009
Thanks: 66 given, 56 received

I now understand the logic about the CloseTrade better. It indeed is a switch.

A thing i noticed is that when exiting a trade next bar at market
it is possible that another buy is given in the same next bar due to the
IntrabarOrder etc etc. You could use sell this bar at close but this code works for me:

 
Code
[IntrabarOrderGeneration = True]

inputs: Num1(40), Num2(60), Num3(18), profitamount(4000);
variables: CloseTrade(false);



If marketposition = 0 then
begin
	CloseTrade = False;

	if Average(close, Num1) Cross Above Average(close, Num2) then 
	buy ("long") next bar at market;
end;

if marketposition = 1 AND CloseTrade = False then
begin
	if Close <= keltnerchannellower(Close, 25, 2.5) then CloseTrade = true;
end;


if marketposition = 1 AND CloseTrade = True then
begin
 	if Close > Average(Close, Num3) then sell ("CloseTrade") next bar at market;
end;


SetStopContract;
SetProfitTarget(profitamount);

Reply With Quote
The following user says Thank You to ehlaban for this post:
 
  #38 (permalink)
Elite Member
vancouver canada
 
Futures Experience: Intermediate
Platform: multicharts, ninjatrader
Favorite Futures: forex
 
toddma's Avatar
 
Posts: 53 since Jul 2012
Thanks: 14 given, 6 received

Hi Ehlaban - I think you've solved this puzzle! I haven't had a chance to take a close look yet, but initially all seems to be functioning as it "should" even with intrabarorder gen!
Great job.
Thanks for your help!

Reply With Quote

Reply



futures io > > > > > bool switch... simple..

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
How often do you switch brokers? Big Mike Reviews of Brokers and Data Feeds 8 August 28th, 2012 03:17 PM
Switch Statement DonStar AmiBroker 7 August 20th, 2012 04:15 PM
Filter switch seeker NinjaTrader Programming 9 July 30th, 2012 07:22 AM
Help : Method + Switch wkmetal NinjaTrader Programming 3 October 25th, 2010 05:51 AM
CalculateOnBarClose as a bool or as a simulation within OnBarUpdate chapter SARdynamite NinjaTrader Programming 5 July 5th, 2010 02:02 AM


All times are GMT -4. The time now is 04:18 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-14 in 0.12 seconds with 36 queries on phoenix via your IP 54.91.38.173