The strategy is very basic:
Follow the day to day trend by reading yesterday's Open compared to yesterday's Close, enter position (long or short) on CurrentBar Open and close out position on CurrentBar Close.
The types of charts I've tried are Kinetick's end of day bars and I've also imported custom minute data spanning multiple days, viewing both as candlestick charts. Neither chart seem to work correctly. I will say that the code does actually enter and exit in some way but I cannot figure out the reasoning for their placements on the chart.
I know that my conditional code works as the Print lines are printing out in my Output window exactly as they should. My print lines display the entry and exit on their respective Open and Close, I just cannot seem to get the position code to execute. I have the chart draw some arrows too under the conditions and that logic is perfectly what I want them to do! I really don't understand the fault.
Ninjatrader 8
OnStateChange{ ... Calculate = Calculate.OnBarClose; EntriesPerDirection = 1; TimeInForce = TimeInForce.Day; BarsRequiredToTrade = 1; ... }
OnBarUpdate{ // Must have at least 1 previous bar to start if (CurrentBar < 1) return; // Enter long position on up trend if (Close[1] >= Open[1]) { Draw.ArrowUp(this,CurrentBars[0].ToString(),false,0,(Low[0] + (-380 * TickSize)), Brushes.Lime); Print(ToDay(Time[0])+" - 093000 - Entering long position at Open: "+Open[0]); EnterLongLimit(1, Open[0]); Print(ToDay(Time[0])+" - 160000 - Leaving long position at Close: "+Close[0]); ExitLongLimit(Close[0]); } // Enter short position on down trend if (Close[1] < Open[1]) { Draw.ArrowDown(this,CurrentBars[0].ToString(),false,0,(High[0] + (380 * TickSize)), Brushes.Red); Print(ToDay(Time[0])+" - 093000 - Entering short position at Open: "+Open[0]); EnterShortLimit(1, Open[0]); Print(ToDay(Time[0])+" - 160000 - Leaving short position at Close: "+Close[0]); ExitShortLimit(Close[0]); } }
Comment