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

Strategy Order Error

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

    Strategy Order Error

    Hi there,

    I recently added a piece of code in my strategy, and started getting this error when testing on the demo account.

    Here is code

    Code:
    StopLossTicks						    = 40;
    ProfitTargetTicks					    = 160;
    BreakevenAfterTicks 				    = 50;
    Code:
    // Resets the stop loss to the original value when all positions are closed
    	if (Position.MarketPosition == MarketPosition.Flat)
    	{
    	SetStopLoss(CalculationMode.Ticks, StopLossTicks);
    	}
    			
    // If a long position is open, allow for stop loss modification to breakeven
    	if (Position.MarketPosition == MarketPosition.Long)
    			
    	{			
            // Once the price is greater than entry price+50 ticks, set stop loss to breakeven
    	if (Close[0] > Position.AveragePrice + BreakevenAfterTicks * TickSize)
    	{
    	SetStopLoss(CalculationMode.Price, Position.AveragePrice);
    	}
    	}
    			
    			
    // If a short position is open, allow for stop loss modification to breakeven
    	if (Position.MarketPosition == MarketPosition.Short)
    			
    	{			
    	// Once the price is greater than entry price-50 ticks, set stop loss to breakeven
    	if (Close[0] < Position.AveragePrice - BreakevenAfterTicks * TickSize)
    	{
    		SetStopLoss(CalculationMode.Price, Position.AveragePrice);
    	}
    	}
    I've attached the error messages.

    Could you please let me know where i'm going wrong?

    Thanks
    M
    Attached Files

    #2
    Hello mntemel,

    Thank you for your note.

    Without the full code we're unable to test on our end.

    If you'd like to upload the full code I can take a look and see if anything jumps out. Or if you'd prefer to email a copy, send to platformsupport[at]ninjatrader[dot]com with Attn: Alan P in the Subject line. Also within the email please include a link to this thread, and the files.

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hi Alan, I sent it as an email.

      Thanks
      M

      Comment


        #4
        @NinjaTrader_AlanP

        Have you had any chance to look into it?

        Thanks
        M

        Comment


          #5
          Hello mntemel,

          I was out of the office and see that Jesse sent you an email on 2-12 covering the issue.

          Would you please check your email and reply to that thread, or if you did not receive it please send an email to platformsupport[at]ninjatrader[dot]com with Attn: Alan P in the Subject line. Also within the email please include a link to this thread.

          Thank you.
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            @NinjaTrader_AlanP

            Hi Alan,

            I could't find the email, just sent an email to platformsupport[at]ninjatrader[dot]com again.

            Thanks
            M

            Comment


              #7
              Hello mntemel,

              I have sent you an email in outlook.

              Please let us know if you do not receive it, or if you do, please reply to that email so I know you got it.

              Please let us know if you need further assistance.
              Alan P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by adeelshahzad, Today, 03:54 AM
              5 responses
              32 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by stafe, 04-15-2024, 08:34 PM
              7 responses
              32 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by merzo, 06-25-2023, 02:19 AM
              10 responses
              823 views
              1 like
              Last Post NinjaTrader_ChristopherJ  
              Started by frankthearm, Today, 09:08 AM
              5 responses
              21 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              43 views
              0 likes
              Last Post jeronymite  
              Working...
              X