PDA

View Full Version : code script question


abikambic
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.



Thanx MUCH..........Steve

NinjaTrader_Ray
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

abikambic
06-02-2007, 08:39 AM
NT RAY,

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[0] > High[1] && Position.MarketPosition != MarketPosition.Long)


EnterLong();

else if (Low[0] < Low[1] && Position.MarketPosition != MarketPosition.Short)


EnterShort();

NinjaTrader_Ray
06-02-2007, 09:03 AM
Yes this is correct.

abikambic
06-02-2007, 09:08 AM
NT RAY,
Thank you SO MUCH!!
Steve

ljoe
06-18-2007, 10:52 PM
How does one go about get a indicator file written in c to become a indicator in Ninja?

NinjaTrader_Dierk
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

ljoe
06-19-2007, 07:10 AM
The indicator has already been code for Ninja, just need to know how to get it into the program.

NinjaTrader_Ray
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.