NexusFi: Find Your Edge


Home Menu

 





place multiple stoploss/limit orders based on entry price


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
bermondsey
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;

end;


// 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;


end;


any help much appreciated,

cheers,

bermondsey


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Zytrade: Devin Brady, CEO - Ask Me Anything (AMA)
Brokers
Khamenei Vetoes Uranium Transfer as Peace Odds Surge to …
Prediction Markets & Event Contracts
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
Bond Market Rout -- Worst Week Since Russias 2022 Invasi …
Treasury Notes and Bonds
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
23 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639


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?

Regards,
ABCTG


Follow me on X Reply With Quote
Thanked by:




Last Updated on October 14, 2013


© 2026 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 - Downloads - Top
no new posts