Multi-Timeframe in a strategy - NinjaTrader Programming | futures io social day trading
futures io futures trading


Multi-Timeframe in a strategy
Updated: Views / Replies:8,619 / 30
Created: by max-td Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • 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.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Multi-Timeframe in a strategy

  #21 (permalink)
Elite Member
Sydney / Australia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: AMP
Favorite Futures: Oil
 
Posts: 116 since Jun 2009
Thanks: 125 given, 103 received


zeller4 View Post
jthom,

Thanks for sharing the portion of your code. It appears mrticks and I are going through a similar learning experience.

A couple quick questions:

How are your Buy and Sell variables initially set? true or false? I'm assuming false with other conditions of your code creating the true condition.
When the condition sets Buy or Sell to true, do you also restate the other one to false (keeping them paired up throughout your code)?

Is this strat COBC = false;? I'm assuming false.

When I see error messages in the log (ie "GetAtmStrategyMarketPosition() method error: Missing atmStrategyId parameter"), is that because I have a situation where there's no "check" such as
if (atmStrategyId.Length > 0)?

Thanks,
Kirk

Buy and Sell variables are initially set to false. Only Buy or Sell can be true at one time. If you look at the code carefully, there are instances where the variables are set back to false. ie if there there is an atmcancelorder or if the trade has just finished( filled )
No im running this as COBC = true. The point of running 1 tick timeframe is to pretty much run as COBC = false. However if you have an indicator that requires COBC = false and another to true, then it gets complicated. Is that what you are doing?

Yeah im assuming that error msg is because of that. Its hard to tell without seeing the code.
PM me if you need something more.

James

Reply With Quote
The following user says Thank You to jthom for this post:
 
  #22 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 received


jthom View Post
Ok you would add the strategy to a 500 tick chart.
Then add a 1 tick chart by:
Add( PeriodType.Tick, 1);

Add a Buy and Sell variable when you would set to false. Set Buy or Sell to true once entry conditions are met.
Then add this:


 
Code
                            
if (BarsInProgress == && orderId.Length 0)
    {
    
string[] status GetAtmStrategyEntryOrderStatus(orderId);
                
    
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
    
if (status.GetLength(0) > 0)
    {
     
    
// If the order state is terminal, reset the order id value
    
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
      
orderId string.Empty;
      
Buy false;
      
Sell false;
      
    
    
    if (
Buy == true && status[2] == "Working" && Close[0] == orderLimitPrice TickSize)
     {
        
AtmStrategyCancelEntryOrder(orderId);
     } 
    if (
Sell == true && status[2] == "Working" && Close[0] == orderLimitPrice TickSize)
     {
        
AtmStrategyCancelEntryOrder(orderId);
     } 
    }
    } 
// If the strategy has terminated reset the strategy id
    
else if (atmStrategyId.Length && GetAtmStrategyMarketPosition(atmStrategyId) ==  Cbi.MarketPosition.Flat)
    
atmStrategyId string.Empty;
    
Buy false;
    
Sell false

Enjoy

James - Thank you so much for that code, appreciate you going to the trouble of putting that up.

I have just edited the strat with your code and it won't compile due to an error with the reference to orderLimitPrice from the line:

if (Buy == true && status[2] == "Working" && Close[0] == orderLimitPrice + 3 * TickSize)

The error I get is "The name 'orderLimitPrice' does not exist in the current context".

So I'm going to try and use a different trigger instead of orderLimitPrice. Will let you know how I get on.


Thanks,

Gavin.



Reply With Quote
 
  #23 (permalink)
Elite Member
Florida
 
Futures Experience: Intermediate
Platform: NT7
Favorite Futures: CL, NQ, NG
 
Posts: 456 since Jun 2009
Thanks: 1,359 given, 383 received



jthom View Post
Buy and Sell variables are initially set to false. Only Buy or Sell can be true at one time. If you look at the code carefully, there are instances where the variables are set back to false. ie if there there is an atmcancelorder or if the trade has just finished( filled )
No im running this as COBC = true. The point of running 1 tick timeframe is to pretty much run as COBC = false. However if you have an indicator that requires COBC = false and another to true, then it gets complicated. Is that what you are doing?

Yeah im assuming that error msg is because of that. Its hard to tell without seeing the code.
PM me if you need something more.

James

Thanks James,

Two questions - when I'm calling the indicators, can they be COBC = false or do you comment out that line in the indicator. (see post #3 from the NT support thread that mentions that) I have set this strategy to COBC true and would like up-to-the-tick info from the indicator.

http://www.ninjatrader.com/support/forum/showthread.php?p=66428#post66428

What code do you use to ensure a fill (ie High[0] > limitPrice && Low[0] < limitPrice) ? Where should this be placed in the code in relation to the

 
Code

if (entryPriceL > 0) AtmStrategyCreate(Cbi.Action.Buy, OrderType.Limit, entryPriceL, 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
 
Or do I need to change the "0" to the limit price also?
Thanks,
Kirk

Reply With Quote
 
  #24 (permalink)
Elite Member
Sydney / Australia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: AMP
Favorite Futures: Oil
 
Posts: 116 since Jun 2009
Thanks: 125 given, 103 received

Gavin, orderlimitprice is just a variable for the Close[0]
Just remember if you are referencing the 500 tick range in the BarsinProgress == 1(1 tick) its Closes[0][0]

Reply With Quote
The following user says Thank You to jthom for this post:
 
  #25 (permalink)
Elite Member
Sydney / Australia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: AMP
Favorite Futures: Oil
 
Posts: 116 since Jun 2009
Thanks: 125 given, 103 received

Zella,
I prefer running strategies on COBC = true. Just add a smaller timeframe and run the indicator on that. ie a 1 min chart with a 5 min. You cannot have an indicator on COBC = false and a strategy with the indicator set to COBC = true. It will calculate as it set to true

Reply With Quote
The following user says Thank You to jthom for this post:
 
  #26 (permalink)
Elite Member
Florida
 
Futures Experience: Intermediate
Platform: NT7
Favorite Futures: CL, NQ, NG
 
Posts: 456 since Jun 2009
Thanks: 1,359 given, 383 received

Thanks James,

Any thoughts for the "fill" question?
kz

Reply With Quote
 
  #27 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 received


jthom View Post
Gavin, orderlimitprice is just a variable for the Close[0]
Just remember if you are referencing the 500 tick range in the BarsinProgress == 1(1 tick) its Closes[0][0]

James - I couldn't get your code to work so I kept at my own and came up with something that kind of works. The strat will close orders once the current price dips x ticks below the high of the last bar. This is for a strat with a long ATM created.

 
Code
                            
}
                
                if (
Close [0] - TickSize High[1] &&(status[2] == "Accepted" || status[2] == "Working" || status[2] == "Pending"))
                
                {
                Print(
"108 ATM cancel TFL3BR order");    
                
AtmStrategyCancelEntryOrder(orderId);
                } 
I just have to figure out how to express "close pending orders if n bars have passed with no fill" and it's there. I have posted on the NT forums asking for pointers in the right direction also so if they come up with something I'll post it here also. It's on the same thread you posted in about canceling orders after n ticks +/- movement.

Here is the full status section code,
 
Code
                            
// Check for a pending entry order
            
if (  orderId.Length 0)
            
            
            {
                
string[] status GetAtmStrategyEntryOrderStatus(orderId);
                
                
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements

                
if (status.GetLength(0) > 0)
                    
                
                if (
status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                
                {
                    Print(
"100 Reset the strategy id if filled/cancelled or rejected");    
                      
orderId string.Empty;
                                        
                }
                
                if (
Close [0] - TickSize High[1] &&(status[2] == "Accepted" || status[2] == "Working" || status[2] == "Pending"))
                
                {
                Print(
"108 ATM cancel TFL3BR order");    
                
AtmStrategyCancelEntryOrder(orderId);
                }
            } 
            
                        
            if (
atmStrategyId.Length && GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Flat)
                {
                Print(
"117   reset the strategy id");
                
atmStrategyId string.Empty;
                
orderId string.Empty;
                }


            if (
atmStrategyId.Length 0)
            {
                
                
// Print some information about the strategy to the output window
                
Print("126 At the end of  TFL3BR");
                Print(
"The current ATM Strategy market position is: " GetAtmStrategyMarketPosition(atmStrategyId));
                Print(
"The current ATM Strategy position quantity is: " GetAtmStrategyPositionQuantity(atmStrategyId));
                Print(
"The current ATM Strategy average price is: " GetAtmStrategyPositionAveragePrice(atmStrategyId));
                Print(
"The current ATM Strategy Unrealized PnL is: " GetAtmStrategyUnrealizedProfitLoss(atmStrategyId));
                Print(
"The current ATM Strategy Realized PnL is: " GetAtmStrategyRealizedProfitLoss(atmStrategyId));
            }
        } 

Reply With Quote
 
  #28 (permalink)
Elite Member
Sydney / Australia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: AMP
Favorite Futures: Oil
 
Posts: 116 since Jun 2009
Thanks: 125 given, 103 received

Gavin,

Just by looking at your code there, it seems fine. Does it work properly? You will also need to put a buy cancel order in it. Ie Close [0] + 5 * TickSize < High[1]

Does it run on COBC = false? Because if it doesnt you will need to use a smaller timeframe for the cancel option which is 1 tick.

Looks good.

Also if you want to talk about it, I have a voice ventrillo server. You can download that for free. PM me for details.

Reply With Quote
 
  #29 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 received

Hey James - I think it works OK. I need to test it on a sim feed today though. Haven't tried it with bar close set to false. As I'm running tick charts I haven't tried anything with COBC = false.

So if it doesn't run on COBC = false do you reckon I should test with a 1 tick chart?

I may take you up on that offer to talk about it. You seem to know your stuff!! Will PM you about it.


Thanks,

Gavin.

Reply With Quote
 
  #30 (permalink)
Elite Member
Sydney / Australia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: AMP
Favorite Futures: Oil
 
Posts: 116 since Jun 2009
Thanks: 125 given, 103 received


Well Im willing to help you get it running efficiently.
Ok well I have a Ventrilo Chat Server setup for you guys to chat in.

You will need a microphone.

You can download Ventrilo Client Free here:
Ventrilo - Download

The Server Ip is 180.92.192.226
Port is 4584

Or the easy way to connect is just to click this Link:
ventrilo://180.92.192.226:4584/servername=BigMikeTrading

The Channel you want to goto is BigMikeTrading.

The password for the channel is 'trading'

Look for Jimmy in there. Thats me. All are welcome to join
Its very easy to setup

Reply With Quote
The following 2 users say Thank You to jthom for this post:

Reply



futures io > > > > > Multi-Timeframe in a strategy

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW TO DO A SIMPLE MULTI-TIMEFRAME SCREEN IN MARKET SCANNER ShruggedAtlas MultiCharts 13 December 19th, 2014 12:04 PM
Multi Timeframe Price Indicator michaelf NinjaTrader 1 March 17th, 2011 01:07 PM
Multi Timeframe EMA indicator kulu NinjaTrader Programming 3 November 14th, 2010 06:10 PM
sensitivity multi-timeframe trick (small timeframe on bigger one) SARdynamite NinjaTrader Programming 4 July 15th, 2010 03:57 PM
Ninja Strategy multi-timeframe issue/Strategy to indicator nw123 NinjaTrader Programming 2 December 20th, 2009 07:24 PM


All times are GMT -4. The time now is 04:42 PM.

Copyright © 2017 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
Page generated 2017-12-18 in 0.13 seconds with 19 queries on phoenix via your IP 54.221.136.62