Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT crashes with this code without any reason.

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

  • pstrusi
    replied
    Maybe not the most elegant solution but finally I've solved this issue:

    simply, the dataseries variable cc, hh, and ll were substituted by these double variable a,b and c. So now I can perform the basic comparisons without any trouble a>b b>c a>c ...etc etc

    Obviously the problem is when I wanted to construct a dataseries variable within other.

    Leave a comment:


  • sledge
    replied
    NT Support needs in here...

    Leave a comment:


  • sledge
    replied
    Originally posted by pstrusi View Post
    No, it doesn't work because it's the same, three conditions..it must be up to 2 cond.

    Code:
    if (     cc[0]>hh[0] 
       && cc[0]>ll[0] 
       && hh[0]>ll[0] )
    Could be rewritten as:

    Code:
    if (      hh[0]>ll[0] 
       &&  cc[0]>hh[0] )
    Right?

    Leave a comment:


  • pstrusi
    replied
    No, it doesn't work because it's the same, three conditions..it must be up to 2 cond.

    Leave a comment:


  • sledge
    replied
    Originally posted by pstrusi View Post
    Another interesting note that I've founded with this issue:

    If I just set two conditions ( of this type xx[0]>yy[0] && xx[0]>zz[0] ) instead of three or more same type or condition simultaneously, then the optimization goes perfect....so, could it be a memory-variable problem that I could address with a right initial configuration?
    No idea

    This might work then:

    Code:
    if (cc[0]>hh[0])
    {
      if (cc[0]>ll[0])
      {
         if ( hh[0]>ll[0] ) 
         {	
             EnterLong(100000, "BUY");	
         }
       }
    }

    Leave a comment:


  • pstrusi
    replied
    Another interesting note that I've founded with this issue:

    If I just set two conditions ( of this type xx[0]>yy[0] && xx[0]>zz[0] ) instead of three or more same type or condition simultaneously, then the optimization goes perfect....so, could it be a memory-variable problem that I could address with a right initial configuration?

    Leave a comment:


  • pstrusi
    replied
    I don´t get any message, nor even in trace or log files...it totally crashes without messages, That´s why I can't solve it

    Leave a comment:


  • sledge
    replied
    Originally posted by pstrusi View Post
    Thanks Sledge,

    That's in forex. I try to optimize it in the strategy analizer (backtesting)

    I suspect it's a memory-variable issue not yet addressed by me.

    I wait for more responses

    It's always fun to post the screenshot of the error message. Draws more attention, since it is super big and usually has a lot of hidden calls in it. *assuming you are getting one.

    Leave a comment:


  • pstrusi
    replied
    Thanks Sledge,

    That's in forex. I try to optimize it in the strategy analizer (backtesting)

    I suspect it's a memory-variable issue not yet addressed by me.

    I wait for more responses

    Leave a comment:


  • sledge
    replied
    Hi, I had no problems running the code here in Market Replay. Are you trying to run this in Strategy Analyzer, or Live, or Sim?

    Market Replay did stop and cancel the strategy, because the 100,000 ES contracts is bigger than my Market Replay Account. 10 contracts worked fine. I'm not sure what you are buying 100,000 of, Penny stocks?

    I'd add more print statements like I've done with your code, to find the exact line.

    *edit-> Have you tried rebooting your machine?

    Here is some sample output:

    2218>3
    0.9995475>0.9995478
    0.9995475>0.9995475
    0.9995478>0.9995475
    Finished OBU()
    2219>3
    0.9996982>0.9996984
    0.9996982>0.9996982
    0.9996984>0.9996982
    Finished OBU()
    2220>3
    1.0003019>0.9996983
    1.0003019>0.9996981
    0.9996983>0.9996981
    Entered Long-1
    Finished OBU()
    **NT** Strategy 'crash/de8d3875af3346a2a5e5cc91459e22d7' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
    **NT** Disabling NinjaScript strategy 'crash/de8d3875af3346a2a5e5cc91459e22d7'
    Code:
     
     
     
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class crash : Strategy
    {
    #region Variables
    private double s = 1000; // Default setting for Stoploss
    private DataSeries cc; // Roc for close 
    private DataSeries hh; // Roc for high
    private DataSeries ll; // Roc for low
    #endregion
    protected override void Initialize()
    {
    SetProfitTarget("", CalculationMode.Ticks, s);
    SetStopLoss("", CalculationMode.Ticks, s, false);
    BarsRequired = 3;
    cc = new DataSeries(this);
    hh = new DataSeries(this);
    ll = new DataSeries(this);
    CalculateOnBarClose = true;
    }
    protected override void OnBarUpdate()
    { 
     
    Print ( CurrentBar +">"+ BarsRequired );
     
    if (CurrentBar > BarsRequired) 
    { 
    cc.Set(Math.Round((Close[0]/Close[1]), 7)); 
    hh.Set(Math.Round((High[0]/High[1]), 7));
    ll.Set(Math.Round((Low[0]/Low[1]), 7));
    Print ( cc[0] +">"+hh[0] );
    Print ( cc[0]+">"+ll[0] );
    Print ( hh[0]+">"+ll[0]);
     
     
    if (cc[0]>hh[0] && cc[0]>ll[0] && hh[0]>ll[0] ) 
    { 
    Print ( "Entered Long-1");
    EnterLong(100000, "BUY"); 
    }
    // The code continues with different combinations...
    ExitLong();
    }
     
    Print ( "Finished OBU()");
    } 
     
    #region Properties
    #endregion
    }
    }
    Originally posted by pstrusi View Post
    Hi ninjas,

    This issue is driving me crazy. Everytime I try to run this apparently simple code, NT crashes. I really need your help. This is the core of this simple testing code:

    An important note: the crashes just happens when I set the comparation:
    cc[0]>hh[0] && cc[0]>ll[0] && hh[0]>ll[0]

    and it goes just fine with this combinations:
    cc[0]>1 && cc[0]>1 && hh[0]>1

    WHY? and how can I solve this?

    I appreciate your help as always
    Last edited by sledge; 07-09-2013, 04:44 PM. Reason: added 1 more thought

    Leave a comment:


  • pstrusi
    started a topic NT crashes with this code without any reason.

    NT crashes with this code without any reason.

    Hi ninjas,

    This issue is driving me crazy. Everytime I try to run this apparently simple code, NT crashes. I really need your help. This is the core of this simple testing code:

    #region Variables
    private double s = 1000; // Default setting for Stoploss
    private DataSeries cc; // Roc for close
    private DataSeries hh; // Roc for high
    private DataSeries ll; // Roc for low
    #endregion

    protected override void Initialize()
    {

    SetProfitTarget("", CalculationMode.Ticks, S);
    SetStopLoss("", CalculationMode.Ticks, S, false);
    BarsRequired = 3;
    cc = new DataSeries(this);
    hh = new DataSeries(this);
    ll = new DataSeries(this);
    CalculateOnBarClose = true;

    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar > BarsRequired)
    {
    cc.Set(Math.Round((Close[0]/Close[1]), 7));
    hh.Set(Math.Round((High[0]/High[1]), 7));
    ll.Set(Math.Round((Low[0]/Low[1]), 7));


    if (cc[0]>hh[0] && cc[0]>ll[0] && hh[0]>ll[0] )
    {
    EnterLong(100000, "BUY");
    }
    // The code continues with different combinations...

    ExitLong();
    }
    }

    An important note: the crashes just happens when I set the comparation:
    cc[0]>hh[0] && cc[0]>ll[0] && hh[0]>ll[0]

    and it goes just fine with this combinations:
    cc[0]>1 && cc[0]>1 && hh[0]>1

    WHY? and how can I solve this?

    I appreciate your help as always

Latest Posts

Collapse

Topics Statistics Last Post
Started by voltation, 07-20-2020, 09:06 PM
10 responses
2,307 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by rwlink3z8, Yesterday, 06:17 PM
3 responses
11 views
0 likes
Last Post NinjaTrader_Gaby  
Started by kaywai, 05-20-2024, 07:09 AM
9 responses
41 views
0 likes
Last Post NinjaTrader_ChristopherJ  
Started by amichalska, Yesterday, 01:23 PM
5 responses
29 views
0 likes
Last Post NinjaTrader_Gaby  
Started by llanqui, Today, 06:14 AM
6 responses
16 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X