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

CrossAbove

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

    CrossAbove

    Does anyone know what is wrong with the code below? I am not sure if the CrossAbove code is used correctly or not. This code is basically locking up NT and when it finally does load there are no orders. HighestHigh (double) and CountBars (int) are variables defined in the variable declaration section. Also, how do you say in NT "close since CrossAbove > HighestHigh." Meaning the close has to stay above HighestHigh for the order to continue working.

    Code:
    protected override void OnBarUpdate()
    {
    if((ToTime(Time[0]) >= 070000) && (ToTime(Time[0]) <= 150000) && CrossAbove(Close, HighestHigh, CountBars)) && Close[0] > HighestHigh);
                        {
                            entryOrder = EnterLongStop(1, Math.Max(Close[0]+.0005,GetCurrentAsk(0)),"LongEntry");
                        }
    }
    Thanks!

    GT

    #2
    GT,

    please try this - there was a brace too much in the code you posted.

    Code:
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] ((ToTime(Time[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]]) >= [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]070000[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]) && (ToTime(Time[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]]) <= [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]150000[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]) && CrossAbove(Close, HighestHigh, CountBars) && Close[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]] > HighestHigh);
    {
    IOrder entryOrder = EnterLongStop([/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], Math.Max(Close[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]]+[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080].0005[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2],GetCurrentAsk([/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2])),[/SIZE][/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"LongEntry"[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Verdana]);[/FONT]
    }
    [/SIZE][/FONT][/SIZE][/FONT]


    You could simply set the order liveUntilCancelled, and then cancel it when the Close falls below the HighestHigh value.

    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Waxavi, Today, 02:10 AM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by Kaledus, Today, 01:29 PM
    5 responses
    13 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Waxavi, Today, 02:00 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by alifarahani, Today, 09:40 AM
    5 responses
    23 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by gentlebenthebear, Today, 01:30 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X