Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting limits in FX

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

    Setting limits in FX

    Dear all,

    I trade stocks for a year and I decided to enter into FX trading too. I noticed huge differences between backtest and realtime (simulated through NT and Kinetick realtime) results:

    In backtest I always enter at bar's Open. In realtime sometimes I enter higher than High and nowhere near Open. I set up limits like:

    if (GetCurrentAsk()<Close[0]) {price_to_buy=Close[0];}
    if (GetCurrentAsk()>=Close[0]) {price_to_buy=GetCurrentBid();}

    when it comes to EnterShort for example.

    1. Is my approach naive or in the right direction when it comes to the above limits definition? I try to be as close as much to previous bar's Close in order to be near next bar's Open.

    2. I get no differences when I set up these limits in backtest. I still wait for realtime. Does this mean that in backtest I have no access to the past Bid/Ask values?

    3. I guess I should always have now CalculateOnBarClose=false?

    Thank you!

    #2
    Hello Jim_Feyn,

    Thank you for your post.

    With Forex data, the last price is going to be the bid price. You are correct in assuming that in a back test you do not have access to historical bid or ask data.

    If you open a chart and load it with Ask data instead, you should see the correlation with the Ask prices and the fill price of the orders.

    With the CalculateOnBarClose you can try testing it with False to see what kind of results you will get between running it True
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your prompt reply.

      I start exploring StopLimit orders. When I write this:

      EnterLongStopLimit(High[0], High[0]-2*TickSize);

      sometimes, but not always, I get "KinetickRealTime: Stop Buy or Stop Buy Limit orders cannot be placed below the market" and the strategy terminates itself.

      Any clues? NT help has the following piece of code:

      EnterLongStopLimit(High[0]+2*TickSize, High[0]);

      instead of mine.

      Comment


        #4
        Jim_Feyn,

        If this is a backtest, this may be true because the order will be placed on the next bar that the submission was made on. If the next bars close price was higher than the High values of the previous bar then you would get this message.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          I see. It is real time with simulated orders. I perform it as we speak.

          Comment


            #6
            Hello Jim_feyn,

            Can you please attach your strategy so that I can test it on my end and investigate the code?

            You can attach items by clicking Reply -> Go Advanced -> Paperclip icon on the toolbar
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Yes, I attached the strategy. It decides for long/short from an indicator that hides the logic, hence I reveal only the execution part.

              When indicator reaches 2 for the first time, I try to enter short. While it keeps being 2 I am in short mode and keep trying to enter short. Same for 6 and long respectively.

              The code is short; hopefully I am not wasting your time. I really appreciate!

              Thank you.
              Attached Files

              Comment


                #8
                Jim_feyn,

                Any chance I can get the my_indicator as well that the strategy is referencing?
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  I can't, it's very novel idea, a paper is about to be submitted soon about this approach, I'm so sorry.

                  In the end the indicator just produces integers, we are interested only in 2 and 6 for short trend and long trend repectively.

                  Comment


                    #10
                    Hi,

                    did you find any obvious mistakes in the strategy's execution logic?

                    Thank you!

                    Comment


                      #11
                      Jim, for the StopLimit order you try we would expect such an issue occasionally -

                      EnterLongStopLimit(High[0], High[0]-2*TickSize);

                      Since your stop price here for the order to be parked is could be below the current bar's inside market, just imagine a bar closing near or at the high of the bar when you submit this in - would result in a rejection.
                      BertrandNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by cre8able, Today, 01:16 PM
                      1 response
                      4 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by chbruno, 04-24-2024, 04:10 PM
                      3 responses
                      47 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by samish18, Today, 01:01 PM
                      1 response
                      6 views
                      0 likes
                      Last Post NinjaTrader_LuisH  
                      Started by WHICKED, Today, 12:56 PM
                      1 response
                      8 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by WHICKED, Today, 12:45 PM
                      1 response
                      11 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Working...
                      X