Announcement

Collapse
No announcement yet.

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 szferi, Today, 02:04 AM
              0 responses
              4 views
              0 likes
              Last Post szferi
              by szferi
               
              Started by Rosario, Today, 12:50 AM
              0 responses
              4 views
              0 likes
              Last Post Rosario
              by Rosario
               
              Started by MartynBashi, Yesterday, 11:01 PM
              0 responses
              4 views
              0 likes
              Last Post MartynBashi  
              Started by manueldecastro, Yesterday, 10:59 PM
              0 responses
              3 views
              0 likes
              Last Post manueldecastro  
              Started by pkr75, Yesterday, 10:09 PM
              1 response
              4 views
              0 likes
              Last Post pkr75
              by pkr75
               
              Working...
              X