NexusFi: Find Your Edge


Home Menu

 





RISTRICTING ENTRY LIMIT ORDER TO ONE BAR ONLY


Discussion in MultiCharts

Updated
    1. trending_up 1,353 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

RISTRICTING ENTRY LIMIT ORDER TO ONE BAR ONLY

  #1 (permalink)
Tiforp
Cambridge, UK
 
Posts: 5 since Jun 2010
Thanks Given: 1
Thanks Received: 1

I am frustrated when unfilled limit or stop entry orders carry on to the next bar. It does not happen to often, but is quite troublesome when it does.

Therefore, I shall be very appreciative for programming help to ensure via strategy code so any unfilled entry position stop order / limit order is cancelled at the end of day, or bar, and does not carry to the next session.

Below are two entry instructions examples:
  1. sellshort next bar at open next bar + .05 Limit;
  2. if condition1 = true then buy next bar at currentbid limit;

Thank you in advance.

Tiforp

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
What broker to use for trading palladium futures
Commodities
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
About a successful futures trader who didnt know anythin …
Psychology and Money Management
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Tiforp,

Multicharts will keep an order alive as along as the condition that triggered the order is valid. You can use this by adding a condition to your order that you set to false X bars after you set it to true. You could for example store the bar number when you want to issue the order in a variable (let's call it "longOrderBar"). Then check for the current bar being equal to this variable before you issue your order - this wouldn't require resetting the condition,
as it becomes false on subsequent bars.

 
Code
if CurrentBar = longOrderBar then
 SellShort...
Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
Tiforp
Cambridge, UK
 
Posts: 5 since Jun 2010
Thanks Given: 1
Thanks Received: 1



ABCTG View Post
Tiforp,

Multicharts will keep an order alive as along as the condition that triggered the order is valid. You can use this by adding a condition to your order that you set to false X bars after you set it to true. You could for example store the bar number when you want to issue the order in a variable (let's call it "longOrderBar"). Then check for the current bar being equal to this variable before you issue your order - this wouldn't require resetting the condition,
as it becomes false on subsequent bars.

 
Code
if CurrentBar = longOrderBar then
 SellShort...
Regards,

ABCTG

ABCTG,

Thank you for your help. Verpflichtet.

Reply With Quote
Thanked by:
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Tiforp,

you are welcome.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #5 (permalink)
Tiforp
Cambridge, UK
 
Posts: 5 since Jun 2010
Thanks Given: 1
Thanks Received: 1

ABCTG,

After you kind reply I did try to write a working code, but obviously have missed certain key elements because it complies but does not execute any trades. Most probably I have missed out correctly completing the “CurrentBar” and “longOrderBar”:

1. CurrentBar[ StdFunction ] : Return(Numeric)
2. longOrderBar[ Variable ] : NumericSimple

It appears simple enough, but I cannot seem to make any progress!

My full code is included. Any help once again shall be greatly appreciate.

Thank you.

 
Code
Inputs: 
MyContracts (1          { Indicate number of contracts to trade}),
StartTime   (900       { Designate valid intraday start-trading time}),
NumBarsP    (5          { Number of bars since entry});

Variables:
longOrderBar (0         { To ensure any unfilled entry order is not carried to the next bar });
     
If ( Time = StartTime )and CurrentBar[0] = longOrderBar Then  
     Begin
          SellShort("")  MyContracts Contracts next bar at CurrentAsk Limit;
     End;
     
 { --- Exit at N bars since entry --- }
      
 If ( NumBarsP > 0 ) Then
     Begin
          If marketposition = -1 and BarsSinceEntry >= NumBarsP Then Buytocover("Stop") MyContracts contracts next bar at Market;      
     End;

Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Tiforp,

you can use the print reserved word, to check the values of the variables in your code on every bar.

As I wrote above "You could for example store the bar number when you want to issue the order in a variable (let's call it "longOrderBar")." Your code doesn't store the bar number when you want to issue the order. That's what you will have to do first, before checking for CurrentBar = longOrderBar. Otherwise longOrderBar will have a value of 0. CurrentBar on the other hand will always be greater than 0 and in turn your condition will never be true and you would see no trade entries.

From looking at your code and under the condition that you are on time based intraday charts, checking for "( Time = StartTime )" should be true only once per day. Which would already limit the order to one bar.

Regards,

ABCTG

Follow me on Twitter Reply With Quote




Last Updated on February 5, 2018


© 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