stop-limit order easylanguage tradestation - futures io
futures io futures trading



stop-limit order easylanguage tradestation


Discussion in TradeStation

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

stop-limit order easylanguage tradestation

(login for full post details)
  #1 (permalink)
world's citizen
 
 
Posts: 45 since Oct 2015
Thanks: 10 given, 7 received

Hi,
i'm trying to code a Stop-Limit order with easylanguage for Tradestation.
Unfortunately (!) TS don not provide a built -in stop-limit order to insert in strategies so as reported by tech support (!) one need to "mimic" the order and coding a "synth stop-limit" with Intrabar Order Generation (IOG)

I've tryied but IOG seems to overcomplicate simple task so maybe someone can help me to solve the issue...

below the code provided by TS support

 
Code
[intrabarordergeneration = true]
inputs:
LimitOffsetTicks( 5 ),
BarsToSetRange( 5 ) ;
variables:
OpenRange( false ),
OpenRangeHigh( 0 ),
OpenRangeLow( 0 ),
LongStopPrice( 0 ),
ShortStopPrice( 0 ),
Count( 0 ),
intrabarpersist EnterLong( false ),
intrabarpersist EnterShort( false ),
intrabarpersist EnteredToday( false ),
ATick( MinMove / PriceScale ),
MP( 0 ) ;

MP = MarketPosition ;

if MP <> 0 then
begin
EnteredToday = true ;
EnterLong = false ;
EnterShort = false ;
end ;

if Date <> Date[1] then
begin
OpenRangeHigh = High ;
OpenRangeLow = Low ;
Count = 1 ;
EnteredToday = false ;
end
else if Count < BarsToSetRange then
begin
OpenRangeHigh = MaxList( High, OpenRangeHigh ) ;
OpenRangeLow = MinList( Low, OpenRangeLow ) ;
Count += 1 ;
end
else if EnteredToday = false then
begin
if Close crosses above OpenRangeHigh + ATick then
begin
EnterLong = true ;
EnterShort = false ;
end
else if Close crosses below OpenRangeLow - ATick then
begin
EnterShort = true ;
EnterLong = false ;
end ;
end ;


if EnterLong then
begin
Buy next bar at OpenRangeHigh + ATick + LimitOffsetTicks * ATick Limit ;
end ;

if EnterShort then
begin
SellShort next bar at OpenRangeLow - ATick - LimitOffsetTicks * ATick Limit ;
end ;

if BarsSinceEntry = 5 then
begin
Sell next bar at Market ;
Buy to Cover next bar at Market ;
end ;


The code should trade the break of the range of the first candle of the day, regardless the timeframes.
Sadly, it doesn't work......

Reply With Quote

Can you help answer these questions
from other members on futures io?
Automatic pattern research with NT
Elite Algorithmic NinjaTrader Trading
Which kind of Blockvolume is visible? - order processing
Emini and Emicro Index
ZigZag with Depth and Backstep
EasyLanguage Programming
MACD line not plotting after change of plot order
NinjaTrader
Indicators for pair trading MES and M2K
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Battlestations: Show us your trading desks!
111 thanks
Selling Options on Futures?
109 thanks
Rank your Futures vs Stocks trading priority
37 thanks
Want your NinjaTrader indicator created, free?
26 thanks
Bitcoin storage wallet recommendations
18 thanks
 
(login for full post details)
  #2 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

w4rri0r,

what settings do you use for the look inside bar backtesting? Anything above 1 tick will give you results that are different from what the code would produce in realtime.

When you say "it doesn't work", what does the code do exactly?

Regards,

ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #3 (permalink)
world's citizen
 
 
Posts: 45 since Oct 2015
Thanks: 10 given, 7 received



ABCTG View Post
w4rri0r,

what settings do you use for the look inside bar backtesting?

IBB = 1 tik


Quoting 
When you say "it doesn't work", what does the code do exactly?

The code should trade the break of the range of the first candle of the day, regardless the timeframes - because Tradestation don't allow stop-limit orders in it's code (there not a built-in for stop-limit), and because the slippages are very very large (on MSFT i can have a 20 cents slippage for a stop order!), I was trying to "mimic" a stop-limit...to protect me from the exorbitant slippage provided....

(maybe easylanguage ond IOG are not the best to code something like that...maybe better drop Tradestation and go with a C# or C++ based coding language?)

Reply With Quote
 
(login for full post details)
  #4 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

w4rri0r,

looking at your code and an example on 30 min @ES.D it seems to do what you want it to do - under the condition that BarsToSetRange is set to 1. Based on that the problem might not be code related, unless I am not seeing the wrong behavior.


You can use stop limit orders with Object Oriented EasyLanguage order objects, but these will only work in realtime.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #5 (permalink)
world's citizen
 
 
Posts: 45 since Oct 2015
Thanks: 10 given, 7 received


ABCTG View Post
w4rri0r,

looking at your code and an example on 30 min @ES.D it seems to do what you want it to do - under the condition that BarsToSetRange is set to 1. Based on that the problem might not be code related, unless I am not seeing the wrong behavior.


You can use stop limit orders with Object Oriented EasyLanguage order objects, but these will only work in realtime.

Regards,

ABCTG

so maybe it's because of the latest Tradestation update?
can u check if it work even on MSFT chart please?

how can i mix Object Oriented EasyLanguage and strategies? Is it even possible? can you provide an example, please?

Reply With Quote
 
(login for full post details)
  #6 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

w4rri0r,

it works fine here on MSFT, too.

I don't think it has something to do with the TS version or the code, but is more likely a settings issue. It could for example be that the tick data is not present, although you have LIB set to 1 tick. But without a chart and your settings one could only guess.

You shouldn't mix order objects with regular orders and you can find plenty of examples for order objects in the official Tradestation forum.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #7 (permalink)
world's citizen
 
 
Posts: 45 since Oct 2015
Thanks: 10 given, 7 received


ABCTG View Post
w4rri0r,

it works fine here on MSFT, too.

I don't think it has something to do with the TS version or the code, but is more likely a settings issue. It could for example be that the tick data is not present, although you have LIB set to 1 tick. But without a chart and your settings one could only guess.

the code i'm using it's exctly the same posted with BarsToSetRange set to 1

i'll check about the tick data

thanks

Reply With Quote
 
(login for full post details)
  #8 (permalink)
world's citizen
 
 
Posts: 45 since Oct 2015
Thanks: 10 given, 7 received

anyway....this is why i need stop-limits having tradestation as broker....



slippage of 60 cents (!) so instead to open the trade at 20ish it's been opened at 2060ish...the target was 20.60ish...so after the buy the bot immediately tried to sell....30 cents lower
so instead of a 400ish win i've got a 200ish loss + commissions

Reply With Quote


futures io Trading Community Platforms and Indicators TradeStation > stop-limit order easylanguage tradestation


Last Updated on December 21, 2016


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts