NexusFi: Find Your Edge


Home Menu

 





How can I achieve this?


Discussion in NinjaTrader

Updated
    1. trending_up 3,592 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 17 posts
    2. attach_file 8 attachments




 
Search this Thread

How can I achieve this?

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

Hi,
I have this code:-
if (((Low[0] < Low[2]) && (Low[0] < Low[3])) || ((Low[1] < Low[2]) && (Low[1] < Low[3])))
{
DrawArrowUp(
"BP" + CurrentBar, true, 0, (Low[0] -(2*TickSize)), Color.Green);
}

And there are occasions where the above won't hold true. What I want to do then is lock-in the lower of Low[2] and Low[3] and compare it against future Lows. And when a future Low is lower than Low[2] or Low[3], to give instructions for a DrawArrowUp.

Can someone please help with the code? Thanks!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Can I use Ehlers Periodogram as the lookback for another …
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Quantum physics & Trading dynamics
The Elite Circle
Is there a way to simulate CONTINUOUS CONTRACT?
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
16 thanks
GFIs1 1 DAX trade per day journal
13 thanks
The Trading Pit "Futures VIP" Account Journal
12 thanks
Trading with Intuition
10 thanks
Joes Trading Garage
10 thanks
  #3 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090


add 2 more variables

...
private double low2 = 0;
private double low3 = 0;
...


then you can save the value

if (low2 == 0)
low2 = Low(2);

if (low3 == 0)
low3 = low(3);


remember after drawing the arrow reset them to zero for the next comparison

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

hi cory, thanks for your help!

the double values work fine but for some reason the drawarrowup is being drawn where the condition would be false , i.e at the "old" Low[0].

Reply With Quote
  #5 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090

you need to post the coding of drawing the arrow.

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

Hi Cory,

Here is the whole code. The relevant portion is the BuyPerfectionTest and ImprefectBuyTest.

If you look at the attached chart, the test kicks in upon the completion of the 9th count, where the 8th or the 9th must be lower than the 6th and the 7th count. Failing that, a low below the low of the 6th or 7th will suffice. An arrow up at the low is used to indicate that that low has been found.

Right now, after including the code you kindly provided, the arrow is still printing at the 9 (white circle) when it should print at the low formed in the yellow circle.

Hope that helps explain it. Let me know if it is not clear. Thanks again Cory!

Attached Thumbnails
Click image for larger version

Name:	~MyBitmap.jpg
Views:	195
Size:	89.0 KB
ID:	8711  
Attached Files
Elite Membership required to download: kys1.zip
Reply With Quote
  #7 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090


kaywai View Post
Hi Cory,

Here is the whole code. The relevant portion is the BuyPerfectionTest and ImprefectBuyTest.

If you look at the attached chart, the test kicks in upon the completion of the 9th count, where the 8th or the 9th must be lower than the 6th and the 7th count. Failing that, a low below the low of the 6th or 7th will suffice. An arrow up at the low is used to indicate that that low has been found.

Right now, after including the code you kindly provided, the arrow is still printing at the 9 (white circle) when it should print at the low formed in the yellow circle.

Hope that helps explain it. Let me know if it is not clear. Thanks again Cory!

a)

&& = and
|| = or
you want 'or' so it should be ||

b) you want to keep testing the 'second chance' condition until it's true

Attached Thumbnails
Click image for larger version

Name:	second-chance.jpg
Views:	187
Size:	85.6 KB
ID:	8775  
Attached Files
Elite Membership required to download: tdsplusperf.cs
Reply With Quote
  #8 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7

Hi Cory,

My bad.

a) should read "a low below the the lower of the 6th and 7th count.
b) yes, i want to keep testing until the second is true and to draw an arrowup at the particular point
c) how and which part of the code do you reset the double values to zero for the next comparison?

Reply With Quote
  #9 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090


kaywai View Post
Hi Cory,

My bad.

a) should read "a low below the the lower of the 6th and 7th count.
b) yes, i want to keep testing until the second is true and to draw an arrowup at the particular point
c) how and which part of the code do you reset the double values to zero for the next comparison?

reset right after drawing the arrow
// second chance
if ( low3 > 0 || low2 > 0)
if ((Low[0] < low3) || (Low[0] < low2))
{
DrawArrowUp("IBP" + CurrentBar, true, 0, (Low[0] -(2*TickSize)), Color.Green);
low2 = 0; low3 = 0;// <======= reset
}

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


Hi Cory

This is what I've keyed in for 2nd chance:-
if (low2 == 0)
{
low2 = Low[
2];
}
if (low3 == 0)
{
low3 = Low[
3];
}
if (low3 > 0 || low2 > 0)
if ((Low[0] < low3) || (Low[0] < low2))
{
DrawArrowUp(
"IBP" + CurrentBar, true, 0, (Low[0] -(2*TickSize)), Color.Green);
low2 =
0; low3 = 0;
}

Green UpArrow still at the wrong point. (please see attached chart)

Attached Thumbnails
Click image for larger version

Name:	NIA 02-10  11_20_2009 (3 Min).jpg
Views:	177
Size:	47.5 KB
ID:	8777  
Reply With Quote




Last Updated on February 26, 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