Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Calendar enum for Indicator Window?
Collapse
X
-
Dates do not change
I'm able to change the dates via the Indicator Window only for them to return to previous settings when "re-opening" Indicator Window.
I'm trying to draw a Rectangle using these Dates.
The Rectangle will not change even after selecting different dates via the Indicator Window
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Variables[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]// Wizard generated variables[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startMonth = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]4[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endMonth = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]4[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startDay = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endDay = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startHour = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]6[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for StartHour[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endHour = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]11[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for EndHour[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startMinute = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]30[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for StartMinute[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endMinute = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]15[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for EndMinute[/COLOR][/SIZE][/FONT]
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime inputdate;[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime inputdate1;[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//private DateTime enddateTime;[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000] Called on each bar update event (incoming tick)[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#008000]// Check to make sure the end time is not earlier than the start time[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2](inputdate1< inputdate)[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (EndHour < StartHour)[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]// If the stored date time date is not the same date as the bar time date, create a new DateTime object[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (inputdate.Date != Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Date)[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#008000]//1 startDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, StartHour, StartMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//2 startDateTime = new DateTime(Time[0].Year, Time[0].Month, StartDay, StartHour, StartMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]inputdate = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Year, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Month, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Day, StartHour, StartMinute, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); [/SIZE][/FONT] [SIZE=2][FONT=Courier New]inputdate1 =[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Year, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Month, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Day, EndHour, EndMinute, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//2 endDateTime = new DateTime(Time[0].Year, Time[0].Month, EndDay, EndHour, EndMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//1 endDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, EndHour, EndMinute, 0);[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startBarsAgo = GetBar(inputdate);[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endBarsAgo = GetBar(inputdate1); [/SIZE][/FONT]
Code:[SIZE=2][FONT=Courier New]DrawRectangle([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"rectangle2"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], startBarsAgo, R_Upper_edge, endBarsAgo ,R_Lower_edge, BorderColor2, FillColor2, Opacity2);[/SIZE][/FONT]
Code:[SIZE=2][FONT=Courier New][Description([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"Stop Date"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT] [SIZE=2][FONT=Courier New][Category([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"Enter Date"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime Inputdate1[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] inputdate1; }[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { inputdate1 = value; }[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [SIZE=2][FONT=Courier New][Description([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"Begin Date"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT] [SIZE=2][FONT=Courier New][Category([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"Enter Date"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime Inputdate [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]//was Startdate[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]{[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] inputdate; }[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { inputdate = value; }[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
Last edited by duck_CA; 04-10-2009, 10:53 PM.
Comment
-
delete the "private"?
do I delete the "private" portion when placing the value in the OnBarUpdate() Block?
Code:[FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate() { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (CurrentBar < [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]) [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (inputdate1 < inputdate) [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// If the stored date time date is not the same date as the bar time date, create a new DateTime object [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (inputdate.Date != Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Date) [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// private int startDay = 1; [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]{ inputdate = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Year, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Month, StartDay, StartHour, StartMinute, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); inputdate1 =[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Year, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Month, EndDay, EndHour, EndMinute, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); } [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]//bypassed 3 */ [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Calculate the number of bars ago for the start and end bars of the specified time range [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startBarsAgo = GetBar(inputdate); [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endBarsAgo = GetBar(inputdate1); [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startDay = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endDay = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startHour = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]6[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for StartHour [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endHour = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]11[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for EndHour [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startMinute = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]30[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for StartMinute [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endMinute = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]15[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for EndMinute [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DrawRectangle([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"rectangle2"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],startBarsAgo, R_Upper_edge, endBarsAgo ,R_Lower_edge, BorderColor2, FillColor2, Opacity2); [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// DrawText("text1",Text1, startBarsAgo ,R_Upper_edge,Color.Black,Textfont,StringAlignment.Far, Color.Red,Color.White,10); //* TickSize [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]//DrawText("text2",Text2, startBarsAgo ,R_Lower_edge,Color.Black,Textfont,StringAlignment.Far, Color.Red,Color.White,10); //* TickSize [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] } [/SIZE][/FONT]
Last edited by duck_CA; 04-12-2009, 05:10 PM.
Comment
-
Properties Block
Thanks Josh
Now in the Properties Block...Does that need to be modified? I currently have the following:
Code:[SIZE=2][FONT=Courier New][Description([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT] [SIZE=2][FONT=Courier New][Category([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"Enter Time"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT] [SIZE=2][FONT=Courier New][Gui.Design.DisplayName ([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"\t\t\t\tStart_Hour"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])] [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]//3 or 4t[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] StartHour[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startHour; }[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { startHour = Math.Max([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], value); }[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
Comment
-
Errors
I am prolly putting the int's in the wrong place of the OnBarUpdate()Block
Below is a Pic of the Errors from Indicator
Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{ [/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (CurrentBar < [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (inputdate1 < inputdate)[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]// If the stored date time date is not the same date as the bar time date, create a new DateTime object[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (inputdate.Date != Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Date)[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]inputdate = [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Year, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Month, StartDay, StartHour, StartMinute, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]inputdate1 =[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Year, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Month, EndDay, EndHour, EndMinute, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startDay = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endDay = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startHour = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]6[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for StartHour[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endHour = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]11[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for EndHour[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startMinute = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]30[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for StartMinute[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endMinute = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]15[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for EndMinute[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//1 startDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, StartHour, StartMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//2 startDateTime = new DateTime(Time[0].Year, Time[0].Month, StartDay, StartHour, StartMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//2 endDateTime = new DateTime(Time[0].Year, Time[0].Month, EndDay, EndHour, EndMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//1 endDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, EndHour, EndMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]}[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startBarsAgo = GetBar(inputdate);[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endBarsAgo = GetBar(inputdate1);[/SIZE][/FONT]
Last edited by duck_CA; 04-15-2009, 09:17 AM.
Comment
-
lol
ok...now i'm confused
Ben had mentioned to move the int's under the OnBarUpdate()block but maybe I'm missing the whole point
I originally had the int's in the Variable block which worked but was looking for a way to adjust both Date and Time like the pic below
Comment
-
Leave them in Variables. If you don't want parameters, go to the Properties region of the code and delete those parameters from there. When you delete them from properties you cannot access the capital version of the variable name anymore. Change them to the lower case ones.Josh P.NinjaTrader Customer Service
Comment
-
Getting Closer
Ok..
I put the private int's back in the Variables Block and change the 2 lines of code. The Indicator will not draw the Rectangle based on the Date and Time Settings in the Indicator window
Code:[SIZE=2][FONT=Courier New]inputdate = [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Year, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Month, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Day, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Hour, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Minute, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]inputdate1 =[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Year, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Month, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Day, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Hour, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Minute, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
Code:[SIZE=2][FONT=Courier New]DrawRectangle([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"rectangle2"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], startBarsAgo, R_Upper_edge, endBarsAgo ,R_Lower_edge, BorderColor2, FillColor2, Opacity2);[/SIZE][/FONT]
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{ [/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (CurrentBar < [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (inputdate1 < inputdate)[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]// If the stored date time date is not the same date as the bar time date, create a new DateTime object[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (inputdate.Date != Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Date)[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#008000]//inputdate = new DateTime(Time[0].Year, Time[0].Month, StartDay, StartHour, StartMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//inputdate1 =new DateTime(Time[0].Year, Time[0].Month, EndDay, EndHour, EndMinute, 0);[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New]inputdate = [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Year, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Month, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Day, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Hour, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Minute, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]inputdate1 =[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DateTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Year, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Month, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Day, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Hour, Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].Minute, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]} [/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#008000]//1 startDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, StartHour, StartMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//2 startDateTime = new DateTime(Time[0].Year, Time[0].Month, StartDay, StartHour, StartMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//2 endDateTime = new DateTime(Time[0].Year, Time[0].Month, EndDay, EndHour, EndMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//1 endDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, EndHour, EndMinute, 0);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] startBarsAgo = GetBar(inputdate);[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] endBarsAgo = GetBar(inputdate1);[/SIZE][/FONT]
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by rbeckmann05, Yesterday, 06:48 PM
|
1 response
12 views
0 likes
|
Last Post
by bltdavid
Today, 05:43 AM
|
||
Started by llanqui, Today, 03:53 AM
|
0 responses
6 views
0 likes
|
Last Post
by llanqui
Today, 03:53 AM
|
||
Started by burtoninlondon, Today, 12:38 AM
|
0 responses
10 views
0 likes
|
Last Post Today, 12:38 AM | ||
Started by AaronKoRn, Yesterday, 09:49 PM
|
0 responses
15 views
0 likes
|
Last Post
by AaronKoRn
Yesterday, 09:49 PM
|
||
Started by carnitron, Yesterday, 08:42 PM
|
0 responses
11 views
0 likes
|
Last Post
by carnitron
Yesterday, 08:42 PM
|
Comment