Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

avoid being filled in gaps...?

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

    avoid being filled in gaps...?

    Hi everyone,

    I have a small issue that I cannot find how to deal with it... when my strategy gets backtested it happens that after setting a EntryStopShort() at lets say the low of a bar then if the next day`s bar opened in a big gap it unrealistically creates a FILL at the low of the bar .... I would like to be able to indicate the strategy NOT to fill any entry if the next days open with a gap out of the price... is that possible??

    Another issue I have is by doing a SetStopLoss() ... I am doing the following piece of code after detecting my signal... awkwardly the setstoploss for the SHORT works but not the one for the LONG

    if (condition)
    {
    EnterLongStop(DefaultQuantity, High[0] + 1 * TickSize, "Outlong");
    EnterShortStop(DefaultQuantity, Low[
    0] - 1 * TickSize, "Outshort");
    SetStopLoss(
    "Outlong",CalculationMode.Price,Low[0]-1*TickSize,true); // this one does not work :S
    SetStopLoss(
    "Outshort",CalculationMode.Price,High[0]+1*TickSize,true); // This one works
    }

    can you give some pointers?

    thanks

    GS
    Last edited by gsmaster; 07-13-2007, 01:14 PM.

    #2
    Issue 1) This can't be changed

    Issue 2) Try putting the SetStopLoss() calls above the Enter() calls, does that make a difference?
    RayNinjaTrader Customer Service

    Comment


      #3
      thanks for the tip, I just tried , it did not work... but its weird the short stop loss work the other not...

      GS

      Comment


        #4
        Strip down your strategy so that it only goes short. Are stop loss orders submitted?
        RayNinjaTrader Customer Service

        Comment


          #5
          In back testing I do realise that when the day changes, that could be an issue with some indicator triggering in correct results until they stabilise. Try restricting the time your strategy session starts, and extending you back testing times.
          E.g. If you are back testing from 9am to 3.PM, then you may consider setting the sesssion to back test from the period 8.30 to 3.PM, then have your code in the On Bar Update, to exit if the time is < 9.am. If you were using a 1 Minute strategy, you could start the session from 9.25 to 3.Pm just give the strategy time to adjust to 1 bar for the day, before taking actions from it.

          Comment


            #6
            Hi Support,

            yes well I obviously tried to only do long (enter and setstoploss) or short even though the short stop loss works and the long still does not :S

            GS

            Comment


              #7
              What I can confirm is that the methods do work. I took a chunk of your code and put it into a bare bones strategy. SetStopLoss() is working as expected.

              Import the attached strategy via File > Utilities > Import and use this as a starting point. Add your own logic step by step until it works as you expect it to.
              Attached Files
              RayNinjaTrader Customer Service

              Comment


                #8
                thanks I will ...

                Comment


                  #9
                  dear Support,

                  I have tried to fix the problem without success but I found something interesting that might help you help me

                  look at the code:

                  if (conditiontoenterlimits)
                  {
                  DrawDot(
                  "tdot" + CurrentBar, 0, High[0] + 1 * TickSize, Color.Blue);
                  highxx=High[
                  0];
                  lowxx=Low[
                  0];
                  flag=
                  1;
                  SetStopLoss(
                  "short",CalculationMode.Price,High[0]+1*TickSize,true);
                  SetStopLoss(
                  "long",CalculationMode.Price,Low[0]-1*TickSize,true);
                  EnterLongStop(DefaultQuantity, High[
                  0] + 1 * TickSize, "long");
                  EnterShortStop(DefaultQuantity, Low[
                  0] - 1 * TickSize, "short");
                  }


                  if (flag==1)
                  {

                  if (conditiontoexitlong==true)
                  {
                  DrawDiamond(
                  "MyDiamond" + CurrentBar, 0, High[0] + 2 * TickSize, Color.Blue);
                  ExitLong(
                  "Exitlong", "long");
                  flag=
                  0;

                  }


                  if (conditiontoexitshort==true)
                  {
                  DrawDiamond(
                  "MyDiamond" + CurrentBar, 0, High[0] + 2 * TickSize, Color.Blue);
                  ExitShort(
                  "Exitshort", "short");
                  flag=
                  0;

                  }
                  }


                  ok what I have found is this,,, if I leave everything as is then setstoploss for the SHORTS will not work... but if I comment the conditiontoexitshort block then BOTH stoploss for longs and shorts will work.

                  If I uncomment the conditionexitshort and comment conditiontoexitlong then I still get the same stoploss error...

                  in conclusion I think something is wrong with conditiontoexitshort the problem is that I cannot see the error... any ideas??

                  thanks
                  GS

                  Comment


                    #10
                    Thanks. Could you send me your strategy so I can test it on my end? Send to support at ninjatrader dot com and in the subject include "For Ray" and reference this post. Thanks.
                    RayNinjaTrader 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