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

ExitLongStop acting strangely in backtesting

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

    ExitLongStop acting strangely in backtesting

    Hi,

    I am not sure why this happened once in a backtest. Enclosed is a screenshot. In almost all backtested trades, the ExitLongStop acted the way it was supposed to and got out at 2 points below the entryprice. However, there is one instance in the backtest where it exits at 11.25 points below the entryprice making my partner very uncomfortable in going live with this system. Below is some example code where I utilize this exit with the entry logic stripped (I just say if (x)). I am not sure why this happened once in the backtest and assume there is something I did incorrectly with the ExitLongStop and it is suttle as I looked over the help examples and the function signature and can't seem to find what I did wrong. Any help is appreciated. Here is my sample code:


    Thank you,
    David




    DStop=2.00;


    if(x)
    {
    EnterLong("By");
    }

    if(Position.MarketPosition == MarketPosition.Long)
    {

    double DStop = Position.AvgPrice-stop;


    ExitLongStop(DStop,"By");

    }
    Attached Files

    #2
    Hello Cowpux,

    Thank you for your post.

    You would want to use TickSize and multiply this for the appropriate point size. For the ES there is 4 ticks to the point, so you could do the following:
    Code:
    double DStop = Position.AvgPrice - ((stop*4)*TickSize);
    For information on TickSize please visit the following link: http://www.ninjatrader.com/support/h...7/ticksize.htm

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Skifree, Today, 03:41 AM
    1 response
    2 views
    0 likes
    Last Post Skifree
    by Skifree
     
    Started by usazencort, Today, 01:16 AM
    0 responses
    1 view
    0 likes
    Last Post usazencort  
    Started by kaywai, 09-01-2023, 08:44 PM
    5 responses
    603 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by xiinteractive, 04-09-2024, 08:08 AM
    6 responses
    23 views
    0 likes
    Last Post xiinteractive  
    Started by Pattontje, Yesterday, 02:10 PM
    2 responses
    22 views
    0 likes
    Last Post Pattontje  
    Working...
    X