NexusFi: Find Your Edge


Home Menu

 





How can I get this counter to work properly - TD Sequential


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one kaywai with 33 posts (1 thanks)
    2. looks_two decs0057 with 21 posts (2 thanks)
    3. looks_3 cory with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 51,859 views
    2. thumb_up 4 thanks given
    3. group 4 followers
    1. forum 56 posts
    2. attach_file 37 attachments




 
Search this Thread

How can I get this counter to work properly - TD Sequential

  #1 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7

Hi,

I have a counter which commences counting if close[0] < close[4]. code is as follows:-

if (Close[0] < Close[4])
{
BS++;
DrawText(...)
}
else BS = 0;

If I want this counter to count to only 9, I would add
if (BS==9)
{
BS = 0;
}

What I also want it to do is initiate a new and independent count which only counts if close[0] <= low[2] and for it to commence when BS = 9. How would I do that?

I tried including it here:-

if (BS==9)
{
if Close[0] <= Low[2]
{
BQ++
}
BS = 0;
}

This only counts everytime BS gets to 9. Please help.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Quantum physics & Trading dynamics
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
 
  #3 (permalink)
 decs0057 
Munich, Germany
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Broker: IB, NinjaTrader Brokerage
Trading: ES,NQ,6E
Posts: 71 since Feb 2010
Thanks Given: 15
Thanks Received: 25


you can use a flag indicating BS == 9

if (BS==9)
{
BS = 0;
flagBS9 = true;
}

if( flagBS9 == true )
{
if Close[0] <= Low[2]
{
BQ++
}
}

Reply With Quote
  #4 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7

sorry decs0057 but what is a flag?

Reply With Quote
  #5 (permalink)
 decs0057 
Munich, Germany
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Broker: IB, NinjaTrader Brokerage
Trading: ES,NQ,6E
Posts: 71 since Feb 2010
Thanks Given: 15
Thanks Received: 25

boolean variable

initialize like this

bool flagBS9 = false;

Reply With Quote
Thanked by:
  #6 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7

Decs0057, it's still only counting when 1) 9 consecutive closes, each less than its respective cloe 4 bars ago and 2) added the extra condition that on the 9th count, the close is <= low two bars earlier.

1) need a 9 count to start the 2nd condition count
2) need the 2nd condition (close[0] <= low[2]) to count without taking into consideration the initial 9 count.

Reply With Quote
  #7 (permalink)
 decs0057 
Munich, Germany
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Broker: IB, NinjaTrader Brokerage
Trading: ES,NQ,6E
Posts: 71 since Feb 2010
Thanks Given: 15
Thanks Received: 25

you have to declare the flag as a class variable

private bool flagBS9 = false;

In method Initialize() initialize variable flagBS9 = false;

In OnBarUpdate you increase your couter and set the flag

if (BS==9)
{
BS = 0;
flagBS9 = true;
}

if( flagBS9 == true )
{
if Close[0] <= Low[2]
{
BQ++
}
}

Reply With Quote
  #8 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7

i did that. lemme clean up code and try again. thx again!

Reply With Quote
Thanked by:
  #9 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7

decs0057, here is my code. i think it is similar to yours.

If you look at the charts I've attached, I'm trying to get what is displayed in [COLOR=#0066cc]NIA 02-10 11_27_2009 (3 Min)a.jpg[/COLOR] but I keep getting [COLOR=#0066cc]NIA 02-10 11_27_2009 (3 Min).jpg[/COLOR].

Oh yeah, 13 is the final count.

Attached Thumbnails
Click image for larger version

Name:	NIA 02-10  11_27_2009 (3 Min).jpg
Views:	554
Size:	90.5 KB
ID:	8976   Click image for larger version

Name:	NIA 02-10  11_27_2009 (3 Min)a.jpg
Views:	521
Size:	97.5 KB
ID:	8977  
Attached Files
Elite Membership required to download: kys5.zip
Reply With Quote
  #10 (permalink)
 decs0057 
Munich, Germany
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Broker: IB, NinjaTrader Brokerage
Trading: ES,NQ,6E
Posts: 71 since Feb 2010
Thanks Given: 15
Thanks Received: 25


method ProcessBuySequential is only called in ProcessBuySequential.
You have to call it in OnBarUpdate

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar < SetupBars*2) return;
this.HouseKeeping();
if (priceflipdown == true)
{
TDBuySetup = true;
if( flagBS9 == false )
this.ProcessBuySetup();
else
this.ProcessBuySequential();
}
if (priceflipup == true)
{
TDSellSetup = true;
}
}

Reply With Quote




Last Updated on December 8, 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