NexusFi: Find Your Edge


Home Menu

 





Stop Limit Code


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Edwin Lefevre with 4 posts (1 thanks)
    2. looks_two ABCTG with 3 posts (1 thanks)
    3. looks_3 numberjuani with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 2,864 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
Edwin Lefevre
Scotland
 
Posts: 27 since May 2019
Thanks Given: 11
Thanks Received: 4

Hi i'm trying to add a stop limit to my strategy.

I have the followinng code but it does not seem to be working.

var:

limit_stop_long = (entryprice-(minmove*sl));
limit_stop_short = (entryprice+(minmove*sl));

...

if MarketPosition > 0 then

setprofittarget_pt(tp);

sell next bar at limit_stop_long stop limit_stop_long limit;

if MarketPosition < 0 then

setprofittarget_pt(tp);

buytocover next bar at limit_stop_short stop limit_stop_short limit;


Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
Khamenei Vetoes Uranium Transfer as Peace Odds Surge to …
Prediction Markets & Event Contracts
Post-Summit Scorecard: $36M in May 15 Bets Settle Near-Z …
Prediction Markets & Event Contracts
Fed Hike Odds at 57% After Warsh: England Surges 12.9%, …
Prediction Markets & Event Contracts
CFTC Opens First COT Report Review in 20 Years -- Asks W …
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


Edwin Lefevre,

what does "it does not seem to be working" mean? What does the code do versus what should the code do?
Are there any error messages? What is the platform you are coding this in (Multicharts or Tradestation)?

Regards,

ABCTG


Follow me on X Reply With Quote
  #4 (permalink)
Edwin Lefevre
Scotland
 
Posts: 27 since May 2019
Thanks Given: 11
Thanks Received: 4

Hey,

the stop does not seem to be triggerinng.

The position either goes to the take profit limit or keeps going until I cover the position at the end of the session.

I want it to reach the stop level and put a limit order in the book at that price. Closing my position.

I'm doinng this to stop the slippage of a market order - even if only 1 tick.

I understand that there is a chance that stop limit will not trigger but it seems that this is not triggering at all in any instance.

Im using Multicharts.

Cheers.


Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643

Edwin Lefevre,

it might make sense for you to use the print reserved word to check the values you are using for the stop and limit prices when you issue the order.

Regards,

ABCTG


Follow me on X Reply With Quote
Thanked by:
  #6 (permalink)
Edwin Lefevre
Scotland
 
Posts: 27 since May 2019
Thanks Given: 11
Thanks Received: 4


ABCTG View Post
Edwin Lefevre,

it might make sense for you to use the print reserved word to check the values you are using for the stop and limit prices when you issue the order.

Regards,

ABCTG

Thanks, seems I have negative numbers.

What data does print reference?


Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643

Edwin Lefevre,

it prints the values of variables and reserved words (that you included in the print statement) at the time your code executes the print statement.

Regards,

ABCTG



Edwin Lefevre View Post
Thanks, seems I have negative numbers.

What data does print reference?


Follow me on X Reply With Quote
  #8 (permalink)
 
numberjuani's Avatar
 numberjuani 
Agoura Hills, CA USA
 
Experience: Advanced
Platform: Tradestation&Multicharts
Broker: TradeStation
Trading: Futures & Equities
Posts: 128 since Apr 2019
Thanks Given: 9
Thanks Received: 102


Edwin Lefevre View Post
Thanks, seems I have negative numbers.

What data does print reference?

HI Edwin, From what I understand TS strategy only support StopLoss Order, which are a stop market, and Limit as SetProfitTarget.

but a way to hack it into being a limit would be :

if C crosses below (StopLevel) then
Sell next bar at (StopLevel) Limit;

In my opinion its a bad idea all around, because it will take away from the fidelity of your backtest and you will always need very fine LIBB. You will also need to make sure you have the box checked about limit order fills. I would recommend you simply add a couple of ticks of slippage and comms and design your strategy work with it.


Reply With Quote
  #9 (permalink)
Edwin Lefevre
Scotland
 
Posts: 27 since May 2019
Thanks Given: 11
Thanks Received: 4


numberjuani View Post
HI Edwin, From what I understand TS strategy only support StopLoss Order, which are a stop market, and Limit as SetProfitTarget.

but a way to hack it into being a limit would be :

if C crosses below (StopLevel) then
Sell next bar at (StopLevel) Limit;

In my opinion its a bad idea all around, because it will take away from the fidelity of your backtest and you will always need very fine LIBB. You will also need to make sure you have the box checked about limit order fills. I would recommend you simply add a couple of ticks of slippage and comms and design your strategy work with it.

Im using Multicharts - posted in wrong section my accident.

I'm still having trouble making the stop limit work. I'm pretty sure its how im calculating the stop from the entry.. You would think that there would be a simple function for stop limit and stop limit trailing.

Problem I'm having is a I had a great system developed. But then realised that I had been market buying in and not accounting for slippage. Even with 1 tick slippage the system is broken.

I tried half slippage to account for say 50% of the time buying market is on the bid or ask the same as backtesting. It was a little better.

If I can limit in and out then I might salvage the premise of the strategy.


Reply With Quote
  #10 (permalink)
 
numberjuani's Avatar
 numberjuani 
Agoura Hills, CA USA
 
Experience: Advanced
Platform: Tradestation&Multicharts
Broker: TradeStation
Trading: Futures & Equities
Posts: 128 since Apr 2019
Thanks Given: 9
Thanks Received: 102



Edwin Lefevre View Post
Im using Multicharts - posted in wrong section my accident.



I'm still having trouble making the stop limit work. I'm pretty sure its how im calculating the stop from the entry.. You would think that there would be a simple function for stop limit and stop limit trailing.



Problem I'm having is a I had a great system developed. But then realised that I had been market buying in and not accounting for slippage. Even with 1 tick slippage the system is broken.



I tried half slippage to account for say 50% of the time buying market is on the bid or ask the same as backtesting. It was a little better.



If I can limit in and out then I might salvage the premise of the strategy.



TS and MC are the same for easylanguage purposes . Is this an intraday strategy?


Sent using the NexusFi mobile app


Reply With Quote




Last Updated on November 28, 2019


© 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