• 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 brunoviveiros, 08-04-2020, 09:36 AM
          3 responses
          36 views
          0 likes
          Last Post ATMtrader0001  
          Started by DieSlower, Yesterday, 09:46 PM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by orenytz, Today, 06:10 AM
          0 responses
          3 views
          0 likes
          Last Post orenytz
          by orenytz
           
          Started by ATMtrader0001, Today, 05:05 AM
          0 responses
          4 views
          0 likes
          Last Post ATMtrader0001  
          Started by webus, Today, 02:03 AM
          0 responses
          10 views
          0 likes
          Last Post webus
          by webus
           
          Working...
          X