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 jaybedreamin, Today, 05:56 PM
              0 responses
              3 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Working...
              X