NexusFi: Find Your Edge


Home Menu

 





Multi-Timeframe in a strategy


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one mrticks with 8 posts (1 thanks)
    2. looks_two jthom with 7 posts (7 thanks)
    3. looks_3 max-td with 7 posts (0 thanks)
    4. looks_4 caprica with 5 posts (0 thanks)
    1. trending_up 16,407 views
    2. thumb_up 8 thanks given
    3. group 3 followers
    1. forum 30 posts
    2. attach_file 0 attachments




 
Search this Thread

Multi-Timeframe in a strategy

  #1 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

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

Can you help answer these questions
from other members on NexusFi?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Deepmoney LLM
Elite Quantitative GenAI/LLM
 
  #2 (permalink)
 
caprica's Avatar
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
Posts: 155 since Jul 2009
Thanks Given: 45
Thanks Received: 114


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
  #3 (permalink)
 
caprica's Avatar
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
Posts: 155 since Jul 2009
Thanks Given: 45
Thanks Received: 114


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
  #4 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

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
  #5 (permalink)
 
caprica's Avatar
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
Posts: 155 since Jul 2009
Thanks Given: 45
Thanks Received: 114


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
  #6 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

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
  #7 (permalink)
 
caprica's Avatar
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
Posts: 155 since Jul 2009
Thanks Given: 45
Thanks Received: 114


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
  #8 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

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
  #9 (permalink)
 
caprica's Avatar
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
Posts: 155 since Jul 2009
Thanks Given: 45
Thanks Received: 114


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
  #10 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927


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




Last Updated on July 22, 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