Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Always In Strategy for testing

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

    Always In Strategy for testing

    Hello,

    I'm "toying" with an "Always-In" strategy so I can test the use of GetCurrentBid() and GetCurrentAsk(). I've attached the Indicator and Strategy codes and screenshots below. I'm not sure why the following occurs:

    1. I've added DrawLine so you can see when the GannHiLo flips - not sure the best way to get the entry orders to exactly hit like the drawline plots.
    2. I've included exits right before entries - I'm believing I should get a same fill unless I need to have a reversing order instead? What is the syntax for reversing orders?
    3. Sometimes, the orders don't fill so that when the TriggerDown line has plotted, and after a bar has passed, I'm still in a long position. Not sure why...
    4. If Indexing or COBC should be modified to make this work correctly, please let me know.
    5. If the use of GetCurrentBid/Ask needs to be modified to something better, please let me know. I'm sometimes using OnMarketData but I've simplified for this test.

    Thanks for any help.

    Kirk

    ps - I'm testing on a 1-minute chart (30 sec when the market slows down) just to test setups.
    Attached Files

    #2
    1. If you want to guarantee a price you will need to use limit orders. If you just care for speed, use market orders. Note that placing limit orders at bid and price is not advisable. If the market moves fast against you by the time your order travels across the internet to the market it could very well be rejected for an invalid price.

    2. If you want to reverse just tell it to do a EnterShort() if you are long and an EnterLong() if you are already short. It will automatically close you and then reverse you. You do not need to place an explicit Exit() before it.

    3. To understand what your orders are doing I suggest you run with TraceOrders = true so you can track it and see what is going on under the hood.

    4. I am not sure what you mean here.

    5. Would think it should be fine.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thank You Josh,
      1. I'm using limit orders using the "worst-case" ie going Long at the Ask price and going Short at the Bid. I'm not sure how often this would be passed over on a fast run like you mentioned.
      2. In my code, I'm trying to exit/enter at the same limit price. Do I understand correctly that this would require "EnterLongLimit(limitprice)" with an "ExitShortLimit(limitprice)" just prior to that?
      3.I have trace orders set to true.
      4. I'm wondering if the CalcOnBarClose could be false and allow this to function or if I need to change some of the [0] to [1] for completed bars or if I'm able to use FirstTickOfBar to solve some of these issues.
      5.ok
      thanks again, please help with these last few questions.
      Kirk

      Comment


        #4
        1. In real trading it can happen quite often depending on many factors like internet latency. The ask/bid price you submit at may be valid when your computer submits, but by the time it reaches your brokerage it could be an invalid ask/bid price.

        2. Yes.

        3. You can view the output in the Output Window.

        4. Not sure I follow. CalculateOnBarClose has no impact on what you get filled at.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X