Problem with naming multiple entry/exits - EasyLanguage Programming | futures.io
futures io futures trading


Problem with naming multiple entry/exits
Started: by Big Mike Views / Replies:4,440 / 21
Last Reply: Attachments:0

Welcome to futures io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • 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, and we will never resell your private information.

-- Big Mike

Reply
 
Thread Tools Search this Thread
 

Problem with naming multiple entry/exits

  #1 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 45,803 since Jun 2009
Thanks: 29,097 given, 81,377 received

Problem with naming multiple entry/exits

I can't make this work.

The error is:
 
Code
------ Compiled with error(s): ------
syntax error, unexpected 'identificator', expecting 'string constant'
errLine 105, errColumn 7, errLineEnd 105, errColumnEnd 7
causal study:  (Function)
What I am trying to do is name each entry with a unique name, but without doing it manually.

An example of manually doing it:
 
Code
		switch (CurrentContracts)
		begin
			case 0: 	Buy ("LE # 1") 1 Contract Next Bar At MaxList(InsideAsk, MinList(sr, srskip, Lowest(Low, skiplength) + TickSize)) Limit;
			case 1: 	Buy ("LE # 2") 1 Contract Next Bar At MaxList(InsideAsk, MinList(sr, srskip, Lowest(Low, skiplength) + TickSize)) Limit;
			case 2: 	Buy ("LE # 3") 1 Contract Next Bar At MaxList(InsideAsk, MinList(sr, srskip, Lowest(Low, skiplength) + TickSize)) Limit;
			case 3: 	Buy ("LE # 4") 1 Contract Next Bar At MaxList(InsideAsk, MinList(sr, srskip, Lowest(Low, skiplength) + TickSize)) Limit;
			case 4: 	Buy ("LE # 5") 1 Contract Next Bar At MaxList(InsideAsk, MinList(sr, srskip, Lowest(Low, skiplength) + TickSize)) Limit;
			case 5: 	Buy ("LE # 6") 1 Contract Next Bar At MaxList(InsideAsk, MinList(sr, srskip, Lowest(Low, skiplength) + TickSize)) Limit;
			case 6: 	Buy ("LE # 7") 1 Contract Next Bar At MaxList(InsideAsk, MinList(sr, srskip, Lowest(Low, skiplength) + TickSize)) Limit;
			case 7: 	Buy ("LE # 8") 1 Contract Next Bar At MaxList(InsideAsk, MinList(sr, srskip, Lowest(Low, skiplength) + TickSize)) Limit;
			case 8: 	Buy ("LE # 9") 1 Contract Next Bar At MaxList(InsideAsk, MinList(sr, srskip, Lowest(Low, skiplength) + TickSize)) Limit;
			case 9: 	Buy ("LE # 10") 1 Contract Next Bar At MaxList(InsideAsk, MinList(sr, srskip, Lowest(Low, skiplength) + TickSize)) Limit;
		end;
That is what I want to avoid, because I have to build a 10 case/switch routine about 20 times in my code.

I've tried:
Buy ("LE # ", CurrentContracts + 1)

I've tried:
Buy (Text("LE # ", CurrentContracts + 1))

I've tried:
Buy (NumToStr(CurrentContracts, 0))

I've even tried just making one switch/case statement, like so:
 
Code
switch (CurrentContracts)
begin

	case 0:	begin nextlongname = "LE # 1"; nextshortname = "SE # 1"; end;
	case 1:	begin nextlongname = "LE # 2"; nextshortname = "SE # 2"; end;
	case 2:	begin nextlongname = "LE # 3"; nextshortname = "SE # 3"; end;
	case 3:	begin nextlongname = "LE # 4"; nextshortname = "SE # 4"; end;
	case 4:	begin nextlongname = "LE # 5"; nextshortname = "SE # 5"; end;
	case 5:	begin nextlongname = "LE # 6"; nextshortname = "SE # 6"; end;
	case 6:	begin nextlongname = "LE # 7"; nextshortname = "SE # 7"; end;
	case 7:	begin nextlongname = "LE # 8"; nextshortname = "SE # 8"; end;
	case 8:	begin nextlongname = "LE # 9"; nextshortname = "SE # 9"; end;
	case 9:	begin nextlongname = "LE # 10"; nextshortname = "SE # 10"; end;

end;
And then using:
Buy (nextlongname)

But same problem.

All result in the error posted above.

I am exploring other ways to get around this, but it seems like I must be doing something wrong.... surely this should work, yes?

The whole point of this is to granularly control a specific entry/exit point. I'm toying with using the PosTrade* reserve words but it would be far easier if I could just properly name the entries using a string.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:
 
  #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
Newcastle, Australia
 
Futures Experience: Intermediate
Platform: Multicharts 8 - Full Version
Broker/Data: IB
Favorite Futures: SPI,FTSE100, 6E, 6A
 
Posts: 285 since Oct 2010
Thanks: 108 given, 176 received


Hi Mike
I had the same issue but with exits.
I wanted the exits in the report to properly reflect the reason for the exit.
I found the same issue, can't use strings in the sell order line.
So i ended up with the case statement style of thing like you.

Thanks,
Neil.

(Sent from my Galaxy S2 via Tapatalk)

Reply With Quote
 
  #4 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 45,803 since Jun 2009
Thanks: 29,097 given, 81,377 received

Worse, I later found out that each name has to be unique. So in all the different sections of my code, I wanted Contract #1 to always be referred to as "LE" or "SE" then "#1" for example. But it won't let me do that, as I already used that name in the code.

And it won't let me apply a CurrentBar modifier to the string....

Pretty neat.

For now, I have worked around it using a whole slew of switch/case statements, adding over 400 lines of code to my strategy.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #5 (permalink)
Elite Member
Newcastle, Australia
 
Futures Experience: Intermediate
Platform: Multicharts 8 - Full Version
Broker/Data: IB
Favorite Futures: SPI,FTSE100, 6E, 6A
 
Posts: 285 since Oct 2010
Thanks: 108 given, 176 received

Futures Edge on FIO
Hi Mike
I had the same issue.
What i did was use a variable early in the code and just one set of orders at the end.
How about i send you the code. Send me a pm with your email .

Thanks,
Neil.

(Sent from my Galaxy S2 via Tapatalk)

Reply With Quote
 
  #6 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 45,803 since Jun 2009
Thanks: 29,097 given, 81,377 received

I did some extra testing right now and it seems named orders are not at all what I was expecting anyway.

I wanted to name an order so I could manipulate that specific order later, by name. But it is not possible (by name), because of the "order name already in use" thing I mentioned earlier.

So for now I am just using PosTrade* and OpenEntry* reserve words to try and identify orders. I will need to rethink all this, it seems much too difficult compared to what it should be. I've asked MultiCharts for help in case I am missing something obvious.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #7 (permalink)
 Vendor: www.multicharts.com 
Columbus, Ohio, US
 
Futures Experience: Intermediate
Platform: MultiCharts
Broker/Data: Multiple/Multiple
Favorite Futures: ES, EUR/USD
 
MultiCharts's Avatar
 
Posts: 168 since Oct 2010
Thanks: 74 given, 170 received

Hi Mike,

In MultiCharts the entries cannot be changed dynamically. They should be static from the very beginning of the script calculation in order to generate entries and exits properly.

The example script below shows the proper order naming routine:


 
Code
Var: PosNum(0),PosPrice1(0),PosPrice2(0),PosPrice3(0);   
 
switch (PosNum) begin
 
               case 1: Buy ("LE # 1") 1 Contract Next Bar At PosPrice1 Limit;
               case 2: Buy ("LE # 2") 1 Contract Next Bar At PosPrice2 Limit;
               case 3: Buy ("LE # 3") 1 Contract Next Bar At PosPrice3 Limit;
 
end; 

MultiCharts - Raising the Trading Standard.
Please send me a private message if you have any further questions about MultiCharts
Reply With Quote
 
  #8 (permalink)
Trading Apprentice
Las Vegas, Nevada
 
Futures Experience: Intermediate
Platform: MultiCharts
Favorite Futures: Forex
 
Posts: 10 since Mar 2012
Thanks: 1 given, 0 received

I encountered a similar issue - but it doesn't quite jive. I tried to set up an automatic scale out where it calculates the total order size divided by the number of units to be scaled out.

So then I encountered the unique name issue - tried using a String variable to name it, saw that it won't allow that. Tried the if/else or switch statement approach (or simply using NO name), and while that works, it only seems to do it once in my backtesting. basically, i have a catch-all in case the remaining quantity is too small to be divided in half.

When I backtest, my debug output says its issuing all the orders to sell, followed by the final. But no matter what I've tried, the chart and trade list will only show the first one, followed by the final one for the remaining size.

So my code confirms the strategy is working code-wise by outputing, for example:

Position Size: 100000
ScaleOut order #1 set for: 25000
Position Size: 75000
ScaleOut order #2 set for: 25000
Position Size: 50000
ScaleOut order #3 set for: 25000
Position Size: 25000
FINAL ScaleOut order set for: 25000

But on the chart, it will only show ScaleOut order #1 for 25000, then the next one will be the FINAL scaleout order, and for 75000!

Again, I believe I tried all the combinations of allowing multiple orders per bar. Is this some other limitation of intrabarorder generation?

Thanks...

Reply With Quote
 
  #9 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 45,803 since Jun 2009
Thanks: 29,097 given, 81,377 received

Make sure you are using SetStopContract (or whatever equivalent for Shares), as it effects targets as well as stops.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #10 (permalink)
Trading Apprentice
Las Vegas, Nevada
 
Futures Experience: Intermediate
Platform: MultiCharts
Favorite Futures: Forex
 
Posts: 10 since Mar 2012
Thanks: 1 given, 0 received


I think Contract and Share are equivalent. SetStopContract is for the built-in stop though (which I am using for initial stop loss, but not for my custom trailing stop).

All that aside, I am not using stop orders (well I was, but then I changed it to market to see if that was the issue). So it's just a market order like this:

 
Code
Sell ("Out Order name") From Entry("Long Entry") outSize Contracts Next Bar At Market;
I was thinking maybe you cannot split one entry multiple times? So I could try issuing multiple order entries, but that would really not be ideal since there's a minimum commission at IB (basically 100,000 costs the same as 20,000 for forex). I realize I am splitting to less than ideal size when I exit, but I can live with that because it's for profit taking and also because I will ensure it's always trading full lots once I see it tested live more.

But perhaps that's the only way?

I worked with TradeStation a lot several years ago and I seem to remember being able to split one entry into multipel exits for stocks at that time, but, it was a long, long time ago.

Reply With Quote

Reply



futures io > > > > > Problem with naming multiple entry/exits

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Spring Grains Outlook w/Sean Lusk @ Walsh Trading

Elite only

FIO Video Journal Challenge featuring NinjaTrader ($2,000+ of prizes)

April

Process above all else w/Anthony Crudele @ Futures Radio Show

Elite only

Machine Learning - Quantitative Trading w/Martin Froehler @ Quantiacs

Elite only

Market Dynamics w/Peter Davies @ Jigsaw Trading

Elite only

Ask Me Anything w/Patrick Rooney @ Trading Technologies

Apr 18

Ask Me Anything w/FuturesTrader71

Apr 19

Machine Learning w/Kris Longmore

Elite only

Market Analysis w/Dave Forss

Apr 25

Introducing iSystems with Stage 5 Trading

Apr 27
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
re coding for entry/exits in easylanguage baz111 EasyLanguage Programming 1 December 28th, 2011 06:17 AM
NinjaTrader custom indicator problem with multiple data series - freezing TraderOfFortune NinjaTrader Programming 17 December 22nd, 2011 06:29 PM
MULTIPLE ORDER ENTRY gparkis NinjaTrader 9 May 17th, 2011 10:25 AM
Using Limit entry, how to know if entry was execute - Multicharts arjfca EasyLanguage Programming 11 November 24th, 2010 04:33 PM
Need help with order entry on multiple dataseries bobbakerr EasyLanguage Programming 20 August 29th, 2010 09:03 AM


All times are GMT -4. The time now is 07:03 AM.

no new posts
Page generated 2017-03-27 in 0.13 seconds with 19 queries on phoenix via your IP 54.211.169.76