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 can you compare current bar price to the crossover value of the EMA/SMA

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

    how can you compare current bar price to the crossover value of the EMA/SMA

    Im am experimenting with crossovers:
    if (CrossAbove(EMA(Fast), SMA(Slow),1))
    //if the current price is <= crossvalue
    EnterLong("EMASMA");

    elseif (CrossBelow(EMA(Fast), SMA(Slow),1))
    //if the current price is >= crossvalue)
    EnterShort("EMASMA");


    I am stuck with the pseudo code in green
    any ideas greatly appreciated

    #2
    You need to determine what you consider is the cross value. Then just compare it to Close[0]. Close[0] on an unclosed bar is the latest price.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      correction

      when the crossover occurs - the trade is at market and typically entered above the cross over for a long or below ot for a short - soometimes too much ---
      so i want to try to control the entry range - maybe by putting a limit entry on lower/higher as appropiate with a trailing stop --- thats what i am building up to :-)

      Last edited by tomleeson; 05-08-2009, 01:00 PM. Reason: post analysis of posting !

      Comment


        #4
        tomleeson,

        Submit your limit order at a limit price of Close[0] +/- a few ticks to get you the order in at the cross. You need to do a few ticks because if you are exactly at Close[0] and the price moves away from you you could potentially end up submitting at an invalid price and get your order rejected.

        Ultimately though slippage is part of electronic trading and you will have to just compensate for it in your system.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Josh - i thouhgt i might be able to do it by getting it on really quick in the same bar - but this was not possible:
          if (CrossAbove(EMA(Fast), SMA(Slow),0))
          EnterLong(
          "EMASMA");
          elseif (CrossBelow(EMA(Fast), SMA(Slow), 0))
          EnterShort(
          "EMASMA");

          So yes limits would be good - but then they might not be hit - but as you point out you cant get a quote before going to market ans expect it to wait!!!
          Last edited by tomleeson; 05-08-2009, 01:13 PM.

          Comment


            #6
            Right. Your best bet may be to stick with market orders.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              thank you for your help Josh

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by andrewtrades, Today, 04:57 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              6 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              436 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              9 views
              0 likes
              Last Post FAQtrader  
              Started by rocketman7, Today, 09:41 AM
              5 responses
              20 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X