Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with trading strategy

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

    Problem with trading strategy

    Gentlemen,

    I'm having a problem with the following strategy:

    protected override void Initialize()
    {
    Add(ImperialDragon(NinjaTrader.Data.PivotRange.Dai ly, NinjaTrader.Data.HLCCalculationMode.UserDefinedVal ues, 20));

    CalculateOnBarClose = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    // Condition set 1
    if (CrossAbove(GetCurrentAsk(), ImperialDragon(PivotRange.Daily, HLCCalculationMode.UserDefinedValues, 20).PP, 1))

    EnterLong(2, "Going Long");
    ExitLongLimit(ImperialDragon(PivotRange.Daily, HLCCalculationMode.UserDefinedValues, 20).TS11[0], "", "");


    // Condition set 2
    if (CrossAbove(GetCurrentAsk(), ImperialDragon(PivotRange.Daily, HLCCalculationMode.UserDefinedValues, 20).TS11, 1))

    EnterLong(2, "GOING LONG");
    ExitLongLimit(ImperialDragon(PivotRange.Daily, HLCCalculationMode.UserDefinedValues, 20).M6[0], "EXIT W/PROFIT", "");

    Every time I initiate this strategy, I receive the following error message:

    "Error on Calling 'OnBarUpdate' method for strategy 'DragonTrader': Limit price must not be 0.

    Does anyone know how to fix this problem? All my variables are defined, and I've rechecked the calculations and everything appears to be correct.

    #2
    Hello dscurry,

    Thank you for your post.

    One issue with your code is that your statements to execute are not enclosed in curly brackets {}

    You can only ommit curly brackets if all your statements can be processed on one line.

    One of your conditions corrected below:
    Code:
     
    if (CrossAbove(GetCurrentAsk(), ImperialDragon(PivotRange.Daily, HLCCalculationMode.UserDefinedValues, 20).PP, 1))
    [COLOR=red][B]{[/B][/COLOR]
    EnterLong(2, "Going Long");
    ExitLongLimit(ImperialDragon(PivotRange.Daily, HLCCalculationMode.UserDefinedValues, 20).TS11[0], "", "");
    [B][COLOR=red]}[/COLOR][/B]
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I fixed the bracket problem, but I'm getting the same error message.

      Comment


        #4
        Hi dscurry,

        You will need to ensure you value for the ExitLongLimit() are a valid, non zero value.

        I suggest using Print() statements within your code to monitor the ImperialDragon value.
        More info at - http://www.ninjatrader-support.com/H...ide.html?Print
        Last edited by NinjaTrader_Tim; 05-17-2010, 07:11 AM.
        TimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        672 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        379 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        111 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        577 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        582 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X