NexusFi: Find Your Edge


Home Menu

 





place multiple stoploss/limit orders based on entry price


Discussion in EasyLanguage Programming

Updated
    1. trending_up 7,442 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?
Penalties in Budapest, Peace Deadline in Tehran: Arsenal …
Prediction Markets & Event Contracts
Hormuz Surges From 14% to 26.5% Intraday as Irans Answer …
Prediction Markets & Event Contracts
Fed Hike Odds at 57% After Warsh: England Surges 12.9%, …
Prediction Markets & Event Contracts
Fabrication or Framework? Irans Denied MOU Explains the …
Prediction Markets & Event Contracts
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643


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