• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 bumbledbee, Today, 04:28 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Marco  
          Started by Tmaninc, Today, 02:13 AM
          3 responses
          12 views
          0 likes
          Last Post Tmaninc
          by Tmaninc
           
          Started by rexmie888, Yesterday, 09:37 PM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_ChrisSch  
          Started by larkmail, Yesterday, 06:19 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Marco  
          Started by jvanelli, Yesterday, 09:23 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Marco  
          Working...
          X