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 1,874 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

Stop Limit Code

  #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?
Cheap historycal L1 data for stocks
Stocks and ETFs
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
Quant vue
Trading Reviews and Vendors
 
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


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 Twitter 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,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

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 Twitter 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,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

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 Twitter 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


© 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