Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

CoBC True/False

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    CoBC True/False

    Hi Ninjas

    I'm still trying to work out the best way to implement my automated strategy.

    Yes, I have a strategy that enters ATMs automatically (based on SampleAtmStrategy), but one of the drawbacks I hadn't considered, is that there's no way of adjusting variables in an ATM as one can in a strategy. This means I'll have to produce a large number of ATMs for every possible time period or Renko length. This can be confusing and lead to mistakes.

    Moreover, I won't be using trailing stops.

    I'm considering reverting to a traditional strategy using SetTrailStop, SetProfitTarget, etc.

    I wish to incorporate into this strategy, though, an essential element of ATMs: the break even aspect. I've worked out some code that I'm hoping will do the trick:

    Code:
    int a = 0;
    int i = 1;
    
    while (i <= BarsSinceEntry())	
    			{
    				if( Position.GetProfitLoss(Close[i], PerformanceUnit.Points) < ProfitTrigger1 )
    					
    				{
    					i++;
    					
    					continue;
    				}
    				
    					else
    					
    					a = 1;
    					
    					break;
    				
    			}
    
    				if (
    				Position.MarketPosition == MarketPosition.Long
    				&& Position.GetProfitLoss(Close[0], PerformanceUnit.Points) <= BreakEvenPlus1
    				&& a == 1
    				)
    
    				{
    				ExitLong("Long1"); // LongQuantity1, 
               				}
    The problem I have is this: I wish the part of the strategy that enters tthe trades to operate with CoBC = True. The problem is, the break even part should really work on a CoBC = False basis.

    Two questions:

    1) Does the above code look like it might successfully operate as a break even?

    2) Although I think I'm asking for the impossible, is there any wonderfully erudite way of making different parts of a strategy operate with CoBC = True and others CoBC = False? Or at least fooling the strategy into making part of it act differently?

    Any advice as regards these points will be greatly appreciated.

    #2
    arbuthnot,

    Thank you for your post.

    The code looks good, though without testing we couldn't say for sure. Test that out and see what kind of results you get.

    Second, you can use FirstTickOfBar to filter out when a new bar is made and only then. This is similar to how CalculateOnBarClose = true works.
    http://www.ninjatrader.com/support/h...ttickofbar.htm

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks very much, Cal.

      That seems to be exactly what I was looking for.

      I'll post back here if I encounter any new problems.

      Cheers,

      Ed

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by nicthe, Today, 02:58 PM
      1 response
      7 views
      0 likes
      Last Post nicthe
      by nicthe
       
      Started by percy3687, Yesterday, 12:28 AM
      3 responses
      30 views
      0 likes
      Last Post percy3687  
      Started by SilverSurfer1, Today, 01:33 PM
      0 responses
      9 views
      0 likes
      Last Post SilverSurfer1  
      Started by ETFVoyageur, Today, 10:27 AM
      2 responses
      18 views
      0 likes
      Last Post ETFVoyageur  
      Started by CommonWhale, Today, 01:12 PM
      0 responses
      10 views
      0 likes
      Last Post CommonWhale  
      Working...
      X