NexusFi: Find Your Edge


Home Menu

 





Using Limit entry, how to know if entry was execute - Multicharts


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one arjfca with 6 posts (0 thanks)
    2. looks_two Jeff65 with 4 posts (7 thanks)
    3. looks_3 Big Mike with 1 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 9,864 views
    2. thumb_up 8 thanks given
    3. group 2 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Using Limit entry, how to know if entry was execute - Multicharts

  #1 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91

Hello again to all

With Multicharts and IB as a broker,

I'm using a limit entry order like

 
Code
 
[ SellShort ("Short1b") ShortSizeOfOrder contracts next bar at ShortEntryPrice Limit;
MC will cancel the order if the limit price was not reach before the end of the bar. I need to set a flag at the begining of the next bar to confirm that the order as been execute. How can i do it?


Martin

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,397 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537



arjfca View Post
Hello again to all

With Multicharts and IB as a broker,

I'm using a limit entry order like

 
Code
 
[ SellShort ("Short1b") ShortSizeOfOrder contracts next bar at ShortEntryPrice Limit;
MC will cancel the order if the limit price was not reach before the end of the bar. I need to set a flag at the begining of the next bar to confirm that the order as been execute. How can i do it?


Martin

The simplest way would be to look at MarketPosition and see if it is right (0 flat, 1 long, -1 short). There is also EntryPrice(0) to see the last execution entry price, it may be helpful to you.

But if you are scaling in or out then this may not be sufficient for you. So you could look at BarsSinceEntry as well as CurrentContracts, and figure out where you stand.

All of this is in the help under 'Strategy Positions'.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
Jeff65
Gurnee, IL
 
Posts: 46 since Apr 2010
Thanks Given: 17
Thanks Received: 97


arjfca View Post
Hello again to all

With Multicharts and IB as a broker,

I'm using a limit entry order like

 
Code
 
[ SellShort ("Short1b") ShortSizeOfOrder contracts next bar at ShortEntryPrice Limit;
MC will cancel the order if the limit price was not reach before the end of the bar. I need to set a flag at the begining of the next bar to confirm that the order as been execute. How can i do it?


Martin

This might help. The following code will tell you if a new position was entered.

 
Code
Variables:
MP(0);


MP = MarketPosition;

If ( MP <> 0 ) And ( MP[1] = 0 ) Then
Begin
    // A new position was just entered 
End;

Reply With Quote
Thanked by:
  #5 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91

Thanks

My programmed strategy look to enter on all valid signals, even in the same direction. Each trade is manage independently. Up to ten trades per direction. So marketposition is not reliable if trade as occured or not.

I will look for arround Big Mike solution with BarsSinceEntry as well as CurrentContracts.

This verification to be done for bar status = 1 (beginning of a bar) for the first bar following the entry bar.

Martin

Started this thread Reply With Quote
  #6 (permalink)
Jeff65
Gurnee, IL
 
Posts: 46 since Apr 2010
Thanks Given: 17
Thanks Received: 97


arjfca View Post
Thanks

My programmed strategy look to enter on all valid signals, even in the same direction. Each trade is manage independently. Up to ten trades per direction. So marketposition is not reliable if trade as occured or not.

I will look for arround Big Mike solution with BarsSinceEntry as well as CurrentContracts.

This verification to be done for bar status = 1 (beginning of a bar) for the first bar following the entry bar.

Martin

This might help.

With multiple trades you can manage them independently by using the function "CurrentEntries". Create a variable to hold this value and manage each trade by how many current entries there are.

 
Code
CE = CurrentEntries;

      If ( MP = 1 ) Then
      Begin
              If (  CE  = 1 ) Then {manage one entry}
              If (  CE  = 2 ) Then {Manage two entries }
              If (  CE  = 3 ) Then {Manage three entries }
      End
      Else If ( MP = -1 ) Then
      Begin
              If (  CE  = 1 ) Then {manage one entry}
              If (  CE  = 2 ) Then {Manage two entries }
              If (  CE  = 3 ) Then {Manage three entries }
      End

Reply With Quote
Thanked by:
  #7 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91


Jeff65 View Post
This might help.

With multiple trades you can manage them independently by using the function "CurrentEntries". Create a variable to hold this value and manage each trade by how many current entries there are.

 
Code
 
CE = CurrentEntries;
 
      If ( MP = 1 ) Then
      Begin
              If (  CE  = 1 ) Then {manage one entry}
              If (  CE  = 2 ) Then {Manage two entries }
              If (  CE  = 3 ) Then {Manage three entries }
      End
      Else If ( MP = -1 ) Then
      Begin
              If (  CE  = 1 ) Then {manage one entry}
              If (  CE  = 2 ) Then {Manage two entries }
              If (  CE  = 3 ) Then {Manage three entries }
      End


Thank Jeff

As mention is EL reference, This solution is only applicable in the development and evaluation stage. It could not be applied in live trading

 
Code
                            
[LEFT]CurrentEntries (Reserved Word)
Disclaimer
Returns the number of entries currently open within a position
.
Remarks
This 
function can only be used in the evaluation of strategies.
Example[/LEFT]
CurrentEntries returns a value of 3 if the strategy has made 3 entries in the current open position
Martin

Started this thread Reply With Quote
  #8 (permalink)
Jeff65
Gurnee, IL
 
Posts: 46 since Apr 2010
Thanks Given: 17
Thanks Received: 97


arjfca View Post
Thank Jeff

As mention is EL reference, This solution is only applicable in the development and evaluation stage. It could not be applied in live trading

 
Code
                            
[LEFT]CurrentEntries (Reserved Word)

Disclaimer
Returns the number of entries currently open within a position
.
Remarks
This 
function can only be used in the evaluation of strategies.
Example[/LEFT]
CurrentEntries returns a value of 3 if the strategy has made 3 entries in the current open position
Martin

Matrin,

In this case I think you have to label each new entry with an entry label (buy "LE1", buy "LE2", buy "LE3 ...). You'll have to be clever and place these orders with their unique label based on the current shares or contracts you are currently holding. In the end you will have 10 such labels.

Then you can reference each entry as an individual trade with the "From Entry" command such as ...

Sell 1 contract from entry ("LE2") next bar at market ;

In this case the contract from the second buy order is sold at market.

I have not personally coded multi-entry and multi-exits strategies, so I'm not sure if this will work. If I get some time this weekend I can try to code it up and test it.

I have done single entry, multi-exit, but this is different. Hope this helps.

Reply With Quote
Thanked by:
  #9 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91

Good day Jeff / Mike and others

Some code has been developed for me using this approach. Each entry having a different name. Up to to entry's per sides. But the problem persist as the orders are done at market. I'm looking for a limit or stop orders.

With these conditionnals entrys, if price not reach, orders are cancelled. No problem as this is done by MC. Order are canceled automatically at the end of a period if not execute. My interrogation is about orders that where executed. I need a flag or a variable that will confirm it. A unique flag to a unique reason for this entry

A solution could be to compare how many contract in the account before sending the order and comparing at the end. This wont produce a solid system as there is no direct link from an order to the entry. If two programmed systems where issuing similar quantity order, but at a different price and only one was executed, it would be difficult to attribute a position to is system. As entry price could be different as the calculated one.

My conceptual solution could be to ( I dont know if it is possible with MC)
- Issue an order
- Capture the order number from broker
- Capture and read back after each period a trade journal where , executed orders are linked to a new position and a new position number related to it.
- From my database ( array) compare the executed order and attach it to the new position number.

Being able to do it, it will create a solid and accurate plateform. Where orders and positions are linked.

Easier said than done for me. I'm not a programmer and I'm new with MC. I was doing it manually before. A verry fastudious job.

Quest continu.

Martin

Started this thread Reply With Quote
  #10 (permalink)
Jeff65
Gurnee, IL
 
Posts: 46 since Apr 2010
Thanks Given: 17
Thanks Received: 97



arjfca View Post
Good day Jeff / Mike and others

Some code has been developed for me using this approach. Each entry having a different name. Up to to entry's per sides. But the problem persist as the orders are done at market. I'm looking for a limit or stop orders.

With these conditionnals entrys, if price not reach, orders are cancelled. No problem as this is done by MC. Order are canceled automatically at the end of a period if not execute. My interrogation is about orders that where executed. I need a flag or a variable that will confirm it. A unique flag to a unique reason for this entry

A solution could be to compare how many contract in the account before sending the order and comparing at the end. This wont produce a solid system as there is no direct link from an order to the entry. If two programmed systems where issuing similar quantity order, but at a different price and only one was executed, it would be difficult to attribute a position to is system. As entry price could be different as the calculated one.

My conceptual solution could be to ( I dont know if it is possible with MC)
- Issue an order
- Capture the order number from broker
- Capture and read back after each period a trade journal where , executed orders are linked to a new position and a new position number related to it.
- From my database ( array) compare the executed order and attach it to the new position number.

Being able to do it, it will create a solid and accurate plateform. Where orders and positions are linked.

Easier said than done for me. I'm not a programmer and I'm new with MC. I was doing it manually before. A verry fastudious job.

Quest continu.

Martin

My code example below was written before I read your most recent post. Anyway, it is an example of naming entry orders and using the "from entry" syntax to exit. All orders are done at market.

Place this system on the daily bar chart of S&P Emini and watch the money roll in! You can pay me my fee later. It buys 1 contract when the RSI falls below 10 and another contract when it falls below 5. It only takes trades when price is above the 200-period simple moving average. Two independent exits are triggered when price closes above a their respected moving average. Oh, be sure to set your pyramiding configuration on your chart to "2" or this strategy will not work.

As for your most recent post, I may be confused, but this is my understanding. You are entering on limit orders correct? You want to verify that each limit order was actually filled, correct? Is this what you mean when you say you want a "flag" to confirm an entry? If this is true and you know how many contracts you place at each entry point than you can use currentcontracts to interrogate how many of your limit orders have been filled. Am I understanding you correctly?

 
Code
Input: Lookback(2), ExitBars(5);

Variables: Exit1(0), Exit2(0), MP(0), RSI_Value(0), MA200(0);

RSI_Value   = RSI( Close,Lookback );
MA200       = Average( Close, 200 );
Exit1       = Average( Close, 10 );
Exit2       = Average( Close, 5 );
MP          = MarketPosition;

// Enter first position when we first go below threshold 10 on rsi
If (  RSI_Value <= 10 ) And ( Close > MA200 ) And ( MP = 0 ) Then 
   buy ("LE1") 1 contract this bar at close;

// Enter second position if we go below threshold 5 on rsi
If (  RSI_Value <= 5 ) And ( Close > MA200 ) Then
   buy ("LE2") 1 contract this bar at close;

// Exit contracts from LE2 when hit exit price
If ( MP = 1 ) And ( CurrentContracts = 2 ) And ( Close > Exit2 ) Then 
   Sell from entry ("LE2" ) this bar at close;
   
// Exit contracts from LE1 when hit exit price
If ( MP = 1 ) And ( CurrentContracts = 1 ) And ( Close > Exit1 )Then 
   Sell from entry ("LE1" ) this bar at close;

Reply With Quote
Thanked by:




Last Updated on November 24, 2010


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts