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,592 / 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

  #11 (permalink)
Elite Member
Calgary Canada
 
Futures Experience: Intermediate
Platform: Ninja
Broker/Data: IB/Kinetic
Favorite Futures: 6E, CL
 
jackyd's Avatar
 
Posts: 47 since Jun 2009
Thanks: 44 given, 18 received

Max, in case you haven't already solved this, here's something simple to try to do a sanity check. I plan to do some testing with this period type soon as well, so good luck.

 
Code
if (BarsInProgress == 0)
{
	if (Position.MarketPosition != MarketPosition.Flat)
	{
		Print(Time[0] + " Process Range Bar 0 - High: " + High[0] + ", Low: "  + Low[0] + ", Close: "  + Close[0]);
	}
}

if (BarsInProgress == 1)
{
	if (Position.MarketPosition != MarketPosition.Flat)
	{
		Print(Time[0] + " ======> Process Range Bar 1 - High: " + High[0] + ", Low: "  + Low[0] + ", Close: "  + Close[0]);
	}
}


Last edited by jackyd; July 28th, 2009 at 01:46 AM.
Reply With Quote
 
  #12 (permalink)
Elite Member
Frankfurt
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 917 received

thank you,
i just tried it again on market replay to make shure my logic is right -
>> the ATM - order-cancelation works OK with a call from the main timeframe

It does not work with my trys from the second timeframe ...... there is a conflict somewhere i have to find.

max-td
Reply With Quote
 
  #13 (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



max-td View Post
well ... there is nothing special inside the strategy ---- just some simple conditions and a call for an Entry via ATM-creation :


if (blabla )


{
AtmStrategyCreate(Action.Buy, OrderType.Limit, valueClose - 1 , 0,
TimeInForce.Day, entryorderid, atmname,
atmorderid);
create = 1;
}

dont know could cause MTF- troubles here -- but never used MTF before i must say.

max-td, for the above to work do you need the following ints?

private string entryorderid = string.Empty;
private string atmorderid = string.Empty;

Reply With Quote
 
  #14 (permalink)
Elite Member
Frankfurt
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 917 received

hi mrtick,
yes thats right.

i have the following in my #region variables:

private string entryorderid = "";
private string atmorderid = "";
private string atmname = "";

to run this shown example.

max-td
Reply With Quote
 
  #15 (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


max-td View Post
hi mrtick,
yes thats right.

i have the following in my #region variables:

private string entryorderid = "";
private string atmorderid = "";
private string atmname = "";

to run this shown example.


Thanks for the reply. Have a good weekend!

Reply With Quote
The following user says Thank You to mrticks for this post:
 
  #16 (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


max-td View Post
thank you,
i just tried it again on market replay to make shure my logic is right -
>> the ATM - order-cancelation works OK with a call from the main timeframe

It does not work with my trys from the second timeframe ...... there is a conflict somewhere i have to find.

Hi Max,

Any chance you could post the code of the section you have that cancels the order? I have a good ATM strat but the cancel component is not working.

 
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(
                        CurrentBar > barNumberOfOrder + 1 &&
                        (status[1] == "Accepted" || status[1] == "Working" || status[1] == "Pending"))
                    AtmStrategyCancelEntryOrder(orderId);
                    Print("TFL3BRATM Cancelled Order");
                    atmStrategyId = string.Empty;
                    orderId = string.Empty;
                                        
                }
When I take out CurrentBar > barNumberOfOrder + 1 && I can get the orders to cancel(straight away but good for testing).

I have set TraceOrders = true; and from the output window can't see any errors. Even with print statements it looks good, the AtmCancelEntryOrder is called but doesn't actually cancel with CurrentBar > barNumberOfOrder + 1 . However, I can get it to cancel if I just call the cancel if any order is pending/working or accepted.

The NT site doesn't have any actual samples of working strats with AtmStrategyCancelEntryOrder(orderId); on it, just the command variable page.

Did you ever get it to work? If you have some working sample code you could post would really appreciate it!


Thanks,

Gavin.

Reply With Quote
 
  #17 (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,
What time frame are you running the chart in and what market is it for? Futures?
I can post some code once I know that.

James

Reply With Quote
 
  #18 (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

Hi James - I use tick charts. Have been testing it on the mini Russel 500 tick chart. That would be great if you could post that!

Thanks,

Gavin.

Reply With Quote
 
  #19 (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

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

Reply With Quote
The following 2 users say Thank You to jthom for this post:
 
  #20 (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,

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.



I've started my code off the SampleAtmStrategy which is a long only sample. How often would you use variables that are specifically long or short to keep them separated? I've tried orderIdL and orderIdS and atmStrategyIdL and atmStrategyIdS. Those seem to allow for going long AND short at the same time which could solve a bracketing type scenario but can create a mess also. Or if you have barNumber assignments do you use entryBarL = CurrentBar or just entryBar = CurrentBar?


Thanks,
Kirk

Reply With Quote

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 06:20 AM.

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-15 in 0.12 seconds with 19 queries on phoenix via your IP 107.20.115.174