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 25,354 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

  #21 (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

I will try to test it live later in the day.

(i) Sorry if I force you to repeat, but just for confirmation: the "pending orders" are the entry orders, correct?

(ii) I understand that, for your live trading, you are connected to your broker in sim mode. Correct? Which broker is it?

Nicolas

Visit my NexusFi Trade Journal Reply With Quote

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #22 (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

1.Yes the pending orders are my entry orders.

2.Yes i am connected to my broker which is OEC in sim also.



Nicolas11 View Post
I will try to test it live later in the day.

(i) Sorry of I force you to repeat, but just for confirmation: the "pending orders" are the entry orders, correct?

(ii) I understand that, for your live trading, you are connected to your broker in sim mode. Correct? Which broker is it?

Nicolas


Reply With Quote
  #23 (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


I still not succeed in reproducing your problem.

I have used the following signal in real-time sim mode, connected to my broker (Interactive Brokers).
Instrument is EUR.USD.
Timeframe is 1 minute.

The "condition" becomes true a few minutes after the activation of the strategy.
But the entry is impossible (the required entry price is set @ 1000 ticks above current price).
 
Code
[IntraBarOrderGeneration = false]

Variables:
    TickSize        ( MinMove / PriceScale ),
    NbContracts        ( 10000 ),
    NotAlreadyDone    ( true );
    
if Date = 1120131 AND Time >= 1313 AND NotAlreadyDone {to be sure the test will be done only once} AND MarketPosition = 0 then begin
    Buy ("Entry LONG") NbContracts contracts next bar at H + 1000 * TickSize or higher {virtually impossible};
    NotAlreadyDone = false;
end;

if MarketPosition = 1 AND BarsSinceEntry >= 1 then
    Sell ("Time Exit LONG") next bar at market; // actually never used since no entry triggered
MultiCharts has generated the buy order. This order could not be executed since the required price was too high. After one minute, the order has been automatically cancelled by MultiCharts. Evidence in MC's "Order Position Tracking window" with the "Cancelled" status:

Same behaviour (order then cancellation of the order) has been noticed in the broker's software, not shown here.

Nicolas

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #24 (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

Im wondering if this is a broker issue then. Ill have to ask my broker.

How would your code it if you wanted it one way vs the other.

1. if condition is met then pending orders stay there forever until executed or new condition is there.

2.if condtion is met then pending orders stay valid for 1 hour only then cancels.

How would the coding be for each?




Nicolas11 View Post
I still not succeed in reproducing your problem.

I have used the following signal in real-time sim mode, connected to my broker (Interactive Brokers).
Instrument is EUR.USD.
Timeframe is 1 minute.

The "condition" becomes true a few minutes after the activation of the strategy.
But the entry is impossible (the required entry price is set @ 1000 ticks above current price).
 
Code
[IntraBarOrderGeneration = false]
 
Variables:
    TickSize        ( MinMove / PriceScale ),
    NbContracts        ( 10000 ),
    NotAlreadyDone    ( true );
 
if Date = 1120131 AND Time >= 1313 AND NotAlreadyDone {to be sure the test will be done only once} AND MarketPosition = 0 then begin
    Buy ("Entry LONG") NbContracts contracts next bar at H + 1000 * TickSize or higher {virtually impossible};
    NotAlreadyDone = false;
end;
 
if MarketPosition = 1 AND BarsSinceEntry >= 1 then
    Sell ("Time Exit LONG") next bar at market; // actually never used since no entry triggered
MultiCharts has generated the buy order. This order could not be executed since the required price was too high. After one minute, the order has been automatically cancelled by MultiCharts. Evidence in MC's "Order Position Tracking window" with the "Cancelled" status:

Same behaviour (order then cancellation of the order) has been noticed in the broker's software, not shown here.

Nicolas


Reply With Quote
  #25 (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


guppy View Post
1. if condition is met then pending orders stay there forever until executed or new condition is there.

I would do something similar to the following, not tested.

 
Code
Variables:
    Setup    ( false );
    
If L > L[1] AND H < H[1] {inside bar; substitute by what you want} then begin
    Setup = true;
end;

If Setup AND MarketPosition = 0 then begin
    Buy next bar at market;
end;

// if order executed, then set the condition at false:
If Setup AND MarketPosition = 1 then begin
    Setup = false;
end;

// if "other condition", then set the condition at false:
If Setup AND L < L[1] AND H > H[1] {outside bar; substitute by what you want} then begin
    Setup = false;
end;

// inspired by http://www.breakoutfutures.com/Newsletters/Newsletter0103.htm

guppy View Post
2.if condtion is met then pending orders stay valid for 1 hour only then cancels.

I would do something similar to the following, not tested.

 
Code
Variables:
    Setup            ( false ),
    SetupBarNumber    ( 0 );
    
If L > L[1] AND H < H[1] {inside bar; substitute by what you want} then begin
    Setup = true;
    SetupBarNumber = BarNumber;
end;

If Setup AND MarketPosition = 0 then begin
    Buy next bar at market;
end;

// if order executed, then set the condition at false:
If Setup AND MarketPosition = 1 then begin
    Setup = false;
end;

// if other condition, then set the condition at false:
If Setup AND L < L[1] AND H > H[1] {outside bar; substitue by what you want} then begin
    Setup = false;
end;

// if 12 bars have elapsed, then set the condition at false:
If Setup AND BarNumber >= SetupBarNumber + 12 then begin
    Setup = false;
end;
Another way would be to identify how many bars ago the condition was true (with a function like "MRO"), check that it occurred less than 12 bars ago, and check that no trade was done between this most recent time the condition was true and now.

Nicolas

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #26 (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

This was definetly an issue and multicharts support confirmed what i was originally saying. They (Henery) at multicharts support after testing verified it and gave me a hot fix as other people were having and issue with it also. The future versions of multicharts will have this flaw/bug removed they told me.





Nicolas11 View Post
I still not succeed in reproducing your problem.

I have used the following signal in real-time sim mode, connected to my broker (Interactive Brokers).
Instrument is EUR.USD.
Timeframe is 1 minute.

The "condition" becomes true a few minutes after the activation of the strategy.
But the entry is impossible (the required entry price is set @ 1000 ticks above current price).
 
Code
[IntraBarOrderGeneration = false]
 
Variables:
    TickSize        ( MinMove / PriceScale ),
    NbContracts        ( 10000 ),
    NotAlreadyDone    ( true );
 
if Date = 1120131 AND Time >= 1313 AND NotAlreadyDone {to be sure the test will be done only once} AND MarketPosition = 0 then begin
    Buy ("Entry LONG") NbContracts contracts next bar at H + 1000 * TickSize or higher {virtually impossible};
    NotAlreadyDone = false;
end;
 
if MarketPosition = 1 AND BarsSinceEntry >= 1 then
    Sell ("Time Exit LONG") next bar at market; // actually never used since no entry triggered
MultiCharts has generated the buy order. This order could not be executed since the required price was too high. After one minute, the order has been automatically cancelled by MultiCharts. Evidence in MC's "Order Position Tracking window" with the "Cancelled" status:

Same behaviour (order then cancellation of the order) has been noticed in the broker's software, not shown here.

Nicolas


Reply With Quote
  #27 (permalink)
 mrphr 
London
 
Experience: None
Platform: .
Trading: .
Posts: 255 since Apr 2011
Thanks Given: 65
Thanks Received: 182


nismo View Post
3. Is there any 'best practises' when using limit orders?

Yes there is:

Buy Stop and Sell Stop orders... 99% of the time, I would say 100% of the time you will get filled.

If you are using Limits Orders most likely you will not get filled, mainly if price is moving fast or there is a spike; Limits Orders never worked for me.

Now, after I am in a position then I use Limit Orders to take some profits [Sell Limit and But Limit], but for entries ONLY Buy Stop and Sell Stop.

I am will MB Trading as well and the majority of the time they did not fill my Limits Orders, it was really really really frustrating. Like a trade that could have made me some nice profit...

They say: We pay for Limits!!! Pfff... who cares you pay for Limits Orders, once your orders won't get fill anyway.

About your 20 pips slippage, I trade with MB for a while now and I never seen that, however one day I had 12 pip slippage on the AUD/USD I call them immediately: They say it was a news event and then I say that there are news event every single day and please never do that again.

Reply With Quote
  #28 (permalink)
 bomberone1 
London
 
Experience: Beginner
Platform: MultiCharts
Posts: 277 since Nov 2010
Thanks Given: 14
Thanks Received: 29


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.

It was good but then it is difficult to keep it aligned with the MC. In MC orders only post them on Data1 and for BID and ASK you have to put even Data2. How could we do?
You could try to put two charts in the WS ....
We can also add the sort of excursion of the time, where the pricegap becomes greater if the time grows, the less if it goes down, just that this is above my current abilities.
Any suggestion?

Reply With Quote
  #29 (permalink)
 bomberone1 
London
 
Experience: Beginner
Platform: MultiCharts
Posts: 277 since Nov 2010
Thanks Given: 14
Thanks Received: 29

Guppy
Original code:

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,

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

I think, but probably I am wrong that code is wrong.
In your code if you work with 1 lot = 100.000
0.0005 is equal to 50 $ and not 500$
Nicolas the time frame should be 1 hours and not 5 minutes.
Guppy use a monetary stop e target of 500$ so the set should change.
I think that you should write 0.0050, nut is bettter use 500 no avoid mistakes.


I use tradestation and for default the minim lot size is minilot = 10.000 so
0.0005 = 5$.
If we trade FX eurusd and we want trade 10.000 eurs or 1 minilot it should be

 
Code
//
// EUR.USD
input: SPT(500), SSL(500), cts(10000);
Condition1 = H < H[1] and L > L[1];
if MarketPosition = 0 and Condition1 then
buy ("IB Break")  cts contracts next bar at H + 0.0001 stop ;
SetProfitTarget(SPT);
SetStopLoss(SSL);

In the following image i post charts, the time frame is daily because the value of
SetProfitTarget(SPT);
SetStopLoss(SSL);
=500 is to big and trade is executed at 1 hour time frame.


Attached Files
Elite Membership required to download: rep.xlsx
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