View Full Version : code script question
06-02-2007, 06:57 AM
Would anyone know how these 2 short phrases would be coded in C# script language:
If strategy is not long already.
If strategy is not short already.
06-02-2007, 08:23 AM
if (Position.MarketPosition != MarketPosition.Long)
// Do something
if (Position.MarketPosition != MarketPosition.Short)
// Do something
See here for further reference - http://www.ninjatrader-support.com/HelpGuideV6/MarketPosition.html
06-02-2007, 08:39 AM
So this code is saying that if the high of present bar is greater than the high of 1 bar ago and if I am "not" in a long position already, than enter long.
// STOP AND REVERSE STRATEGY
protected override void OnBarUpdate()
if (High > High && Position.MarketPosition != MarketPosition.Long)
else if (Low < Low && Position.MarketPosition != MarketPosition.Short)
06-02-2007, 09:03 AM
Yes this is correct.
06-02-2007, 09:08 AM
Thank you SO MUCH!!
How does one go about get a indicator file written in c to become a indicator in Ninja?
06-19-2007, 12:48 AM
You would need to recode yourself of contact one of the NinjaScript consultants: http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm
The indicator has already been code for Ninja, just need to know how to get it into the program.
06-19-2007, 07:23 AM
If you have a .cs file...
Save the file in My Documents\NinjaTrader 6\bin\Custom\Indicator
In the Control Center select Tools > Edit NinjaScript > Indicator and select this indicator
The NinjaScript Editor will open, press "F5" to compile it.
You now can use the indicator on a chart.