NexusFi: Find Your Edge


Home Menu

 





Coding Multi Time Frame (MTF) Indicators with NinjaTrader


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 180 posts (562 thanks)
    2. looks_two Zondor with 19 posts (29 thanks)
    3. looks_3 madLyfe with 16 posts (10 thanks)
    4. looks_4 BankRobberNT with 14 posts (16 thanks)
      Best Posters
    1. looks_one gomi with 3.7 thanks per post
    2. looks_two Fat Tails with 3.1 thanks per post
    3. looks_3 Zondor with 1.5 thanks per post
    4. looks_4 BankRobberNT with 1.1 thanks per post
    1. trending_up 189,208 views
    2. thumb_up 743 thanks given
    3. group 87 followers
    1. forum 424 posts
    2. attach_file 166 attachments




 
Search this Thread

Coding Multi Time Frame (MTF) Indicators with NinjaTrader

  #271 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

@Rad4633

I have tested the VisualSMA in Replay mode, and I did not encounter any problems.

The indicator plots as expected. Screenshot attached.

Attached Thumbnails
Click image for larger version

Name:	VisualSMA Replay.PNG
Views:	236
Size:	59.8 KB
ID:	55592  
Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
41 thanks
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #272 (permalink)
 BankRobberNT 
NYC
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Interactive Brokers
Trading: forex
Posts: 38 since Aug 2011

I'm working on a strategy which has ability to trade simultaneously 28 currency pairs.
It has built in Currency Strength Module (which is the reason for having added 28 pairs) , central bank intervention module, swing rays module,
round numbers, pivot points , fibonacci levels etc added.
All these indicators were stripped down to the core, optimized and rewritten to gather tha data on all 28 pairs and embedded into the strategy as functions.
There are no calls to any external indicator except the most simpliest like SMA, EMA, ZLEMA
I'm planing to use that simple code which I've sent to you for MTF SMA and MTF EMA.
Now my latest challenge is to embed my MTF EMA-SMA code into the strategy without calling it as an external indicator.
I use MTF EMA 5, 15, 30, 60 and 240 minutes and my main chart is BetterRenko.
Everything works fine so far on all 28 pairs, I'm just trying to shorten and optimize the code
Reason for trying to embed the code relies on the fact that anyway the strategy will add additional time frame if i call the external MTF EMA-SMA indicator, so I could add those time frames by myself and save some time here by calling the regular SMA or EMA once in every 5, 15, 30, 60, 240 minutes. There is no need for anything else.
What I'm gonna get is also the ability to access those additional 5, 15, 30, 60, 240 minutes time frames
Yeah i know its silly, I have BarsInProgress up to 163 LOL

Reply With Quote
  #273 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



grofzr View Post
I'm working on a strategy which has ability to trade on 28 currency pairs.
It has built in Currency Strength Module (which is the reason for having added 28 pairs) , central bank intervention module, swing rays module,
round numbers, pivot points , fibonacci levels etc added.
All these indicators were stripped down to the core, optimized and rewritten to gather tha data on all 28 pairs and embedded into the strategy as functions.
There are no calls to any external indicator except the most simpliest like SMA, EMA, ZLEMA
I'm planing to use that simple code which I've sent to you for MTF SMA and MTF EMA.
Now my latest challenge is to embed my MTF code into the strategy without calling it as an external indicator.
I use MTF EMA 5, 15, 30, 60 and 240 minutes and my main chart is BetterRenko.
Everything works fine so far on all 28 pairs, I'm just trying to shorten and optimize the code
Reason for trying to embed the code relies on the fact that anyway the strategy will add additional time frame if i call the external MTF indicator, so I can add those time frames by myself and save some time here by calling the regular SMA or EMA once in every 5, 15, 30, 60, 240 minutes. There is no need for anything else.
What I'm gonna get is also the ability to access those additional 5, 15, 30, 60, 240 minutes time frames
Yeah i know its silly, I have BarsInProgress up to 163 LOL

Good idea to embed the secondary bar series directly in a strategy.

I would like to know whether you manage to freeze NT with BIP 163. I bet so.

Started this thread Reply With Quote
  #274 (permalink)
 BankRobberNT 
NYC
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Interactive Brokers
Trading: forex
Posts: 38 since Aug 2011


Fat Tails View Post
Good idea to embed the secondary bar series directly in a strategy.

I would like to know whether you manage to freeze NT with BIP 163. I bet so.

While i had BIP 55 (28xBetterRenko and 28x60 min ) i didn't have any freezes not even during interventions, but NT constantly freeze when i loose internet connection.
Now for the additional 100'something BIP I'm still coding but the code is simple just to invoke EMA-SMA once in 5 15 30 etc minutes, will see....
My only concern is that every 240 minutes it has 28x5 FirstTickOfBar that could be a problem
I dont even use FirstTickOfBar anymore, I'm affraid it can miss the first tick here or there, i use simple comparission between stored and actual CurrentBar, this way it will catch up if has missed the first tick.

Reply With Quote
  #275 (permalink)
 BankRobberNT 
NYC
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Interactive Brokers
Trading: forex
Posts: 38 since Aug 2011

Oh boy, this embeded MTF EMA-SMA is working like a charm, 7 instruments 6 timeframes, no problem.

Reply With Quote
  #276 (permalink)
 HighDesertTrader 
Albuquerque, New Mexico/USA
 
Experience: Intermediate
Platform: NinjaTrader-Continuum(Mirus)
Trading: emini Currency and Index Futures
Posts: 104 since Jan 2011
Thanks Given: 291
Thanks Received: 108


Fat Tails View Post
As was discovered by @ grofzr, both indicators were lagging when set to CalculateOnBarClose = true. I admit that the original design of the indicators was adapted to CalculateOnBarClose = false setting, which is more difficult, so I somehow neglected this part.

Testing everything is near-impossible. You add range bars to volume bars, then there is a session break, although the indicator works on historical data and on real-time data, it may have a problem with the transition as NinjaTrader builds a hybrid bar from historical and real-time tick in a non-reproducible manner, there is the possibility of CalculateOnBarClose = false setting or CalculateOnBarClose = true setting, there are technical breaks to be considered where there is no data, as the NinjaTrader heuristics for a trading day does not allow to exclude those session breaks via a session template. Let us say it is sort of a large headache until it works.

I have now tested the updated versions with CalculateOnBarClose = true setting, and so far they passed the test.



Hello Fat Tails,

I know you are a busy guy and have "bigger fish to fry" than this but I'm hoping that you have on your list of things to do adding a colored slope option (green/red/yellow :: up/down/flat) for the Vis SMA and Vis EMA MTF indicators.

In the meantime though, thanks for your work on these incredible indicators. They continue to be a big part in my trading (with or without the slope color). As others has said, "They work like a charm."

Reply With Quote
Thanked by:
  #277 (permalink)
 walker 
New York
 
Experience: Beginner
Platform: Ninjatrader
Broker: IB/AMP
Trading: ES
Posts: 36 since Dec 2011
Thanks Given: 568
Thanks Received: 22

Hi Fat Tails,

Could not get much help from Ninja support, will you please help? I just want to have a simple Ninjascript to play with. The idea is to buy when 1) MACD crossabove AVG on 1-min chart and 2) MACD >= AVG on 5-min chart. The opposite would generate a sell signal. It would be better If you can add a 8-tick Target and a 6-tick stop loss. I am not good at coding, would really appreciate your help.

Reply With Quote
  #278 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


walker View Post
Hi Fat Tails,

Could not get much help from Ninja support, will you please help? I just want to have a simple Ninjascript to play with. The idea is to buy when 1) MACD crossabove AVG on 1-min chart and 2) MACD >= AVG on 5-min chart. The opposite would generate a sell signal. It would be better If you can add a 8-tick Target and a 6-tick stop loss. I am not good at coding, would really appreciate your help.

This can be coded as a simple strategy. Unfortunately my time is limited, and I cannot spend hours for free on coding strategies. I would suggest that you try to convince somebody else, maybe here:



If nobody responds to your request, you can either try to learn some basic C# and code it yourself or pay somebody to code it. But as we both know that anything as simple as your request does not make money, your best options would be

-> to code it yourself
-> or to find somebody who is bored and can code it

You could load one of the sample strategies, for example the MA crossover, and then modify it to use the crossover MACD/Signalline instead. That is relatively simple.

Started this thread Reply With Quote
  #279 (permalink)
 BankRobberNT 
NYC
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Interactive Brokers
Trading: forex
Posts: 38 since Aug 2011


walker View Post
Hi Fat Tails,

Could not get much help from Ninja support, will you please help? I just want to have a simple Ninjascript to play with. The idea is to buy when 1) MACD crossabove AVG on 1-min chart and 2) MACD >= AVG on 5-min chart. The opposite would generate a sell signal. It would be better If you can add a 8-tick Target and a 6-tick stop loss. I am not good at coding, would really appreciate your help.

PLEASE TEST IT WELL! On DEMO of course.

Attached Files
Elite Membership required to download: MACDCrossOverMTFv1.0.zip
Reply With Quote
  #280 (permalink)
 walker 
New York
 
Experience: Beginner
Platform: Ninjatrader
Broker: IB/AMP
Trading: ES
Posts: 36 since Dec 2011
Thanks Given: 568
Thanks Received: 22


Hi BankRobberNT,

Thanks so much for the quick coding. One issue here, if I load it in 1-min chart, it buys whenever MACD crossabove AVG regardless the MACD status on 5-min chart. If I load it in both 1-min and 5-min charts, something quite interesting happens. It buys first when MACD crossabove AVG on 1-min chart and will buy again later when MACD crossabove AVG on the 5-min chart. Also, if it buys when MACD crossabove AVG on 5-min chart (depend on what time I choose to start the replay) and later MACD crossbelow AVG on 1-min chart, it sells a contract and becomes flat. But those Target and Stoploss orders are still there. I will do more testing. Hope this does not confuse you. Really appreciate your help. I don't need a quick fix if you still want to help. Take your time as I am taking my time and learn little by little.

Reply With Quote




Last Updated on April 19, 2022


© 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