NexusFi: Find Your Edge


Home Menu

 





Code Snippets needed!


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one zeller4 with 5 posts (9 thanks)
    2. looks_two jackyd with 2 posts (4 thanks)
    3. looks_3 slacker with 2 posts (4 thanks)
    4. looks_4 Saroj with 1 posts (0 thanks)
      Best Posters
    1. looks_one slacker with 2 thanks per post
    2. looks_two jackyd with 2 thanks per post
    3. looks_3 zeller4 with 1.8 thanks per post
    4. looks_4 Trader.Jon with 1 thanks per post
    1. trending_up 6,886 views
    2. thumb_up 18 thanks given
    3. group 6 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Code Snippets needed!

  #11 (permalink)
 slacker 
Durham, NC
 
Experience: Beginner
Platform: NinjaTrader
Trading: No Idea
Posts: 7 since Jul 2010
Thanks Given: 6
Thanks Received: 8

Hey, I think this is a great idea. I have some code lying around of things I've tried out that may or may not be useful to others so I'll try to add it here.

In Variables Section:
 
Code
private double pivotR3;
private double pivotR2;
private double pivotR1;
private double pivotPP;
private double pivotS1;
private double pivotS2;
private double pivotS3;
private double rLevel;
private double sLevel;
private double profitTarget = 8; # In ticks
In OnBarUpdate Section:

 
Code
if (Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP.ContainsValue(0))
{
pivotR3 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).R3[0];
pivotR2 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).R2[0];
pivotR1 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).R1[0];
pivotPP = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];
pivotS1 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).S1[0];
pivotS2 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).S2[0];
pivotS3 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).S3[0];
}

// Find Closest Resistance
if (GetCurrentAsk() < pivotS3)
	rLevel = pivotS3;
else if (GetCurrentAsk() < pivotS2)
	rLevel = pivotS2;
else if (GetCurrentAsk() < pivotS1)
	rLevel = pivotS1;
else if (GetCurrentAsk() < pivotPP)
	rLevel = pivotPP;
else if (GetCurrentAsk() < pivotR1)
	rLevel = pivotR1;
else if (GetCurrentAsk() < pivotR2)
	rLevel = pivotR2;
else rLevel = pivotR3;
//Print("Resistance Level: " + rLevel + "     Current Price: " + GetCurrentAsk());

// Find Closest Support
if (GetCurrentBid() > pivotR3)
	sLevel = pivotR3;
else if (GetCurrentBid() > pivotR2)
	sLevel = pivotR2;
else if (GetCurrentBid() > pivotR1)
	sLevel = pivotR1;
else if (GetCurrentBid() > pivotPP)
	sLevel = pivotPP;
else if (GetCurrentBid() > pivotS1)
	sLevel = pivotS1;
else if (GetCurrentBid() > pivotS2)
	sLevel = pivotS2;
else sLevel = pivotS3;
//Print ("Support Level: " + sLevel + "     Current Price: " + GetCurrentBid());
In the entry decision code:

 
Code
if (rLevel - GetCurrentAsk() >  (profitTarget * TickSize) &&
       EMA(ME) == pure awesomeness)
{ enter Long }

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
What broker to use for trading palladium futures
Commodities
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
REcommedations for programming help
Sierra Chart
Footprint for strategy Builder
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Funded Trader platforms
32 thanks
Just another trading journal: PA, Wyckoff & Trends
23 thanks
Trading with Intuition
17 thanks
Self sabotage reframed
14 thanks
GFIs1 1 DAX trade per day journal
9 thanks
  #12 (permalink)
 slacker 
Durham, NC
 
Experience: Beginner
Platform: NinjaTrader
Trading: No Idea
Posts: 7 since Jul 2010
Thanks Given: 6
Thanks Received: 8

Same as the Pivot Points but for Murrey Math:

 
Code
if (MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).P28.ContainsValue(0))
{
pivotPP28 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).PP28[0];
pivotPP18 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).PP18[0];
pivotP88 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).P88[0];
pivotP78 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).P78[0];
pivotP68 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).P68[0];
pivotP58 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).P58[0];
pivotP48 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).P48[0];
pivotP38 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).P38[0];
pivotP28 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).P28[0];
pivotP18 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).P18[0];
pivotN08 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).N08[0];
pivotN18 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).N18[0];
pivotN28 = MurreyMath(false, NinjaTrader.Data.PivotRange.Daily).N28[0];
}
// Find Closest Resistance
if (GetCurrentAsk() < pivotN28)
	rLevel = pivotN28;
else if (GetCurrentAsk() < pivotN18)
	rLevel = pivotN18;
else if (GetCurrentAsk() < pivotN08)
	rLevel = pivotN08;
else if (GetCurrentAsk() < pivotP18)
	rLevel = pivotP18;
else if (GetCurrentAsk() < pivotP28)
	rLevel = pivotP28;
else if (GetCurrentAsk() < pivotP38)
	rLevel = pivotP38;
else if (GetCurrentAsk() < pivotP48)
	rLevel = pivotP48;
else if (GetCurrentAsk() < pivotP58)
	rLevel = pivotP58;
else if (GetCurrentAsk() < pivotP68)
	rLevel = pivotP68;
else if (GetCurrentAsk() < pivotP78)
	rLevel = pivotP78;
else if (GetCurrentAsk() < pivotP88)
	rLevel = pivotP88;
else if (GetCurrentAsk() < pivotPP18)
	rLevel = pivotPP18;
else rLevel = pivotPP28;
//Print("Resistance Level: " + rLevel + "     Current Price: " + GetCurrentAsk());

// Find Closest Support
if (GetCurrentBid() > pivotPP28)
	sLevel = pivotPP28;
else if (GetCurrentBid() > pivotPP18)
	sLevel = pivotPP18;
else if (GetCurrentBid() > pivotP88)
	sLevel = pivotP88;
else if (GetCurrentBid() > pivotP78)
	sLevel = pivotP78;
else if (GetCurrentBid() > pivotP68)
	sLevel = pivotP68;
else if (GetCurrentBid() > pivotP58)
	sLevel = pivotP58;
else if (GetCurrentBid() > pivotP48)
	sLevel = pivotP48;
else if (GetCurrentBid() > pivotP38)
	sLevel = pivotP38;
else if (GetCurrentBid() > pivotP28)
	sLevel = pivotP28;
else if (GetCurrentBid() > pivotP18)
	sLevel = pivotP18;
else if (GetCurrentBid() > pivotN08)
	sLevel = pivotN08;
else if (GetCurrentBid() > pivotN18)
	sLevel = pivotN18;
else sLevel = pivotN28;
//Print ("Support Level: " + sLevel + "     Current Price: " + GetCurrentBid());

Reply With Quote
Thanked by:




Last Updated on June 20, 2011


© 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