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



Multi-Timeframe in a strategy


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one mrticks with 8 posts (1 thanks)
    2. looks_two max-td with 7 posts (0 thanks)
    3. looks_3 jthom with 7 posts (7 thanks)
    4. looks_4 caprica with 5 posts (0 thanks)
    1. trending_up 11,763 views
    2. thumb_up 8 thanks given
    3. group 3 followers
    1. forum 30 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
 

Multi-Timeframe in a strategy

(login for full post details)
  #1 (permalink)
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 924 received

Hi,
i try to use following idea from caprica that i found really interesting :

In the Initialize section add the line

Add(PeriodType.Range, 1)

Using range 1 instead of tick 1 is much more efficient and will still manage the trade every 1 tick of price movement. Helpful for trailing stops or etc.


my idea is :
to cancel a limitorder if i get no fill and the price is running away.

i have a strategy that is working OK.
now i add
Add(PeriodType.Range, 1) In the Initialize section -- a basic thing.

now i found out that i have to use if (BarsInProgress == 0)
at the biginning to keep my strategy in the basic timeframe for checking the entryconditions.

Once my limit-order is in the market, i want to use the second timeframe (1 Range) to manage the order-canceling if needed.

i tried different ways - also with if (BarsInProgress == 1) or Highs[1] [0] to have a switch to the 1 Range timeframe --- with no sucsess.

samething i am doing wrong.

any tips / ideas to that ?


if
(

create==1 // means Limit-Order is in the market

&&

valueClose +5 <= Highs[1] [0]

// ( valueClose +5 = the last Barclose+5 ticks of the main timeframe )
//( Highs[1] [0] should represent the High of the 1-Range-timeframe)


)

{
AtmStrategyCancelEntryOrder(entryorderid);

}

max-td
Started this thread Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(166 thanks from 30 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(114 thanks from 32 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #2 (permalink)
USA
 
Experience: Master
Platform: NinjaTrader
 
caprica's Avatar
 
Posts: 155 since Jul 2009
Thanks: 45 given, 112 received


max-td View Post
Hi,
i try to use following idea from caprica that i found really interesting :

In the Initialize section add the line

Add(PeriodType.Range, 1)

Using range 1 instead of tick 1 is much more efficient and will still manage the trade every 1 tick of price movement. Helpful for trailing stops or etc.


my idea is :
to cancel a limitorder if i get no fill and the price is running away.

i have a strategy that is working OK.
now i add
Add(PeriodType.Range, 1) In the Initialize section -- a basic thing.

now i found out that i have to use if (BarsInProgress == 0)
at the biginning to keep my strategy in the basic timeframe for checking the entryconditions.

Once my limit-order is in the market, i want to use the second timeframe (1 Range) to manage the order-canceling if needed.

i tried different ways - also with if (BarsInProgress == 1) or Highs[1] [0] to have a switch to the 1 Range timeframe --- with no sucsess.

samething i am doing wrong.

any tips / ideas to that ?


if
(

create==1 // means Limit-Order is in the market

&&

valueClose +5 <= Highs[1] [0]

// ( valueClose +5 = the last Barclose+5 ticks of the main timeframe )
//( Highs[1] [0] should represent the High of the 1-Range-timeframe)


)

{
AtmStrategyCancelEntryOrder(entryorderid);

}

If you use any BarsSinceEntry() or BarsSinceExit() anywhere in your script at all, you must rewrite them to make them MTF compatible. Change to BarsSinceEntry(0, "long", 0) to indicate barsarray 0, signal name "long", last entry.

If you aren't using that and still having trouble... Highs[1][0] would represent barsarray 1 bar 0 (last bar). You are right.

Also on your order submission, you can submit it to a smaller time frame:
EnterLong(1, 3, "long");

This will submit to bars array 1, order quantity 3, for long. Submitting to smaller time frame is useful for limit order because ninja will cancel the limit order at the end of the bar if not filled so keep in mind this and size of time frame.

As for cancelling an order manually, sorry I can not help. I do not use limit orders because of all the extra bugs in ninja to deal with them in backtesting.

"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

Reply With Quote
 
(login for full post details)
  #3 (permalink)
USA
 
Experience: Master
Platform: NinjaTrader
 
caprica's Avatar
 
Posts: 155 since Jul 2009
Thanks: 45 given, 112 received


Also remember your other indicator based signals to need changing such as

double ma = EMA(BarsArray[1], 21)[0];

You can do the if (BarsInProgress == 1) method as well, but remember that if you check a dataseries value for a BarsArray other than current it will be zero/null. For instance if you .Set a dataseries in array 1 and check it in array 0, sometimes it will be zero/null.

I prefer to set the dataseries in all time frames and call it using the BarsArray[x] method so the dataseries is never 0/null.

so I am pointing all of this out because I do not know if your script in general is not MTF compatbile until you make all these changes or if everything is fine except you cant cancel the order.

"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

Reply With Quote
 
(login for full post details)
  #4 (permalink)
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 924 received

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
Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
USA
 
Experience: Master
Platform: NinjaTrader
 
caprica's Avatar
 
Posts: 155 since Jul 2009
Thanks: 45 given, 112 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;
}

Turn on TraceOrders and check the log to see if something obvious is appearing there.

"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

Reply With Quote
 
(login for full post details)
  #6 (permalink)
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 924 received

the strategy is working -- order is starting -- ATM runs fine -- all OK
also nothing in the logs...

only the cancel-function doesnt work

max-td
Started this thread Reply With Quote
 
(login for full post details)
  #7 (permalink)
USA
 
Experience: Master
Platform: NinjaTrader
 
caprica's Avatar
 
Posts: 155 since Jul 2009
Thanks: 45 given, 112 received


max-td View Post
the strategy is working -- order is starting -- ATM runs fine -- all OK
also nothing in the logs...

only the cancel-function doesnt work

You have TraceOrders on and output window open? The cancel order works fine in a non-MTF?

"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 924 received

what do you mean by : TraceOrders on and output window open?


The cancel order works fine in a non-MTF? if i use a non-MTF-condition - the cancel-logic works.

max-td
Started this thread Reply With Quote
 
(login for full post details)
  #9 (permalink)
USA
 
Experience: Master
Platform: NinjaTrader
 
caprica's Avatar
 
Posts: 155 since Jul 2009
Thanks: 45 given, 112 received


max-td View Post
what do you mean by : TraceOrders on and output window open?


The cancel order works fine in a non-MTF? if i use a non-MTF-condition - the cancel-logic works.

 
Code
                            
In Initialize()


TraceOrders true
Open the Output Window, Tools -> Output Window.

"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

Reply With Quote
 
(login for full post details)
  #10 (permalink)
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 924 received


k - did that ... -- clear outputs for me....

init
start
entryorderid= 78fe3748de0f4f70b441ca3ae9b5c4ca
atmorderid= a711fb5193ff4c4ba3448538c8fd5141
atmname= zuni29
------------------------------------------------1
state=start
start
entryorderid= 3a8d7a5c771a460e9098874afd42be51
atmorderid= ed486e8224744fd293ba15fce757c972
atmname= zuni29

max-td
Started this thread Reply With Quote
 
(login for full post details)
  #11 (permalink)
Calgary Canada
 
Experience: Intermediate
Platform: Ninja
Broker: IB/Kinetic
Trading: 6E, CL
 
jackyd's Avatar
 
Posts: 47 since Jun 2009
Thanks: 44 given, 20 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]);
	}
}

Reply With Quote
 
(login for full post details)
  #12 (permalink)
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 924 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
Started this thread Reply With Quote
 
(login for full post details)
  #13 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 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
 
(login for full post details)
  #14 (permalink)
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 924 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
Started this thread Reply With Quote
 
(login for full post details)
  #15 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 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:
 
(login for full post details)
  #16 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 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
 
(login for full post details)
  #17 (permalink)
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
 
Posts: 118 since Jun 2009
Thanks: 128 given, 105 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
 
(login for full post details)
  #18 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 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
 
(login for full post details)
  #19 (permalink)
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
 
Posts: 118 since Jun 2009
Thanks: 128 given, 105 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:
 
(login for full post details)
  #20 (permalink)
Florida
 
Experience: Intermediate
Platform: NT7
Trading: CL, NQ, NG
 
Posts: 469 since Jun 2009
Thanks: 1,401 given, 402 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
 
(login for full post details)
  #21 (permalink)
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
 
Posts: 118 since Jun 2009
Thanks: 128 given, 105 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:
 
(login for full post details)
  #22 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 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
 
(login for full post details)
  #23 (permalink)
Florida
 
Experience: Intermediate
Platform: NT7
Trading: CL, NQ, NG
 
Posts: 469 since Jun 2009
Thanks: 1,401 given, 402 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.

https://www.ninjatrader.com/support/forum/showthread.php?p=66428

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
 
(login for full post details)
  #24 (permalink)
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
 
Posts: 118 since Jun 2009
Thanks: 128 given, 105 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:
 
(login for full post details)
  #25 (permalink)
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
 
Posts: 118 since Jun 2009
Thanks: 128 given, 105 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:
 
(login for full post details)
  #26 (permalink)
Florida
 
Experience: Intermediate
Platform: NT7
Trading: CL, NQ, NG
 
Posts: 469 since Jun 2009
Thanks: 1,401 given, 402 received

Thanks James,

Any thoughts for the "fill" question?
kz

Reply With Quote
 
(login for full post details)
  #27 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 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
 
(login for full post details)
  #28 (permalink)
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
 
Posts: 118 since Jun 2009
Thanks: 128 given, 105 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
 
(login for full post details)
  #29 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 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
 
(login for full post details)
  #30 (permalink)
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
 
Posts: 118 since Jun 2009
Thanks: 128 given, 105 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:
 
(login for full post details)
  #31 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 received

Thanks James, installing it now.

Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Multi-Timeframe in a strategy


Last Updated on July 22, 2010


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
     



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