![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Aug 2008
Posts: 238
Thanks: 20
Thanked 5 times in 5 posts
|
Hi,
I am new to Ninja Trader and would like to modify the standard pivot indicator to calculate as follows; Pivot Point = (High + Low + Close) / 3 #1 high pivot (R1) = Pivot point + (Pivot Point - Low) #1 low pivot (S1) = Pivot Point - (High - Pivot Point) #2 high pivot (R2) = Pivot Point + 20 (Pivot Point - Low) #2 low pivot (S2) = Pivot Point - 20 (High - Pivot Point) #3 high pivot (R3) = High + 20 (Pivot Point - Low) #3 low pivot (S3) = Low - 20 (High - Pivot Point) Is it possible to cut and paste the standard pivot code provided by NT and change the lines of code as required...the reason I ask this is I tried to, to no avail. I would be using these on 10 minute charts based on the high, low and close of the previous session. Any advice on the matter would be great.
Last edited by suprsnipes; 03-03-2009 at 04:01 AM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,562
Thanks: 261
Thanked 1,015 times in 996 posts
|
Hi suprsnipes, welcome to the NinjaTrader support forums! Sure you can open the 'Pivots' code in your NinjaScript editor and modify the programming for PP, S1, S2, S3, R1, R2, and R3 as needed in your custom formula.
For a good start, please check those coding tutorials - http://www.ninjatrader-support.com/H...verview18.html You can also review those pivot scripts from our sharing - http://www.ninjatrader-support2.com/...h=pivot&desc=1 For professional custom coding, you can contact those NinjaScript consultants - http://www.ninjatrader.com/webnew/pa...injaScript.htm
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Aug 2008
Posts: 238
Thanks: 20
Thanked 5 times in 5 posts
|
I have marked the lines of code that I would like to edit, if they are the correct lines in the first place, can't see anything else in the code that is similar so I'm thinking yes??
Plus I copied the standard NT 'Pivots' indicator code then changed the lines but then received an error message from NT as follows; Firstly when I go to save this as another name it says; 'Your indicator was saved as a new file. Please replace any instances of the old file name with the new file name within your NinjaScript code'. I'm not sure how to identify this and if I even have to?? I then go to the indicators window to add and my new custom indicator is not showing. I thought that I may have to export the code and import it like you would any indicator you got from someone else but received this message, 'You have custom NinjaScript files on your PC that have programming errors. These errors must be resolved before you can export an NinjaScript Archive File. Thanks in advance, if (Bars == null) return; if (!Data.BarsType.GetInstance(Bars.Period.Id).IsIntr aday && Bars.Period.Id != PeriodType.Day) return; if (Bars.Period.Id == PeriodType.Day && pivotRangeType == PivotRange.Daily) return; if (Bars.Period.Id == PeriodType.Day && Bars.Period.Value > 1) return; // pivots only work for // - intraday // - 1 day chart with PivotRange Weekly or Monthly if (!isDailyDataLoaded && !isInitializing) { isInitializing = true; if (priorDayHLC == HLCCalculationMode.DailyBars && Data.BarsType.GetInstance(Bars.Period.Id).IsIntrad ay) { dailyBars = Data.Bars.GetBars(Bars.Instrument, new Period(PeriodType.Day, 1), Bars.From, Bars.To, (Session) Bars.Session.Clone(), Data.Bars.SplitAdjust, Data.Bars.DividendAdjust); existsHistDailyData = (dailyBars.Count <= 1) ? false : true; } else existsHistDailyData = false; isInitializing = false; isDailyDataLoaded = true; } IBar dailyBar; if (existsHistDailyData) { DateTime intradayBarTime = Time[0].AddSeconds(-1).Date; dailyBar = dailyBars.Get(dailyBars.GetBar(intradayBarTime)); if (dailyBar.Time.Date > intradayBarTime.Date) { for (DateTime i = intradayBarTime; i >= dailyBars.Get(0).Time; i = i.AddDays(-1)) { dailyBar = dailyBars.Get(dailyBars.GetBar(i)); if (dailyBar.Time.Date == i.Date) break; } } } else dailyBar = null; double high = existsHistDailyData ? dailyBar.High : High[0]; double low = existsHistDailyData ? dailyBar.Low : Low[0]; double close = existsHistDailyData ? dailyBar.Close : Close[0]; if ((currentDate != Cbi.Globals.MinDate && pivotRangeType == PivotRange.Daily && Time[0].AddSeconds(-1).Date != currentDate) || (currentWeek != Cbi.Globals.MinDate && pivotRangeType == PivotRange.Weekly && RoundUpTimeToPeriodTime(Time[0].AddSeconds(-1).Date, PivotRange.Weekly) != currentWeek) || (currentMonth != Cbi.Globals.MinDate && pivotRangeType == PivotRange.Monthly && RoundUpTimeToPeriodTime(Time[0].AddSeconds(-1).Date, PivotRange.Monthly) != currentMonth)) { pp = (currentHigh + currentLow + currentClose) / 3; s1 = 2 * pp - currentHigh; r1 = 2 * pp - currentLow; s2 = pp - (currentHigh - currentLow); r2 = pp + (currentHigh - currentLow); s3 = pp - 2 * (currentHigh - currentLow); r3 = pp + 2 * (currentHigh - currentLow); currentClose = (priorDayHLC == HLCCalculationMode.UserDefinedValues) ? userDefinedClose : close; currentHigh = (priorDayHLC == HLCCalculationMode.UserDefinedValues) ? userDefinedHigh : high; currentLow = (priorDayHLC == HLCCalculationMode.UserDefinedValues) ? userDefinedLow : low; } else { currentClose = (priorDayHLC == HLCCalculationMode.UserDefinedValues) ? userDefinedClose : close; currentHigh = (priorDayHLC == HLCCalculationMode.UserDefinedValues) ? userDefinedHigh : Math.Max(currentHigh, high); currentLow = (priorDayHLC == HLCCalculationMode.UserDefinedValues) ? userDefinedLow : Math.Min(currentLow, low); } if (pivotRangeType == PivotRange.Daily) currentDate = Time[0].AddSeconds(-1).Date; if (pivotRangeType == PivotRange.Weekly) currentWeek = RoundUpTimeToPeriodTime(Time[0].AddSeconds(-1).Date, PivotRange.Weekly); if (pivotRangeType == PivotRange.Monthly) currentMonth = RoundUpTimeToPeriodTime(Time[0].AddSeconds(-1).Date, PivotRange.Monthly); if ((pivotRangeType == PivotRange.Daily && currentDate != Cbi.Globals.MinDate) || (pivotRangeType == PivotRange.Weekly && currentWeek != Cbi.Globals.MinDate) || (pivotRangeType == PivotRange.Monthly && currentMonth != Cbi.Globals.MinDate)) { PP.Set(pp); R1.Set(r1); S1.Set(s1); R2.Set(r2); S2.Set(s2); R3.Set(r3); S3.Set(s3); |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,562
Thanks: 261
Thanked 1,015 times in 996 posts
|
Yes, you need to edit the bold lines for your custom formulas to take effect. If it does not show up in the indicators list on the charts, it means there were compilation errors of your changes - just open the new indicator up, hit F5 and click on each error on the bottom. Then debug those step by step, if you need further tips to debug your code please check this link - http://www.ninjatrader-support2.com/...ead.php?t=4678
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Advice on Custom Indicator | Trader_Rob | General Programming | 5 | 02-17-2009 07:06 AM |
| Pivot code not displaying | Mindset | Indicator Development | 0 | 01-11-2009 05:57 AM |
| B-LINE Indicator(modify) | jake28787 | Indicator Development | 3 | 01-06-2009 10:23 AM |
| code writer needed | upwardtrade | ATM Strategies (Discretionary Trading) | 1 | 05-05-2008 04:41 PM |
| Dying to Know Why Hidden Auto-Generated Code Needed | geoMEAN | General Programming | 6 | 04-21-2008 12:06 AM |