Need help with order entry on multiple dataseries - EasyLanguage Programming | futures.io
futures.io futures trading
 

Go Back   futures.io

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > TradeStation > EasyLanguage Programming


Need help with order entry on multiple dataseries
Started:August 28th, 2010 (04:25 PM) by bobbakerr Views / Replies:4,251 / 20
Last Reply:August 29th, 2010 (10:03 AM) Attachments:1

Welcome to futures.io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.


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, and we will never resell your private information.

-- Big Mike
     

Reply
 1  
 
Thread Tools Search this Thread

Need help with order entry on multiple dataseries

Old August 28th, 2010, 04:25 PM   #1 (permalink)
Elite Member
Riverdale, Idaho, USA
 
Futures Experience: Intermediate
Platform: Optimus Futures + MultiCharts + TradeStation
Broker/Data: Optimus Futures, Rithmic Data, TradeStation
Favorite Futures: CL, ES
 
bobbakerr's Avatar
 
Posts: 104 since Aug 2010
Thanks: 209 given, 38 received

Need help with order entry on multiple dataseries

I am using a set of rules that I came up with a few months ago for real trading on Zumo's platform, 'Firetip'. It has done exceedingly well over the last 51 trading days. But I want to automate it so that I don't have to stress-out all day long. I have the following code written for MC:

------------------------------------------------------------------------------------------
inputs: F1(6),S1(10),L1(3),F2(6),S2(10),L2(3),F3(270),S3(585),L3(203),
T1(0600),T2(1410),Y(90);
variables: MACD1(0),MACD2(0),MACD3(0),OldMA(0),MACDBuy(9999),MACDSS(-9999);


MACD1=MACD(Close of Data1,F1,S1); //240-Tick Chart.
MACD1=XAverage(MACD1,L1); //Exit off of this.
MACD2=MACD(Close of Data2,F2,S2); // 480-Tick Chart.
MACD2=XAverage(MACD2,L2); //Enter off of this.
MACD3=MACD(Close of Data3,F3,S3); // 30-min. Chart.


if CurrentBar>2 and Time>T1 and Time<T2 and MarketPosition<=0
and MACD2[1]<0 and MACD2[1]<MACD2[2] and MACD2>MACD2[1] and MACD3>MACD3[1]
and AverageFC(Close of Data2,Y)>OldMA then begin
Buy next bar at market;
MACDBuy=MACD2;
end;

If MarketPosition=1 and MACD1[1]>0 and MACD1<MACD1[1] then Sell next bar at market;


If CurrentBar>2 and Time>T1 and Time<T2 and MarketPosition>=0
and MACD2[1]>0 and MACD2[1]>MACD2[2] and MACD2<MACD2[1] and MACD3<MACD3[1]
and AverageFC(Close of Data2,Y)<OldMA then begin
SellShort next bar at market;
MACDSS=MACD2;
end;

If MarketPosition=-1 and MACD1[1]<0 and MACD1>MACD1[1] BuyToCover next bar at market;


SetStopLoss(400);

SetExitOnClose;

OldMA=AverageFC(Close of Data2,Y);
------------------------------------------------------------------------------------------

I use a 240-Tick chart for Data1 and a 480-Tick chart for Data2. The 240-Tick chart is my SubChart#1.

It is supposed to Enter off Data2 (the 480-Tick chart), then Exit off Data1 (the 240-Tick chart). However, it is Entering off of Data1 and doing so at at the next 480-Tick Bar. The Exits are all right (off of Data1 and the 240-Tick chart).

Can anyone see what I've done wrong in my programming? I've worked on this for several weeks now, in both TradeStation and MultiCharts. Thank you for any help!

-- Bob

Reply With Quote
     

Old August 28th, 2010, 04:25 PM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

     

Old August 28th, 2010, 07:05 PM   #3 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 45,547 since Jun 2009
Thanks: 28,886 given, 80,159 received


You should wrap code in the CODE tags on the forum so they are formatted properly and easier to read and cut/paste.

I've also renamed the thread from "this one is my biggie" to "Need help with order entry on multiple dataseries", because we really want and need a descriptive description to help others find this thread in the future.

From skimming your code, you have nothing in the code to tell it to only buy or sell on a specified bar status. Check out barstatus:

Quoting 
BarStatus

Returns a numerical value, indicating the status of the most recent tick in the current bar of the specified data series.

A value of 0 indicates that the tick is the opening tick of the bar, 1 indicates that the tick is within the bar, and 2 indicates that the tick is the closing tick of the bar.

Usage
BarStatus(DataNum)

Where: DataNum - a numerical expression specifying the data number of the series

If DataNum is not specified, a value for the current data series will be returned.


Example
BarStatus(1) will return a value of 2 if the current tick in the data series with the data number 1 is the closing tick of a bar

Print is your friend. You should add some Print debug output throughout your strategy so you can see what is really happening as the strategy runs through each bar.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
     
The following user says Thank You to Big Mike for this post:
     

Old August 28th, 2010, 07:14 PM   #4 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 45,547 since Jun 2009
Thanks: 28,886 given, 80,159 received

BTW, I should mention I am not sure BarStatus is the solution. I've never tried to do exactly what you are trying to do. In my multiple dataseries strategies, I just used the extra dataseries to evaluate something, I didn't care when a particular dataseries closed its bar or opened a new bar.

In NinjaTrader this is referred to as BarsInProgress, I tried to find something similar in MultiCharts but haven't so far.

In looking at your code, I am not entirely sure why you need to exit only at the close of a particular bar type, it seems like you should exit regardless of whether the bar is mid-bar or close or whatever if a condition is met.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
     

Old August 28th, 2010, 07:52 PM   #5 (permalink)
Elite Member
Riverdale, Idaho, USA
 
Futures Experience: Intermediate
Platform: Optimus Futures + MultiCharts + TradeStation
Broker/Data: Optimus Futures, Rithmic Data, TradeStation
Favorite Futures: CL, ES
 
bobbakerr's Avatar
 
Posts: 104 since Aug 2010
Thanks: 209 given, 38 received

Futures Edge on FIO

Big Mike View Post
You should wrap code in the CODE tags on the forum so they are formatted properly and easier to read and cut/paste.

Sorry, I hadn't noticed the Code Tag feature above. I'll re-post my code using it.


Big Mike View Post
I've also renamed the thread from "this one is my biggie" to "Need help with order entry on multiple dataseries", because we really want and need a descriptive description to help others find this thread in the future.

Thanks for changing the title to something more descriptive.


Big Mike View Post
From skimming your code, you have nothing in the code to tell it to only buy or sell on a specified bar status. Check out barstatus:

I don't think the signals really need to know the status of each bar. I just want Entries off of Data#2 and Exits off of Data#1 (the Closes of each of those bars).


Big Mike View Post
Print is your friend. You should add some Print debug output throughout your strategy so you can see what is really happening as the strategy runs through each bar.

I've done that but I will do more of it.

Thanks for the tips.


Last edited by bobbakerr; August 28th, 2010 at 09:20 PM.
Reply With Quote
     

Old August 28th, 2010, 07:56 PM   #6 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 45,547 since Jun 2009
Thanks: 28,886 given, 80,159 received


bobbakerr View Post
I don't think the signals really need to know the status of each bar. I just want Entries off of Data#1 and Exits off of Data#2 (the Closes of each of those bars).

 
Code
			
If MarketPosition=and MACD1[1]>and MACD1<MACD1[1then Sell next bar at market
If long, and MACD1 one bar ago is above zero, and MACD1 is falling, then Sell next bar at market. I don't see anything "wrong" with the logic, can you post a screen shot of the signal not exiting when it should?

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
     

Old August 28th, 2010, 08:02 PM   #7 (permalink)
Elite Member
Riverdale, Idaho, USA
 
Futures Experience: Intermediate
Platform: Optimus Futures + MultiCharts + TradeStation
Broker/Data: Optimus Futures, Rithmic Data, TradeStation
Favorite Futures: CL, ES
 
bobbakerr's Avatar
 
Posts: 104 since Aug 2010
Thanks: 209 given, 38 received


Big Mike View Post
... In looking at your code, I am not entirely sure why you need to exit only at the close of a particular bar type, it seems like you should exit regardless of whether the bar is mid-bar or close or whatever if a condition is met.

Mike

The 'condition to be met' is if the Close of the 480-Tick bar meets my programmed conditions, then I Enter.

To Exit, the 'condition to be met' is if the Close of the 240-Tick bar meets my programmed conditions, then I Exit.

From how I trade in real life, using Firetip, I LOOK at those charts and indicators. As soon as one of the bars Close, if all else is 'right', then I act. That's what I wanted to program into MultiCharts.

Here is my Code again, using Code Tags:

 
Code
inputs:  F1(6),S1(10),L1(3),F2(6),S2(10),L2(3),F3(270),S3(585),L3(203),
           T1(0600),T2(1410),Y(90);
variables:  MACD1(0),MACD2(0),MACD3(0),OldMA(0),MACDBuy(9999),MACDSS(-9999);

MACD1=MACD(Close of Data1,F1,S1);  //  240-Tick Chart.
MACD1=XAverage(MACD1,L1);  //  Exit off of this.
MACD2=MACD(Close of Data2,F2,S2);  // 480-Tick Chart.
MACD2=XAverage(MACD2,L2);  //  Enter off of this.
MACD3=MACD(Close of Data3,F3,S3);  // 30-min. Chart.


if CurrentBar>2 and Time>T1 and Time<T2 and MarketPosition<=0
  and MACD2[1]<0 and MACD2[1]<MACD2[2] and MACD2>MACD2[1] and MACD3>MACD3[1]
  and AverageFC(Close of Data2,Y)>OldMA then begin
    Buy next bar at market;
    MACDBuy=MACD2;
  end;    
    
If MarketPosition=1 and MACD1[1]>0 and MACD1<MACD1[1]
  
If CurrentBar>2 and Time>T1 and Time<T2 and MarketPosition>=0
  and MACD2[1]>0 and MACD2[1]>MACD2[2] and MACD2<MACD2[1] and MACD3<MACD3[1]
  and AverageFC(Close of Data2,Y)<OldMA then begin
    SellShort next bar at market;
    MACDSS=MACD2;
  end;    

If MarketPosition=-1 and MACD1[1]<0 and MACD1>MACD1[1] then BuyToCover next bar at market;    
    
Setstoploss(400);
    
SetExitOnClose;

OldMA=AverageFC(Close of Data2,Y);

Reply With Quote
     

Old August 28th, 2010, 08:03 PM   #8 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 45,547 since Jun 2009
Thanks: 28,886 given, 80,159 received


bobbakerr View Post

It is supposed to Enter off Data2 (the 480-Tick chart), then Exit off Data1 (the 240-Tick chart). However, it is Entering off of Data1 and doing so at at the next 480-Tick Bar. The Exits are all right (off of Data1 and the 240-Tick chart).

Sorry, I just read this part of your first post.

Buy next bar at market is always going to buy at the open of the next bar.

If you want intrabar signals, you need to Format Signal, then go to Intra-Bar Order Generation tab (IOG) and enable it, this way it will submit signals on a tick-by-tick basis and not close of bar.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Attached Thumbnails
Need help with order entry on multiple dataseries-8-28-2010-6-02-28-pm.jpg  
Reply With Quote
     

Old August 28th, 2010, 08:43 PM   #9 (permalink)
Elite Member
Riverdale, Idaho, USA
 
Futures Experience: Intermediate
Platform: Optimus Futures + MultiCharts + TradeStation
Broker/Data: Optimus Futures, Rithmic Data, TradeStation
Favorite Futures: CL, ES
 
bobbakerr's Avatar
 
Posts: 104 since Aug 2010
Thanks: 209 given, 38 received


Big Mike View Post
 
Code
			
If MarketPosition=and MACD1[1]>and MACD1<MACD1[1then Sell next bar at market
If long, and MACD1 one bar ago is above zero, and MACD1 is falling, then Sell next bar at market. I don't see anything "wrong" with the logic, can you post a screen shot of the signal not exiting when it should?

Mike


Here's a Screen shot of a Short that was initiated in the wrong place. (By the way, the Exits are good. It's the Entries that are wrong.) It was Shorted off of the MACD Indicator for the Data 1 graph, which is not supposed to be. It was supposed to be Shorted off of the MACD Indicator for the Data 2 graph, according to what I want from my code. The vertical white line is where the MACD reversed down in Data 2.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
     

Old August 28th, 2010, 08:52 PM   #10 (permalink)
Elite Member
Riverdale, Idaho, USA
 
Futures Experience: Intermediate
Platform: Optimus Futures + MultiCharts + TradeStation
Broker/Data: Optimus Futures, Rithmic Data, TradeStation
Favorite Futures: CL, ES
 
bobbakerr's Avatar
 
Posts: 104 since Aug 2010
Thanks: 209 given, 38 received



Big Mike View Post
Sorry, I just read this part of your first post.

Buy next bar at market is always going to buy at the open of the next bar.

If you want intrabar signals, you need to Format Signal, then go to Intra-Bar Order Generation tab (IOG) and enable it, this way it will submit signals on a tick-by-tick basis and not close of bar.

Mike

Mike, I don't want intrabar signals. I want the Close of the 480-Tick chart (Data #2) to Enter. That's the way I do it in real life -- that's the way I want it in MultiCharts.

Maybe I'm going about it the wrong way, and I really do appreciate your trying to help me, but that is what I SEE on the Firetip trading platform, before I act. That is what I'm trying to program.


Last edited by bobbakerr; August 28th, 2010 at 09:27 PM.
Reply With Quote
     

Reply



futures.io > Futures Trading, News, Charts and Platforms > Platforms and Indicators > TradeStation > EasyLanguage Programming > Need help with order entry on multiple dataseries

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

NinjaTrader 8: Features and Enhancements, Tips and Tricks

Dec 6
 

Al Brooks: Stop Losing when a Good Trade goes Bad, Correcting Mistakes

Elite only
 

Trading Technologies: Algo Design Lab hands-on

Dec 13
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple dataseries Breakout NinjaTrader 28 March 30th, 2015 01:14 PM
Multiple dataseries intrabarpersist ohlc Big Mike EasyLanguage Programming 17 December 27th, 2011 01:14 AM
Quicker Order Entry RambleDog NinjaTrader 6 August 1st, 2011 02:59 AM
MULTIPLE ORDER ENTRY gparkis NinjaTrader 9 May 17th, 2011 11:25 AM


All times are GMT -4. The time now is 07:50 AM.

Copyright © 2016 by 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
Page generated 2016-12-08 in 0.74 seconds with 20 queries on phoenix via your IP 54.166.112.64