NexusFi: Find Your Edge

Home Menu


place multiple stoploss/limit orders based on entry price

Discussion in EasyLanguage Programming

    1. trending_up 6,942 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 2 posts
    2. attach_file 0 attachments

Search this Thread

place multiple stoploss/limit orders based on entry price

(login for full post details)
  #1 (permalink)
London, UK
Posts: 2 since Oct 2013
Thanks Given: 1
Thanks Received: 0

hi everyone,

i tried to incorporate a methodology into my strategy that had been described by Big Mike in one of his tutorials (VIDEO TUTORIAL: How to create an advanced MultiCharts EasyLanguage Strategy ). based on the entry price the strategy should come up with multiple stop loss and limit (take profit) orders. to keep it simple i am for now only trading one contract and therefore for each trade the strategy will only place one stoploss and one takeprofit order. i've been trying to get my head around the following problem for the past few hours but couldn't find any solution to it:

whereas the system enters a long/short position ok, it seems like when calculating stoploss and take profit level the strategy might not be using the correct entry price. it seems to be closing out trades on a rather random basis.

(for additional info i'm backtesting on FGBL futures and i am using a 1min chart).

please see code below:

inputs: stopsize(8), tp (10);

vars: ticksize (minmove/pricescale), tgt1 (tp*ticksize), st1(0), longentryprice(0), shortentryprice(0);

//enter position (only at the close of bar):

if barstatus(1) = 2 then begin

if marketposition = 0 and condition1 then
buy("enter long") next bar 1 contracts at close limit;
longentryprice = entryprice;

if marketposition = 0 and condition2 then
sellshort ("enter short") next bar 1 contracts at close limit;
shortentryprice = entryprice;


// trade management (which is causing issues):

if marketposition <> 0 then begin

if marketposition =1 then
st1 = longentryprice - (stopsize*ticksize);

sell ("longtarget_hit") 1 contracts next bar at (longentryprice + tgt1) limit;
sell ("longstop_triggered") 1 contracts next bar at st1 stop;

if marketposition = -1 then
st1 = shortentryprice + (stopsize*ticksize);

buytocover ("shorttarget_hit") 1 contracts next bar at (shortentryprice- tgt1) limit;
buytocver ("shortstop_triggered") 1 contracts next bar at st1;


any help much appreciated,



Reply With Quote

Can you help answer these questions
from other members on NexusFi?
IQFeed MBO data experience
The Elite Circle
Trader Dale [email protected] or Scammer Dale
Trading Reviews and Vendors
ISO Equity Curve Indicator
Volume profile TradeStation
EasyLanguage Programming
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
GFIs1 1 DAX trade per day journal
28 thanks
Supertradersams Thread Journal on NQ/MNQ
26 thanks
Tao te Trade: way of the WLD
24 thanks
Just another trading journal: PA, Wyckoff & Trends
12 thanks
Deaddogs Stock Trading
11 thanks

(login for full post details)
  #3 (permalink)
 ABCTG   is a Vendor
Posts: 2,426 since Apr 2013
Thanks Given: 437
Thanks Received: 1,618

I have just loaded your code into Multicharts and it seems to exit where I would expect it to do it.
Can you show some examples of trades that are exited at wrong prices?


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:

Last Updated on October 14, 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