NinjaTrader Support Forum Pull Back Logic Possible?

 Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

 02-15-2018, 03:03 PM #16 dorony Member   Join Date: Jan 2018 Posts: 62 Thanks: 11 Thanked 1 time in 1 post Ok I think I am getting close. So far I have the right pullback candle formation in tact as the prints are showing correctly. However, I am now having trouble with creating logic to only EnterLong() How do I create logic to make sure that from the holdValue candle to the candle entry have all had their lows greater than the middle bollinger band? if from the holdValue candle low to the candle that triggers the entry have all lows greater than the middle bollinger band and the High[0] is greater than the high of holdValue than it will trigger long. **As long as all the candle lows in between the holdvalue and entry candle are above the mid bb. I provided a few examples of how to phrase what I need. Here is my code now: protected override void OnBarUpdate() { if (CurrentBars[0] < 5) return; if ((High[4] < High[3]) && (Low[4] > midbbBull.Middle[4]) && (Low[3] > midbbBull.Middle[3]) && (Low[2] > midbbBull.Middle[2]) && (Low[1] > midbbBull.Middle[1]) && (High[3] > High[2]) && (High[3] > High[1]))// pseudo condition, replace with your condition { holdValue = High[3]; //store the close when the condition was true holdBarNumber = CurrentBar; // store the current bar number when the condition was true } if (holdValue != 0 && holdBarNumber != 0) // check if we have values for the variables { Print("Close price at last condition was " + holdValue); } if (High[0] > holdValue) { EnterLong(); } if (Low[0] < SMA5[0]) { ExitLong(); }
 02-16-2018, 09:35 AM #17 NinjaTrader_PatrickH NinjaTrader Customer Service     Join Date: Jul 2011 Location: Denver, CO Posts: 11,474 Thanks: 778 Thanked 1,973 times in 1,902 posts Hello dorony, Thank you for your response. Based on your description that code should do as you wish. Please let me know if you have any questions. Patrick H.NinjaTrader Customer ServiceUse Kinetick, NinjaTrader’s preferred market data service - Learn MoreFree online training events - View Schedule
 02-16-2018, 09:51 AM #18 dorony Member   Join Date: Jan 2018 Posts: 62 Thanks: 11 Thanked 1 time in 1 post Hey thanks! It's not because I need the condition to also say that all bars from holdValue until trigger must have candle lows greater than the middle bollinger band. Right now it only has the first four candles with that condition and thats just to confirm a pullback with holding its high value. After the pullback confirms I need it to continue to make sure all candle lows are greater than the middle bollinger band, otherwise holdvalue needs to reset
 02-16-2018, 11:54 AM #19 NinjaTrader_PatrickH NinjaTrader Customer Service     Join Date: Jul 2011 Location: Denver, CO Posts: 11,474 Thanks: 778 Thanked 1,973 times in 1,902 posts Hello dorony, Thank you for your response. You could add a condition that checks if (Low[0] < midbbBull.Middle[0]) and if so then restart the condition checking. Below is an example that sets the holValue to 0 and checks for that 0 value to act as a switch. Code: ```if (holdValue == 0 && (High[4] < High[3]) && (Low[4] > midbbBull.Middle[4]) && (Low[3] > midbbBull.Middle[3]) && (Low[2] > midbbBull.Middle[2]) && (Low[1] > midbbBull.Middle[1]) && (High[3] > High[2]) && (High[3] > High[1]))// pseudo condition, replace with your condition { holdValue = High[3]; //store the close when the condition was true } if (holdValue != 0 && Low[0] < midbbBull.Middle[0]) holdValue = 0;``` Patrick H.NinjaTrader Customer ServiceUse Kinetick, NinjaTrader’s preferred market data service - Learn MoreFree online training events - View Schedule

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News and Announcements     News and Announcements NinjaTrader 8     Platform Technical Support     Add-On Development     Indicator Development     Strategy Development NinjaTrader 7     Platform Technical Support     General Development     Indicator Development     Strategy Development NinjaScript File Sharing     NinjaScript File Sharing Discussion     Version 8 Add-Ons     Version 8 Indicators     Version 8 Strategies     Version 7 Indicators     Version 7 Strategies     Version 7 Miscellaneous NinjaScript Educational Resources     Reference Samples     Tips Suggestions and Feedback     Suggestions And Feedback Historical Beta Archive     Version 8 Beta

 Similar Threads Thread Thread Starter Forum Replies Last Post brucelevy Platform Technical Support 1 08-06-2017 02:24 PM cgeorgan General Development 2 04-13-2011 08:06 AM SharkCub Indicator Development 1 07-31-2010 10:06 AM BrianNC Platform Technical Support 1 10-07-2009 03:21 AM Mark_486 Platform Technical Support 1 06-05-2008 03:59 PM

All times are GMT -6. The time now is 05:54 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.