NexusFi: Find Your Edge


Home Menu

 





Been at it for hours...Definitely something simple!!! AHHHHH


Discussion in NinjaTrader

Updated
    1. trending_up 4,457 views
    2. thumb_up 7 thanks given
    3. group 2 followers
    1. forum 23 posts
    2. attach_file 4 attachments




 
Search this Thread

Been at it for hours...Definitely something simple!!! AHHHHH

  #11 (permalink)
 
Tanju23's Avatar
 Tanju23 
Riverview Fl
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures
Trading: ES, TF
Posts: 37 since Dec 2009
Thanks Given: 24
Thanks Received: 4

Its coloring when it is supposed to but it seems only when the conditions are met. Is there a way to "latch" it to stay until the opposite is met?



Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
26 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #12 (permalink)
 
Tanju23's Avatar
 Tanju23 
Riverview Fl
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures
Trading: ES, TF
Posts: 37 since Dec 2009
Thanks Given: 24
Thanks Received: 4

Here is another example. In the pic It shows a magenta and should change to cyan when the highs break the swing


Started this thread Reply With Quote
  #13 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623


You need to add one more color variable eg.:

 
Code
private Color useThisColor = Color.White;  //just setting up some default
then OnBarUpdate:

 
Code
if (conditionsUpAreMet)
{
    useThisColor = sMAUp;
}
if (conditionsDownAreMet)
{
    useThisColor = sMADn;
}

// and at the bottom:
PlotColors[0][0] = useThisColor;

Reply With Quote
  #14 (permalink)
 
Tanju23's Avatar
 Tanju23 
Riverview Fl
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures
Trading: ES, TF
Posts: 37 since Dec 2009
Thanks Given: 24
Thanks Received: 4

Just wanted to give you an update. Your guidance paid off and its doing what it is supposed to do!! Thank you again!


Started this thread Reply With Quote
  #15 (permalink)
 
Tanju23's Avatar
 Tanju23 
Riverview Fl
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures
Trading: ES, TF
Posts: 37 since Dec 2009
Thanks Given: 24
Thanks Received: 4

You helped me get the indicator working great, been using it for a few weeks now with success. Now I'm attempting an automated entry.


Here is my generic code for the purpose of illustration.
 
Code
// Condition set 1
            if (MyTML(Weighted, MB, TMl, 5, 8).TMLUp[1] < MyTML(Weighted, MB, TMl, 5, 8).TMLUp[0]
                && MyMACDBBLines(10, 12, 26, 1).BBMACD[0] > MyMACDBBLines(10, 12, 26, 1).Upper[0])
                
            {
                EnterLong(Contracts, "");
            }






For some reason even though I am saying only "Up", as you can see it is entering on the "Down" indication as well. Any insight would be appreciated. Also, I have to use the indicator on COBC true because it doesn't work quite right with it on false. Probably a separate issue but just throwing all my delimas out there. Thank you to anyone in advanced.

Started this thread Reply With Quote
  #16 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623


Tanju23 View Post
For some reason even though I am saying only "Up", as you can see it is entering on the "Down" indication as well. Any insight would be appreciated. Also, I have to use the indicator on COBC true because it doesn't work quite right with it on false. Probably a separate issue but just throwing all my delimas out there. Thank you to anyone in advanced.

Welcome back

The reason because COBC false doesn't work quite well for you is probably because the values of the indicators change intrabar (ie: during a bar creation you can have: Up, Down, Up, Down, etc.).

As to your main problem in your condition you compare TMLUp[1] and TMLUp[0], but what are the values of TMLUp - Is it possible that the line will be colored down even though [0] is greater than [1]?

I would recommend adding some Print statements eg.
 
Code
Print("TMLUp[1]: "+MyTML(Weighted, MB, TMl, 5, 8).TMLUp[1]);
for all the values so you could check if the condition is what you expect.

Reply With Quote
Thanked by:
  #17 (permalink)
 
Tanju23's Avatar
 Tanju23 
Riverview Fl
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures
Trading: ES, TF
Posts: 37 since Dec 2009
Thanks Given: 24
Thanks Received: 4

What are the print statements for?

Would posting the code for the indicator you helped me create help you see an issue?

Started this thread Reply With Quote
  #18 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623

Print will print the message you want into the output window. You can open Output Window from Control Center (Tools) or from NinjaScript code editor (4th icon from the left on the toolbar)

Reply With Quote
Thanked by:
  #19 (permalink)
 
Tanju23's Avatar
 Tanju23 
Riverview Fl
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures
Trading: ES, TF
Posts: 37 since Dec 2009
Thanks Given: 24
Thanks Received: 4

yeah it looks like up is being recognized for the whole indicator, how do i get it to just be set with the plots up and down?


here is the indicator. What can you see that I could change...if anything.



 
Code
protected override void Initialize()
        {
            Add(new Plot(new Pen(Color.Cyan,2), "TMLUp"));
          	Add(new Plot(new Pen(Color.Magenta,2), "TMLDn"));
            Overlay				= true;
			PriceTypeSupported	= false;
			PlotsConfigurable   = true;
			CalculateOnBarClose = false;
			
        }
		
		protected override void OnStartUp()
		
		{
			Plots[0].PlotStyle = plot0Style;
			Plots[0].Pen.DashStyle = dash0Style;
			Plots[1].PlotStyle = plot1Style;
			Plots[1].Pen.DashStyle = dash1Style;
		}

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            
			// Are there enough bars
			if (CurrentBar < Period) return;
			
						
			// Calculations
			TMLUp.Set(LinReg(Input,period)[0]);
            TMLDn.Set(LinReg(Input,period)[0]);
			{
				// If high breaks a swing high
				if (High[0] > Swing(swings).SwingHigh[0] || Low[0] >= EMA(Keltner)[0] + Spread * TickSize)
				{
					useThisColor = tMLUp;
				}
			}
			
			{
				// If low breaks a swing low
				if (Low[0] < Swing(swings).SwingLow[0] || High[0] < EMA(keltner)[0] - spread * TickSize)
				{
					useThisColor = tMLDn;
				}
				
				
				PlotColors[0][0] = useThisColor;

Started this thread Reply With Quote
  #20 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623


Your TMLUp and TMLDown seem to be nothing else than just a reference to the same LinReg. If your goal for TMLUp and TMLDown is to only represent binary result (it is either Up or Down, 1 or -1) then you need one additional dataseries TML and temp int, eg.: private int tempTML = 0;
Then in your code just as you did with color:

 
Code
// Calculations
TMLUp.Set(LinReg(Input,period)[0]);
TMLDn.Set(LinReg(Input,period)[0]);

// If high breaks a swing high
if (High[0] > Swing(swings).SwingHigh[0] || Low[0] >= EMA(Keltner)[0] + Spread * TickSize)
{
    useThisColor = tMLUp;
    tempTML = 1;
}

// If low breaks a swing low
if (Low[0] < Swing(swings).SwingLow[0] || High[0] < EMA(keltner)[0] - spread * TickSize)
{
    useThisColor = tMLDn;
    tempTML = -1;
}

TML.Set(tempTML);
In your strategy you can then ask for:
 
Code
if((YourIndicator.TML[0] == 1) 
{
    EnterLong();
}
if(YourIndicator.TML[0] == -1) 
{
    EnterShort();
}
As already mentioned before remove the {} that are not following a method, condition or property details - this is really bad habit and makes the code unreadable - there is no benefit and high cost to using them.

Reply With Quote
Thanked by:




Last Updated on April 16, 2015


© 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