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



Problem with naming multiple entry/exits


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Big Mike with 6 posts (1 thanks)
    2. looks_two equalizer with 6 posts (0 thanks)
    3. looks_3 NW27 with 3 posts (0 thanks)
    4. looks_4 ABCTG with 2 posts (0 thanks)
    1. trending_up 9,757 views
    2. thumb_up 2 thanks given
    3. group 8 followers
    1. forum 21 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Problem with naming multiple entry/exits

(login for full post details)
  #1 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,014 since Jun 2009
Thanks: 32,474 given, 98,315 received

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

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
The following user says Thank You to Big Mike for this post:

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(311 thanks from 30 posts)
looks_twoSalao's Journalby Salao
(81 thanks from 13 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(50 thanks from 21 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(38 thanks from 16 posts)
looks_5Maybe a little bit different journalby Malykubo
(17 thanks from 18 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
The Crude Dude Oil Trading System
124 thanks
Big Mike in Ecuador
45 thanks
Help improve the FIO community
38 thanks
Next New Poll Ideas/Suggestions
20 thanks
futures io site changelog and issues/problem reporting
17 thanks
 
(login for full post details)
  #3 (permalink)
 NW27 
Newcastle, Australia
 
Experience: Intermediate
Platform: Multicharts 8 - Full Version
Broker: IB
Trading: SPI,FTSE100, 6E, 6A
 
Posts: 285 since Oct 2010
Thanks: 108 given, 186 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
 
(login for full post details)
  #4 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,014 since Jun 2009
Thanks: 32,474 given, 98,315 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

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
 NW27 
Newcastle, Australia
 
Experience: Intermediate
Platform: Multicharts 8 - Full Version
Broker: IB
Trading: SPI,FTSE100, 6E, 6A
 
Posts: 285 since Oct 2010
Thanks: 108 given, 186 received

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
 
(login for full post details)
  #6 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,014 since Jun 2009
Thanks: 32,474 given, 98,315 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

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #7 (permalink)
 MultiCharts 
Columbus, Ohio, US
 
Experience: Intermediate
Platform: MultiCharts
Broker: Multiple/Multiple
Trading: ES, EUR/USD
 
MultiCharts's Avatar
 
Posts: 168 since Oct 2010
Thanks: 74 given, 171 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
Follow me on Twitter Reply With Quote
 
(login for full post details)
  #8 (permalink)
equalizer
Las Vegas, Nevada
 
 
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
 
(login for full post details)
  #9 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,014 since Jun 2009
Thanks: 32,474 given, 98,315 received

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

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #10 (permalink)
equalizer
Las Vegas, Nevada
 
 
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
 
(login for full post details)
  #11 (permalink)
 NW27 
Newcastle, Australia
 
Experience: Intermediate
Platform: Multicharts 8 - Full Version
Broker: IB
Trading: SPI,FTSE100, 6E, 6A
 
Posts: 285 since Oct 2010
Thanks: 108 given, 186 received

What version are you running ?
There was an issue with multiple exits and this that was fixed in 7.4 (build 5032)
Version 8 may be ok?


Thanks,
Neil.

(Sent from my Galaxy S2 via Tapatalk)

Reply With Quote
 
(login for full post details)
  #12 (permalink)
equalizer
Las Vegas, Nevada
 
 
Posts: 10 since Mar 2012
Thanks: 1 given, 0 received

7.4 4953 - so maybe this was just fixed? (I guess MC doesn't have an autoupdater/checker, right - so I should get used to checking for new versions like I do with TWS...) I will attempt an update when I can take it offline again.

Reply With Quote
 
(login for full post details)
  #13 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,014 since Jun 2009
Thanks: 32,474 given, 98,315 received


equalizer View Post
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).

My understanding is SetStopContract modifies behavior of stop loss and profit target orders. Without specifying this reserve word, a single uniform "all out" stop is hit for both stop losses and profit targets, whereas if you do specify it, the stops and targets are unique for each entry order.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #14 (permalink)
equalizer
Las Vegas, Nevada
 
 
Posts: 10 since Mar 2012
Thanks: 1 given, 0 received


Big Mike View Post
My understanding is SetStopContract modifies behavior of stop loss and profit target orders. Without specifying this reserve word, a single uniform "all out" stop is hit for both stop losses and profit targets, whereas if you do specify it, the stops and targets are unique for each entry order.

Mike


Interesting - my understanding was different; I thought it meant that SetStopPosition will mean that the dollar amount fed to SetStopLoss(amount) will be calculated off the entire position, whereas with SetStopContract will mean the amount is the amount lost per contract/share; but that in either case, the entire position will be closed.

That's why I always ended up implementing my own stop order logic for any stops beyond the initial "worst case" stop - because the built-in stop, while easy to use in that it's always calculating every tick without any additional work, will always close out the whole position (and has to be set across the board at all times).

Are you saying it's possible to customize it per order? Perhaps using From Entry("name") could be used with it? I still don't think so though - that's why the included Stop Loss Strategy (only several lines total) can be applied to the chart with any other built-in strategy, because it's always for the whole position.

I hope my understanding is wrong though!

Reply With Quote
 
(login for full post details)
  #15 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,014 since Jun 2009
Thanks: 32,474 given, 98,315 received

You can't customize it per order. I have an open PM request to address that, but no word yet.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #16 (permalink)
equalizer
Las Vegas, Nevada
 
 
Posts: 10 since Mar 2012
Thanks: 1 given, 0 received


Big Mike View Post
My understanding is SetStopContract modifies behavior of stop loss and profit target orders. Without specifying this reserve word, a single uniform "all out" stop is hit for both stop losses and profit targets, whereas if you do specify it, the stops and targets are unique for each entry order.

I guess I am not sure what you meant by this then. Again, I think it only specifies if the dollar amount is for the whole position, or per contract - not whether it applies to a stop loss vs. a profit taking order. But if I am missing something, it would be pretty important to know the subtleties.

That's great you have an active request regarding customing it per order (by name or id). I too think it would be a pretty important feature.

Reply With Quote
 
(login for full post details)
  #17 (permalink)
lismore
Zurich/Switzerland
 
 
Posts: 1 since Jul 2012
Thanks: 0 given, 0 received

Could you provide an example of tied exits (stoploss and profit target) to each of these entries? Tks.

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;

Reply With Quote
 
(login for full post details)
  #18 (permalink)
equalizer
Las Vegas, Nevada
 
 
Posts: 10 since Mar 2012
Thanks: 1 given, 0 received

You cannot tie those exits to each entry as far as I understood (but can set it for the same number of shares per entry). This is one of reasons I ended up migrating to Amibroker, so I am afraid I won't be able to assist further. Perhaps Mike can.

Reply With Quote
 
(login for full post details)
  #19 (permalink)
 bomberone1 
London
 
Experience: Beginner
Platform: MultiCharts
 
Posts: 240 since Nov 2010
Thanks: 10 given, 23 received

Any Solution?

Reply With Quote
 
(login for full post details)
  #20 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,238 since Apr 2013
Thanks: 417 given, 1,489 received

bomberone1,

a solution to what particular problem in this thread? There might be solutions now.

Regards,

ABCTG


bomberone1 View Post
Any Solution?


Follow me on Twitter Reply With Quote
 
(login for full post details)
  #21 (permalink)
 gero 
milano
 
Experience: Intermediate
Platform: tradestation
 
Posts: 4 since May 2010
Thanks: 9 given, 1 received

The solution is now available with MC dynamic order name capability, see this thread:

Setting dynamic order name - MultiCharts

Reply With Quote
The following user says Thank You to gero for this post:
 
(login for full post details)
  #22 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,238 since Apr 2013
Thanks: 417 given, 1,489 received


gero View Post
The solution is now available with MC dynamic order name capability, see this thread:

Setting dynamic order name - MultiCharts

gero,

that's correct, but as far as I am aware Multicharts won't still let you do that within a loop (which I misread in the thread above - as no one used a loop, a switch/case statement on the other hand will work fine).
However a workaround for that is that you can dynamically set the order name within the loop and then use it later.

Regards,

ABCTG

Follow me on Twitter Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Problem with naming multiple entry/exits


Last Updated on July 26, 2016


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April

An Introduction to CME Group Micro Bitcoin Futures w/David Lerman

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), 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