NexusFi: Find Your Edge


Home Menu

 





EasyLanguage, Mulitcharts and Limit Orders


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one nismo with 6 posts (3 thanks)
    2. looks_two guppy with 6 posts (0 thanks)
    3. looks_3 Nicolas11 with 5 posts (4 thanks)
    4. looks_4 Big Mike with 5 posts (10 thanks)
      Best Posters
    1. looks_one RM99 with 2.5 thanks per post
    2. looks_two Big Mike with 2 thanks per post
    3. looks_3 Nicolas11 with 0.8 thanks per post
    4. looks_4 nismo with 0.5 thanks per post
    1. trending_up 24,708 views
    2. thumb_up 22 thanks given
    3. group 8 followers
    1. forum 28 posts
    2. attach_file 4 attachments




 
Search this Thread

EasyLanguage, Mulitcharts and Limit Orders

(login for full post details)
  #11 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Posts: 50,234 since Jun 2009
Thanks Given: 33,106
Thanks Received: 101,351

Buy 1 Contract Next Bar at 1.4450 Limit;

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


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


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive 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

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trader Dale [email protected] or Scammer Dale
Trading Reviews and Vendors
Request for MACD with option to use different MAs for fa …
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Tao te Trade: way of the WLD
30 thanks
Supertradersams Thread Journal on NQ/MNQ
25 thanks
Deaddogs Stock Trading
23 thanks
GFIs1 1 DAX trade per day journal
22 thanks
Daytrading ES & NQ
13 thanks

(login for full post details)
  #12 (permalink)
 RM99 
Austin, TX
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 839 since Mar 2011
Thanks Given: 124
Thanks Received: 704

I recommend issuing orders at the bid/ask and applying some sort of momentum cushion.

In high velocity markets, your limit order can get skipped if you try to issue at an open price.


inputs: pricegap(.01);

If (entry criteria) then buy next bar at currentask + pricegap;
If (entry criteria) then sellshort next bar at currentbid - pricegap;

etc.

you can also make pricegap a variable that adjusts according to the market volitility/velocity. In higher velocity markets, it can be larger and it slow markets, you can have it converge to zero.

Also, with tradestation, limit order does not equal "limit if touched."

They make it really complicated, so you should research on MC to ensure that the two are analogous.

A limit if touched order only gets issued if the price is touched. A limit order gets submitted immediately.

The difference might seem trivial, but it's relevant when trying to implement additional risk management.

TS limits orders from being issued more frequently than 15 seconds apart. Anything beyond 15 seconds, TS will maintain the order on their stop server. If you violate the 15 second rule, the order will be maintained on your machine. In the event that your machine crashes or loses connection, orders that are not maintained at the stopserver will not be valid.

You should verify with MC if there are similar limitations.

Obviously, depending on your trading style, risk tolerance, money management, trading hours, etc, one or the other might be preferable.

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
The following 3 users say Thank You to RM99 for this post:
(login for full post details)
  #13 (permalink)
nismo
Australia
 
Posts: 32 since Dec 2010
Thanks Given: 7
Thanks Received: 3



RM99 View Post
I recommend issuing orders at the bid/ask and applying some sort of momentum cushion.

In high velocity markets, your limit order can get skipped if you try to issue at an open price.


inputs: pricegap(.01);

If (entry criteria) then buy next bar at currentask + pricegap;
If (entry criteria) then sellshort next bar at currentbid - pricegap;

etc.

you can also make pricegap a variable that adjusts according to the market volitility/velocity. In higher velocity markets, it can be larger and it slow markets, you can have it converge to zero.

Great post thats exactly what I was getting at with your suggestion of pricegap in my first post, point 2.

Also using currentask and currentbid seems better.

Say you've got a chart that is set to bid and you issue a limit order based on the current bid price I'm guessing its going to get missed straight away as the ask price will be higher by what ever the spread is...

Reply With Quote
(login for full post details)
  #14 (permalink)
 RM99 
Austin, TX
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 839 since Mar 2011
Thanks Given: 124
Thanks Received: 704


nismo View Post
Great post thats exactly what I was getting at with your suggestion of pricegap in my first post, point 2.

Also using currentask and currentbid seems better.

Say you've got a chart that is set to bid and you issue a limit order based on the current bid price I'm guessing its going to get missed straight away as the ask price will be higher by what ever the spread is...

If you're issuing on the momentum side, just be aware that your pricegap is slippage, just in deliberate form.

In a sense, you're avoiding slippage from market orders, but at the cost of the pricegap. This type of approach is mainly needed once your order sizes start getting large enough to see more than a tick of slippage.

If you're trading during high volume periods, on liquid instruments, this will usually mean some pretty large orders before the limit approach is necessary.

If you're trading off hours, then this approach will be necessary earlier (or with smaller positions).

Also know that limit order execution complicates matters, as you have the issues associated with partial fills.

The good thing is that momentum (or windward) side orders, partial fills are a good thing. A partial fill on an entry, means the market partially filled you and then moved against you, so you entered a smaller position on a loss. A partial fill on profitable exit means you didn't get "limited out" and the trade continues in your favor. A partial fill on loss exit means you survived to fight some more.

Bear in mind that TS has some settings associated with limit orders and partial fills. You need to check and ensure you're on top of MC's settings. You can set it to automatically convert to a market order after a certain amount of time, you can cancel the remaining order if price moves away, etc.

Also, bear in mind that momentum side limit orders still exhibit slippage. I call it momentum slippage. Essentially, the order gets translated from your platform, to the broker, then to the exchange. If you issue the order to the broker at say $0.00 (a buy order on an upward trend). During high velocity market conditions, the price may have moved by the time the broker was able to issue the order to the exchange. So your order may actually get filled at some price higher than $0.00. This is called momentume slippage and it hurts you on momentum side entries and exits.

So keep all this in mind with your limit strategies. Generally, limit orders are necessary (and all the headaches) for larger positions. If you're trading a small position, it's almost always better to just bite the bullet and go with market orders.

Simulation cannot accurately account for variances you'll see with either approach. Sim cannot adequately calculate market order slippage (although you can place the settings to only fill once price has moved at least a tick beyond your order). It also cannot account for live limit slippage (that I covered above).

So you'll see some variance from sim to live. You need to ensure that your net profit/trade is adequate enough to suffer SOME amount of platform-broker-exchange lag (momentum slippage).

I generally backtest with commission plus a tick on each side (for my pricegap) and then if my performance is still satisfactory if I add another tick on each side (for platform lag) then it's tough enough to think about taking live.

If you're strategy with commissions, doesn't yield more than 4 or 5 ticks per trade (net), I'd be very wary about putting any more time or energy into it....as even a small amount of platform variance can really ruin your day. At least it totally wrecks your drawdown, at worst it can totally ruin your profitability.

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
The following 2 users say Thank You to RM99 for this post:
(login for full post details)
  #15 (permalink)
 Seberbach 
Midland, Michigan USA
 
Experience: Advanced
Platform: TradeStation, Biocomp
Trading: TF
Posts: 21 since Aug 2010
Thanks Given: 71
Thanks Received: 22

I have come to the conclusion that proper simulation of real time trading means using at least the OPEN of the next bar as the closing price of the prior bar, especially when trading at even intervals of time like 5 minute or 30 minute bars, if not many ticks of delay as proxy for the close of the prior bar. You want YOUR strategy bar close to sync up with its arrival at your counterparty's bid or offer.

Experiment: Take any strategy that allows trades to commence at the daily open, (regular Session).

Compare results of that same strategy using a custom Session starting time whose intervals are displaced just ONE minute later or earlier in time by starting the Session a minute early or late. Same trick may show difference at the daily Close.

I sometimes see multi-tick gaps between 1 minute bars prior bar close and next bar open. Right where I get signals....and the market leaps.... These little details need to be taken into your strategy's thoughtful consideration along with transmission and computer latency and positioning in limit order book queue.

Reply With Quote
(login for full post details)
  #16 (permalink)
 guppy 
Los Angeles, CA
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation
Trading: ES,HG,GC,YM,Nq,RB,NG
Posts: 52 since Aug 2011
Thanks Given: 11
Thanks Received: 8

Mike in red below you said that all orders are canceled and replaced at the start of each new bar. But I dont see it happend way. For example i have coded a breakout strategy to take the break of an inside bar high + 1 tick. If my condition is met the pending order is placed. However if the price never touches the price the pending order is still there for hours which I only want the pending order to be there for one hour. How do I get it to be there so its not there indefinetly?



Big Mike View Post
All orders are canceled and replaced at the start of each new bar. To cancel it in effect, just don't reissue the Buy or Sell order.

You said you are seeing 1-5 pips slippage. 5 is quite a bit. What instrument and during what time frame? You will always see 1 tick "slippage" which is the price you pay for a market order. Most futures you shouldn't see more than two ticks. If you are trading something very thin, like Micro's on CME, then you can easily see spreads of 4-6 ticks especially after hours. A limit order is not likely to help you, the order simply won't get filled.

Mike


Reply With Quote
(login for full post details)
  #17 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

Hi,

What is your timeframe ?
Could you post your code?

Nicolas

Visit my NexusFi Trade Journal Reply With Quote
(login for full post details)
  #18 (permalink)
 guppy 
Los Angeles, CA
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation
Trading: ES,HG,GC,YM,Nq,RB,NG
Posts: 52 since Aug 2011
Thanks Given: 11
Thanks Received: 8

my time frame is a 1 hour chart and the code is below


vars:mystoploss(0);
condition1= h<h[1] and l>l[1];
if marketposition = 0 and condition1 then
buy ("IB Break") 1 contracts next bar at h+1 point or higher;
setprofittarget(500);
setstoploss(500);


Nicolas11 View Post
Hi,

What is your timeframe ?
Could you post your code?

Nicolas


Reply With Quote
(login for full post details)
  #19 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

Hi,

I do not succeed in reproducing your problem.

I have applied your signal on EUR.USD 5 min:
 
Code
// EUR.USD
Condition1 = H < H[1] and L > L[1];
if MarketPosition = 0 and Condition1 then
    buy ("IB Break") 1 contracts next bar at H+1 point or higher;
SetProfitTarget(0.0005);
SetStopLoss(0.0005);
I have also added an indicator to show the IB which are not triggered on the following bar:
 
Code
Condition1 = H < H[1] and L > L[1];
if Condition1[1] AND H <= H[1] then begin
    Value1 = Arw_New(Date, Time, High+0.0003, true);
    Arw_SetText(Value1, "IB but no trigger");
end;
The results (backtesting) are as expected: when an IB does not trigger an order, such order is "forgotten" after the bar elapsed:


Nicolas

Visit my NexusFi Trade Journal Reply With Quote
The following 2 users say Thank You to Nicolas11 for this post:
(login for full post details)
  #20 (permalink)
 guppy 
Los Angeles, CA
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation
Trading: ES,HG,GC,YM,Nq,RB,NG
Posts: 52 since Aug 2011
Thanks Given: 11
Thanks Received: 8


Nicholas,

I get the same results when backtesting. It works fine on backtesting. Its on live mode that you will see once the condition is true it will but the stop pending orders in. Once the stop pending orders are put in they will remain there indefinetely until one of two things happen. 1. the signal gets executed or 2. There is a new signal.

So for example at 5am if we get a true condition then at beginning of hour 6 the orders are in place pending at h+1. If it doesnt get executed they still stay there even if 4 hours have passed by.

Let me know if you get a chance to test the live.

Thanks



Nicolas11 View Post
Hi,

I do not succeed in reproducing your problem.

I have applied your signal on EUR.USD 5 min:
 
Code
// EUR.USD
Condition1 = H < H[1] and L > L[1];
if MarketPosition = 0 and Condition1 then
    buy ("IB Break") 1 contracts next bar at H+1 point or higher;
SetProfitTarget(0.0005);
SetStopLoss(0.0005);
I have also added an indicator to show the IB which are not triggered on the following bar:
 
Code
Condition1 = H < H[1] and L > L[1];
if Condition1[1] AND H <= H[1] then begin
    Value1 = Arw_New(Date, Time, High+0.0003, true);
    Arw_SetText(Value1, "IB but no trigger");
end;
The results (backtesting) are as expected: when an IB does not trigger an order, such order is "forgotten" after the bar elapsed:


Nicolas


Reply With Quote





Last Updated on April 4, 2013


© 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