PDA

View Full Version : LastPrice as variable in script of a Custom Indicator


tonyh
03-06-2010, 10:16 AM
Hello:

What is the variable name NT uses for LastPrice? As it can be selected from the window (e.g., LastPrice > 0), I assume it is available to use in a custom indicator script for Market Analyzer? I have no problem using Open[0]. High[0], etc. in the custom script.

Thanks.

Tony

NinjaTrader_Austin
03-06-2010, 05:21 PM
Tony, you can use Close[0] (just like High[0], Low[0], etc) to get the last price.

tonyh
03-07-2010, 06:19 AM
Hello Austin:

Based on the help section, I assumed that Close[0] was the actual end price of a time frame for any instrument. Isn't this the case?

Thanks.

eDanny
03-07-2010, 12:13 PM
Close[0] is always the last, current price, even before the bar closes. Dan

NinjaTrader_Austin
03-07-2010, 12:56 PM
tonyh, eDanny is absolutely correct. I can't put it any better so let me quote him: "Close[0] is always the last, current price, even before the bar closes."

tonyh
03-08-2010, 05:41 AM
Thanks Guys for the help. I assume that this is true even if CalculateOnBarClose is set to either true or false. Let me know if this assumption is incorrect.

NinjaTrader_Bertrand
03-08-2010, 06:09 AM
tonyh, no it would still depend on the scripts CalculateOnBarClose setting, if you want to get the last tick, just use it on false and access Close[0].

If you want to run and indicator on the close, but still need the last updated each tick, you could also 'grab' it from for example OnMarketData().

tonyh
03-08-2010, 10:27 AM
Thanks for clearing it up Bertrand.

BBzDan
03-11-2010, 10:20 AM
If in the Initialization region there is:

CalculateOnBarClose = true;

but then you have:

///<summary>
/// Called on each bar update event (incoming tick)
///</summary>

protected override void OnBarUpdate()

Close[0]

is this "Close[0]" the current (last tick) price or is it the bar close price?

Thx.

NinjaTrader_Bertrand
03-11-2010, 10:45 AM
It's not updated on each tick then, just responded to your other thread, you would need to use it in combo with setting COBC to false.

Then for 'end of bar' calcs you could still call them in if (FirstTickOfBar) context referencing one bar back further to achieve using both modes in the same strategy.