Believe it or not I was a comp sci major a long time ago. Giving NinjaTrader a legitimate effort but for the life of me I can't get anything to run. I'm not even going to get started importing data until I can get something to run on a random simulation.
Trying to see how my strategy runs in the simulation. Is this even possible? I have read through the help booklet but my strategy still won't buy anything when the simulation is running.
I'd really like to use this program as I have a bunch of strategies I have backtested elsewhere.
Here is the code. Just looking to buy 1 e-mini ES future if it trends up and then set limits on selling it. Can't find anything online that will help me with this. Pretty damn simple for starters. I used the strategy wizard and then edited the code. It compiles fine. HELP!!!
public class PeteScalper : Strategy
{
#region Variables
// Wizard generated variables
private double initial_P = 0.00; // Default setting for Initial_P
private double longP = 1; // Default setting for LongP
private double longWin = 1; // Default setting for LongWin
private double longLose = 1; // Default setting for LongLose
// User defined variables (add any user defined variables below)
#endregion
protected override void Initialize()
{
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
Initial_P = Open[0];
LongP = Initial_P +0.50;
LongWin = LongP +0.50;
LongLose = LongP -1.00;
if (Close[0] >= LongP)
{
EnterLongLimit(1, LongP, "");
}
if (Close[0] >= LongWin)
{
ExitLongLimit(LongWin, "", "");
}
if (Close[0] <= LongLose)
{
ExitLongLimit(LongLose, "", "");
}
}
Comment