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

Please Help me add a EnterLong

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

    Please Help me add a EnterLong

    Code:
    if(((value1 >= value20 && value3 <= value21 && Close[0] > Close[1]) || (value6 < 7 && value1 > value20 && condition3_1 == false)) || sellOK_1 && buyOK && Close[0] > Close[1])
    {
    
    
    BuyStop[0] = buyStop;
    value4 = 0;
    Signal[0] = 1;
    
    if(Signal[0] > Signal[1]){
    barLastSignal = CurrentBar;
    
    
    if(useAlerts)
    Alert(CurrentBar.ToString(), Priority.High, "Long", "Alert2.wav", 1, Brushes.Blue, Brushes.Black);
    EnterLong();
    
    
    }
    }
    I get

    The name 'EnterLong' does not exist in the current context
    How can I enter long when it produces this alert?

    Thanks

    Lucy
    Last edited by lucyjoy; 09-06-2021, 07:08 AM.

    #2
    Hello Lucy,

    Thanks for your post.

    If you are getting an error "The name 'EnterLong' does not exist in the current context" it sound like you are trying to implement EnterLong in a script that is not a strategy.

    I would suggest testing creating a basic strategy, you can use the Strategy Builder and the Unlock button to unlock the code so you can test calling EnterLong in OnBarUpdate. Once you confirm you are able to call EnterLong in this fashion, you can compare to your existing strategy and test implementing your Alert logic within the strategy that you are able to place orders.

    Strategy Builder 301 - https://www.youtube.com/watch?v=VxU4FR6GWNA

    NinjaScript Editor 401 - https://www.youtube.com/watch?v=H7aDpWoWUQs

    The resources above are publicly available.

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Great, that has helped a lot so thank you.

      I now have somthing I need to mod to make this work in my indicator.

      I have some code which triggers an alert, this is the point I want strategy builder to BUY.

      Code:
      if(Signal[0] > Signal[1]){
      barLastSignal = CurrentBar;
      
      
      if(useAlerts)
      Alert("myAlert", Priority.High, "Long", NinjaTrader.Core.Globals.InstallDir+@"\sounds\Aler t1.wav", 10, Brushes.Blue, Brushes.White);
      I need to add a line of code under the alert which will create somthing I can call on in the strategy like a plot which I can give a numeric value to?


      Comment


        #4
        Hello lucyjoy,

        If the indicator exposes values as plots, you can easily read the plots in the Strategy Builder.

        Conditions examples (reading indicator values) - https://ninjatrader.com/support/help...lueComparisons

        If the indicator does not expose plots, you have 2 options:
        1. Re do the calculation in the strategy (this may be difficult from the Strategy Builder)
        2. Add plots to the indicator and expose the indicator values as plots.
        To expose the indicator values as plots, I suggest reviewing our AddPlot documentation to learn more about plotting, and then to follow our Indicator tutorials to be better able to build your own indicators and add plots to existing indicators.

        AddPlot - https://ninjatrader.com/support/help...8/?addplot.htm

        Indicator tutorials - https://ninjatrader.com/support/help...indicators.htm
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Barry Milan, Yesterday, 10:35 PM
        5 responses
        18 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        13 views
        0 likes
        Last Post DanielSanMartin  
        Started by DJ888, 04-16-2024, 06:09 PM
        4 responses
        13 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by terofs, Today, 04:18 PM
        0 responses
        12 views
        0 likes
        Last Post terofs
        by terofs
         
        Started by nandhumca, Today, 03:41 PM
        0 responses
        8 views
        0 likes
        Last Post nandhumca  
        Working...
        X