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

how to write script for this condition

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

    how to write script for this condition

    hello sir

    how to write a script for this condition :
    for mnq instrument

    Hma200 -Hma70 < 3 point (12 ticks ) .

    thanks for any help

    #2
    Hello traderMNQ, thanks for your question.

    Do you want to do this in the Strategy Builder or with an Indicator in the NinjaScript editor?

    I look forward to hearing from you.

    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hello traderMNQ, thanks for your question.

      Do you want to do this in the Strategy Builder or with an Indicator in the NinjaScript editor?

      I look forward to hearing from you.
      Iwant to do with an Indicator in the NinjaScript editor

      Comment


        #4
        Hello

        I made a quick example to demonstrate:

        Code:
        public class TestHMAStrategy : Strategy
            {
                HMA _HMA0;
                HMA _HMA1;
                protected override void OnStateChange()
                {
                    if (State == State.SetDefaults)
                    {
                        //Setup
                    }
                    else if (State == State.Configure)
                    {
                        _HMA0 = HMA(200);
                        _HMA1 = HMA(70);
                    }
                }
        
                protected override void OnBarUpdate()
                {
                    if(CurrentBar < 200) return;
        
                    if(_HMA0[0] - _HMA1[0] < 3)
                    {
                        Print("Condition True");
                    }
                }
        The idea here is the same for all indicators. We declare two indicator objects at the class level (in this case, two HMA objects titled _HMA0 and_HMA1) and initialize them in State.SetDefaults. The indicator values are then accessed in OnBarUpdate.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hello

          I made a quick example to demonstrate:

          Code:
          public class TestHMAStrategy : Strategy
          {
          HMA _HMA0;
          HMA _HMA1;
          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          //Setup
          }
          else if (State == State.Configure)
          {
          _HMA0 = HMA(200);
          _HMA1 = HMA(70);
          }
          }
          
          protected override void OnBarUpdate()
          {
          if(CurrentBar < 200) return;
          
          if(_HMA0[0] - _HMA1[0] < 3)
          {
          Print("Condition True");
          }
          }
          The idea here is the same for all indicators. We declare two indicator objects at the class level (in this case, two HMA objects titled _HMA0 and_HMA1) and initialize them in State.SetDefaults. The indicator values are then accessed in OnBarUpdate.

          Please let me know if I can assist any further.
          Thank you very much ...i will try it ..

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ZenCortexCLICK, Today, 04:58 AM
          0 responses
          5 views
          0 likes
          Last Post ZenCortexCLICK  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          172 responses
          2,281 views
          0 likes
          Last Post sidlercom80  
          Started by Irukandji, Yesterday, 02:53 AM
          2 responses
          18 views
          0 likes
          Last Post Irukandji  
          Started by adeelshahzad, Today, 03:54 AM
          0 responses
          8 views
          0 likes
          Last Post adeelshahzad  
          Started by Barry Milan, Yesterday, 10:35 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X