TS inter bar order work around - futures io
futures io futures trading



TS inter bar order work around


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one workyboy with 6 posts (0 thanks)
    2. looks_two Doctor Leo with 4 posts (3 thanks)
    3. looks_3 djvie11 with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 10,173 views
    2. thumb_up 3 thanks given
    3. group 5 followers
    1. forum 15 posts
    2. attach_file 0 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
 

TS inter bar order work around

(login for full post details)
  #1 (permalink)
Lakeland, FL USA
 
 
Posts: 7 since Dec 2010
Thanks: 1 given, 0 received

I have been trying to figure out how to automate inter bar orders on Trade Station with Kase, range, or momentum bars.
Has any one figured out a work around and willing to share their code or concept?
Any help would be greatly appreciated,
Workyboy

Reply With Quote

Can you help answer these questions
from other members on futures io?
MACD line not plotting after change of plot order
NinjaTrader
Help Needed: TOS Options Chain IV & IMPL MOVE Calcul …
ThinkOrSwim
SimplerOptions
Trading Reviews and Vendors
Cross border fund flows / fx correlations
Treasury Notes and Bonds
NT8 indicator to simulate a Funding Evaluation where to …
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Selling Options on Futures?
109 thanks
Battlestations: Show us your trading desks!
108 thanks
Rank your Futures vs Stocks trading priority
55 thanks
Want your NinjaTrader indicator created, free?
27 thanks
Whats this confusion with margins?
21 thanks
 
(login for full post details)
  #3 (permalink)
St. Petersburg, Russia
 
 
Posts: 30 since Nov 2010
Thanks: 6 given, 19 received


Not quite sure about the bar types you mentioned, as I do not use TradeStation, but usually when I want to make sure the system works correctly intrabar, I use to data streams. This simplifies life a great deal. If you could give an example of what you mean I think I could help some more.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
Lakeland, FL USA
 
 
Posts: 7 since Dec 2010
Thanks: 1 given, 0 received


Doctor Leo View Post
Not quite sure about the bar types you mentioned, as I do not use TradeStation, but usually when I want to make sure the system works correctly intrabar, I use to data streams. This simplifies life a great deal. If you could give an example of what you mean I think I could help some more.

In Trade Station they do not allow a strategy to execute an order inter bar on the mentioned type of charts. Most of the great entries occur inter bar on longer charts, such as coiled springs, bar lows or high, break out reversals, etc.

This is valid coding;
if CurrentBar > 2 and Value1 crosses over Value2 then
Buy ( "MacdLE" ) next bar at market ;

This is what I would like to do;

if CurrentBar > 2 and Value1 crosses over Value2 then
Buy ( "MacdLE" ) this bar at market ;

Your interest is appreciated.

Reply With Quote
 
(login for full post details)
  #5 (permalink)
St. Petersburg, Russia
 
 
Posts: 30 since Nov 2010
Thanks: 6 given, 19 received

You cannot use "this bar at market" as according to EL semantics it would mean buying at the opening of this current bar — which means entering the market in the past (sort of peek ahead). You can only use "this bar on close" and in this case most often you'd get the same as for "next bar at market" — with a tiny exception for gaps between this bar's close and next bar's opening.

Initially I thought you meant something like "next bar at xxx limit" — I don't know if it's allowed to do for special bar types in TS, but I'd rather prohibited it as a source of constant unrealistic and overoptimistic backtesting results

Reply With Quote
 
(login for full post details)
  #6 (permalink)
Lakeland, FL USA
 
 
Posts: 7 since Dec 2010
Thanks: 1 given, 0 received

You are dead on about overly optimistic back testing results. I back test to find settings but use the results from live testing as a guide.
My example of code might have been a little misguided.
Maybe it should have been more like this;
If C=P then buy this bar at P limit.
P is my price projection.

Reply With Quote
 
(login for full post details)
  #7 (permalink)
St. Petersburg, Russia
 
 
Posts: 30 since Nov 2010
Thanks: 6 given, 19 received

I'm afraid there's a mistake again in your code. If close = some_price then you can't set a limit order at this very some_price. Anyway, you can't use "this bar at xxx limit" on any kind of bars. This is because it is impossible to guess the exact price movement within a single bar. Therefore one never knows if your order is filled or not. In general using intra-bar order generation is a very dangerous practice. If you're not satisfied with the resolution of your working timeframe maybe you'd want to try lower timeframes or consider using two timeframes?

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Lakeland, FL USA
 
 
Posts: 7 since Dec 2010
Thanks: 1 given, 0 received


Doctor Leo View Post
I'm afraid there's a mistake again in your code. If close = some_price then you can't set a limit order at this very some_price. Anyway, you can't use "this bar at xxx limit" on any kind of bars. This is because it is impossible to guess the exact price movement within a single bar. Therefore one never knows if your order is filled or not. In general using intra-bar order generation is a very dangerous practice. If you're not satisfied with the resolution of your working timeframe maybe you'd want to try lower timeframes or consider using two timeframes?

Dr. Leo,
In general I have to agree with you and every thing you say is true except, "This is because it is impossible to guess the exact price movement within a single bar." That is the beauty of range type bars. You can forecast the exact high or low on the tick and be accurate. If you know that then you know when to enter or exit for that particular bar.
Back to the problem. How to transfer that data to a chart that you can use the intra-bar order generation feature for a strategy.

Reply With Quote
 
(login for full post details)
  #9 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,785 since Jun 2009
Thanks: 32,313 given, 97,574 received

Only speaking from MultiCharts experience, not TradeStation, but make data1 a 1-range or 1-tick chart, and data2 the "useful" chart that you desire (kase, range, whatever) and then you can do your calculations on data 2 including predicting the closing price of the bar, and submit your orders via data1.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #10 (permalink)
Lakeland, FL USA
 
 
Posts: 7 since Dec 2010
Thanks: 1 given, 0 received



Big Mike View Post
Only speaking from MultiCharts experience, not TradeStation, but make data1 a 1-range or 1-tick chart, and data2 the "useful" chart that you desire (kase, range, whatever) and then you can do your calculations on data 2 including predicting the closing price of the bar, and submit your orders via data1.

Mike

Yes, that is the simple way on time charts which is supported in TS. Range type charts are not.
I know that I need DLL, Global Variable, and/or ADE(All Data Everywhere). The question is; How do you combine them all together to work?

Reply With Quote
 
(login for full post details)
  #11 (permalink)
St. Petersburg, Russia
 
 
Posts: 30 since Nov 2010
Thanks: 6 given, 19 received

Mike, let me make a tiny correction: you cannot trade off any data stream besides data1 (the default one) in Multicharts (or my knowledge is very limited), so you need to have regular bars as data1 and any auxiliary information as data2, data3,...

I think just a single data stream is more than enough here — and of course no need for external DLLs and other stuff. If I'm not mistaken, the following definition of range bars is correct:

Quoting 
The range bars just look price, the bar does not close at a specific time but closes when a range is complete, then a new bar opens.

If you have a market that moves from 1 to 9, then 9 to 1, then 1 to 9 during 2 days, if you create a range bar chart of $10 you will only have a bar that goes from 1 to 9 during these 2 days and this bars is not closed. If the market moves to 10 then the bar closes and a new bar opens with open price at 10. This new bar now must have $10 range to close. Let’s say the market goes back to 6 and then up to 17, the last range bar closes at 16 (making a range bar from 6 to 16) a new bar opens with open price at 16 and this bars price is now 17. This new bar has now a range of $1 (16 to 17) and will wait until a complete $10 range to close.

If the above quote is correct, then you just need a very simple code to markup your "range bars" and unwrap them on the regular time-based bars, something like this:

 
Code
input: R(100);

var: Rhigh(high), Rlow(low), isBarComplete(false);

isBarComplete = false;

Rhigh = maxList(Rhigh, high);
Rlow = minList(Rlow, low);

if Rhigh - Rlow >= R points then begin
	Rhigh = high;
	Rlow = low;
	isBarComplete = true;
end;

plot1(Rhigh);
plot2(Rlow);
Thus you can add some code which is executed when the range bar is comlete, i.e. when isBarComplete = true. Of course this code works best on tick data, but should also work on N-seconds and N-minutes, of course with some error. Whether this error is significant for you or not — it's up to you to decide.

Reply With Quote
The following 3 users say Thank You to Doctor Leo for this post:
 
(login for full post details)
  #12 (permalink)
Lakeland, FL USA
 
 
Posts: 7 since Dec 2010
Thanks: 1 given, 0 received

The goal is a strategy that will send orders inter bar from range type bars.
Let me see if I have this right.
Build a synthetic bar as you noted above.
Inserts code for the indicator that is driven by the code for the synthetic bar.
Take the above two statements and insert that into a strategy and code the strategy to be driven by the indicator driven by the synthetic bar.
Then place that strategy into a tick chart and and it should be able to place orders inter bar.
I think it will work and I'll let you know if I have any success.
Thank you

Reply With Quote
 
(login for full post details)
  #13 (permalink)
Chicago, IL
 
 
Posts: 52 since Jul 2013
Thanks: 29 given, 1 received


Big Mike View Post
Only speaking from MultiCharts experience, not TradeStation, but make data1 a 1-range or 1-tick chart, and data2 the "useful" chart that you desire (kase, range, whatever) and then you can do your calculations on data 2 including predicting the closing price of the bar, and submit your orders via data1.

Mike

This solution makes sense, I just can't get it to work.

An example:
Data1 = 1 Minute
Data2 = 30 Minute
Data3 = 180 Minute

Even with data1 being one minute, all of the orders are being executed on 00 & 30 past the hour (or 01, 31). There's a stochastic trigger on data2 but I just can't get it to execute except on the data2 closes! Very frustrating.

Thing is: if you have the strategy turned off & then turn it on, it will enter into a position at any time it's triggered. It's getting out whenever it's triggered is my problem. I want it to get out regardless of the time (or close, etc).

Any possible ideas would be greatly apprecited!

Reply With Quote
 
(login for full post details)
  #14 (permalink)
Chicago, IL
 
 
Posts: 52 since Jul 2013
Thanks: 29 given, 1 received

bump!!

Reply With Quote
 
(login for full post details)
  #15 (permalink)
Russia
 
Experience: Beginner
Platform: NinjaTrader MultiCharts
 
Posts: 5 since Dec 2010
Thanks: 1 given, 0 received


Big Mike View Post
Only speaking from MultiCharts experience, not TradeStation, but make data1 a 1-range or 1-tick chart, and data2 the "useful" chart that you desire (kase, range, whatever) and then you can do your calculations on data 2 including predicting the closing price of the bar, and submit your orders via data1.

Mike

Hi Mike!
May be you have some piece of code? Its very difficult for me to realize.
I have 2 charts: 1 tick range and 1 minute. And i want to sell if level broken

and no matter -10 point or -1 poin - sell began on the same price((

if condition3 and condition5 and LastDelayLow then
begin
Sell Short ( "S" ) next bar at oPivotPriceLow -10 point stop;
// Sell Short ( "S" ) next bar market;
LastDelayLow = false;
end;

or

if condition3 and condition5 and LastDelayLow then
begin
Sell Short ( "S" ) next bar at oPivotPriceLow -1 point stop;
// Sell Short ( "S" ) next bar market;
LastDelayLow = false;
end;

the same

many many thanks!

Reply With Quote
 
(login for full post details)
  #16 (permalink)
new york
 
Experience: Advanced
Platform: tradestation
Trading: stocks
 
Posts: 7 since Feb 2011
Thanks: 2 given, 3 received

You can only use if CurrentBar > 2 and Value1 crosses over Value2 then
Buy ( "MacdLE" ) this bar at CLOSE ;


In any case none of the bars that use filled in data points will test accurately regardless. (Kase, Range, Renko, Renko+).

The strategy will think you entered on the exact close of the bar, which is very far in most cases from where the actual price is. Renko bars with "wicks" help, but are also inaccurate. All results will be overly optimistic, so much so, that the actual strategy will in reality not work at all near your expectations.

Run your strategy in Tradestation on one of these bars live and you will see a loss accumulating in the PNL bar in the left corner, Lets say of $1000.00 Then go to the Performance Summary and go look up the exact trade in the trade list that just happened, and you will see a loss of maybe $300.00 or even a gain!

Just doesn't work unless every single tick is counted, which is just not practical unless your running a "Watson" computer at home. Even then you have to reconstruct this to the exact times offline. Even third party vendors who supposedly do this will only allow a few days of tick accumulation , which is certainly not enough to make any kind of conclusions about strategies. Which is why most strategies from most platform vendors use "on bar close". Under normal bar types this is sufficent, but on "advanced types" it just doesn't work.

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > TS inter bar order work around


Last Updated on May 7, 2018


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