NexusFi: Find Your Edge


Home Menu

 





Need help with order entry on multiple dataseries


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one bobbakerr with 12 posts (0 thanks)
    2. looks_two Big Mike with 7 posts (3 thanks)
    3. looks_3 thatguy with 2 posts (3 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 9,346 views
    2. thumb_up 6 thanks given
    3. group 1 followers
    1. forum 20 posts
    2. attach_file 1 attachments




 
Search this Thread

Need help with order entry on multiple dataseries

(login for full post details)
  #1 (permalink)
 
bobbakerr's Avatar
 bobbakerr 
Riverdale, Idaho, USA
 
Experience: Intermediate
Platform: Optimus Futures + MultiCharts + TradeStation
Broker: Optimus Futures, Rithmic Data, TradeStation
Trading: CL, ES
Posts: 115 since Aug 2010
Thanks Given: 240
Thanks Received: 51

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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trader Dale [email protected] or Scammer Dale
Trading Reviews and Vendors
Request for MACD with option to use different MAs for fa …
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Tao te Trade: way of the WLD
30 thanks
Supertradersams Thread Journal on NQ/MNQ
25 thanks
GFIs1 1 DAX trade per day journal
24 thanks
Deaddogs Stock Trading
23 thanks
Just another trading journal: PA, Wyckoff & Trends
12 thanks

(login for full post details)
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Posts: 50,234 since Jun 2009
Thanks Given: 33,106
Thanks Received: 101,351


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

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor


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


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:
(login for full post details)
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Posts: 50,234 since Jun 2009
Thanks Given: 33,106
Thanks Received: 101,351

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

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor


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


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
(login for full post details)
  #5 (permalink)
 
bobbakerr's Avatar
 bobbakerr 
Riverdale, Idaho, USA
 
Experience: Intermediate
Platform: Optimus Futures + MultiCharts + TradeStation
Broker: Optimus Futures, Rithmic Data, TradeStation
Trading: CL, ES
Posts: 115 since Aug 2010
Thanks Given: 240
Thanks Received: 51


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.

Started this thread Reply With Quote
(login for full post details)
  #6 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Posts: 50,234 since Jun 2009
Thanks Given: 33,106
Thanks Received: 101,351


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

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor


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


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
(login for full post details)
  #7 (permalink)
 
bobbakerr's Avatar
 bobbakerr 
Riverdale, Idaho, USA
 
Experience: Intermediate
Platform: Optimus Futures + MultiCharts + TradeStation
Broker: Optimus Futures, Rithmic Data, TradeStation
Trading: CL, ES
Posts: 115 since Aug 2010
Thanks Given: 240
Thanks Received: 51


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);

Started this thread Reply With Quote
(login for full post details)
  #8 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Posts: 50,234 since Jun 2009
Thanks Given: 33,106
Thanks Received: 101,351


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

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor


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


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Attached Thumbnails
Click image for larger version

Name:	8-28-2010 6-02-28 PM.jpg
Views:	265
Size:	75.8 KB
ID:	19314  
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
(login for full post details)
  #9 (permalink)
 
bobbakerr's Avatar
 bobbakerr 
Riverdale, Idaho, USA
 
Experience: Intermediate
Platform: Optimus Futures + MultiCharts + TradeStation
Broker: Optimus Futures, Rithmic Data, TradeStation
Trading: CL, ES
Posts: 115 since Aug 2010
Thanks Given: 240
Thanks Received: 51


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.



Started this thread Reply With Quote
(login for full post details)
  #10 (permalink)
 
bobbakerr's Avatar
 bobbakerr 
Riverdale, Idaho, USA
 
Experience: Intermediate
Platform: Optimus Futures + MultiCharts + TradeStation
Broker: Optimus Futures, Rithmic Data, TradeStation
Trading: CL, ES
Posts: 115 since Aug 2010
Thanks Given: 240
Thanks Received: 51



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.

Started this thread Reply With Quote





Last Updated on August 29, 2010


© 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