NexusFi: Find Your Edge


Home Menu

 





stop-limit order easylanguage tradestation


Discussion in TradeStation

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




 
Search this Thread

stop-limit order easylanguage tradestation

  #1 (permalink)
w4rri0r
world's citizen
 
Posts: 45 since Oct 2015
Thanks Given: 10
Thanks Received: 7

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 NexusFi?
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

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
Thanked by:
  #3 (permalink)
w4rri0r
world's citizen
 
Posts: 45 since Oct 2015
Thanks Given: 10
Thanks Received: 7



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
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

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
Thanked by:
  #5 (permalink)
w4rri0r
world's citizen
 
Posts: 45 since Oct 2015
Thanks Given: 10
Thanks Received: 7


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
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

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
Thanked by:
  #7 (permalink)
w4rri0r
world's citizen
 
Posts: 45 since Oct 2015
Thanks Given: 10
Thanks Received: 7


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
  #8 (permalink)
w4rri0r
world's citizen
 
Posts: 45 since Oct 2015
Thanks Given: 10
Thanks Received: 7

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




Last Updated on December 21, 2016


© 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