Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trend following strategy problems.

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

    Trend following strategy problems.

    Hi.
    I almost developed my trade strategy in Ninja Strategy Creator.
    But I still have 4 problems whih I can not resolve myself. I'm not programmer and I do not know how to resolve folowing problems.

    My trading system is based on trend following rules.
    I enter long when the bar 0 closing price is above "n" (let's say 10) previous bars closing and opening prices.
    I enter short when the bar 0 closing price is below "n" (let's say 10) previous bars closing and opening prices.

    1. I build condition 20 conditions for above in Condition and Action builder:
    (Close[1] < Close[0]
    && Close[2] < Close[0]
    && Close[3] < Close[0]
    && Close[4] < Close[0]
    && Close[5] < Close[0]
    && Close[6] < Close[0]
    && Close[7] < Close[0]
    && Close[8] < Close[0]
    && Close[9] < Close[0]
    && Close[10] < Close[0]
    && Open[0] < Close[0]
    && Open[1] < Close[0]
    && Open[2] < Close[0]
    && Open[3] < Close[0]
    && Open[4] < Close[0]
    && Open[5] < Close[0]
    && Open[6] < Close[0]
    && Open[7] < Close[0]
    && Open[8] < Close[0]
    && Open[9] < Close[0]
    && Open[10] < Close[0])
    {
    EnterLong(1, "");

    Close[1] > Close[0]
    && Close[2] > Close[0]
    && Close[3] > Close[0]
    && Close[4] > Close[0]
    && Close[5] > Close[0]
    && Close[6] > Close[0]
    && Close[7] > Close[0]
    && Close[8] > Close[0]
    && Close[9] > Close[0]
    && Close[10] > Close[0]
    && Open[0] > Close[0]
    && Open[1] > Close[0]
    && Open[2] > Close[0]
    && Open[3] > Close[0]
    && Open[4] > Close[0]
    && Open[5] > Close[0]
    && Open[6] > Close[0]
    && Open[7] > Close[0]
    && Open[8] > Close[0]
    && Open[9] > Close[0]
    && Open[10] > Close[0])
    {
    EnterShort(1, "");
    It's works but I can not optymize it.
    Are there any diffrent way to set such conditions using User Definied Imputs whih allow to optymize the "n" numbers of previous bars ????

    2.I would like to change trading parameters ( number of bar before, stop loss and stop limit for night time and market openning time.
    For example:
    From 3:15 PM to 8:00PM strategy do not trade. I would like to strategy ignore all trading signals.
    From 8:00 PM to 8:30 AM , trading signals from 10 bars ago, stop loss 20 ticks, stop limit 60 ticks
    From 8:30 PM to 3:15 PM tradin signal from 15 bars, stop loss 10 ticks stop limit 100 ticks

    Could you advise me how to programme such conditions.
    Maybe make 2 separate strategies and set different time for activate them???
    I do not know how to do it


    3. Now stop loss and stop limit are calculated from the real price of transaction but I would like
    to calculate them from the exact trade signal price (in my case bar closing price) no matter real buy/sell price.

    4. How to programme strategy to place orders 2 or 3 second before bar close??


    Rgds
    Czarek

    #2
    1) Yes, you can set a user defined input to represent the N number of bars but the coding for this likely needs to be done using a programming loop since N is a variable and through the wizard you are hard coding the number of bars. This means you have to exit the wizard and use the NinjaScript Editor.

    2) See here - http://www.ninjatrader-support.com/H...mparisons.html

    3) Then you must store the signal price in a variable and instead of using the stops/targets screen, just use the actions "Exit long stop" etc... and pass this variable in via price

    4) You would have to run a strategy with CalculateOnBarClose set to false (tick by tick) and then check time stamps and when you are near the trigger time, send the order. This is no guarantee that you will execute at that time since you may NOT have a tick for 1 minute in a 2 minute bar and thus you will never place the order.

    All of what you want to do you really will need to self code using the Editor and not the Wizard.
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks for explanations.
      I think I will be able to fix almost all problems exept most important.
      I mean topic no 1 with "n" bars.
      Unfotunately I'm not programmer and I do not know how to use NinjaScriptsEditor.
      Could you advise me where can I find such script tenplate or where can I orders such script or give some advise how to type such script

      Rgds
      Wesley

      Comment


        #4
        This is basic programming skills outside of NinjaScript. Unfortunately we do not provide assistance in this area.

        You can check the Help Guide as we do provide some examples on loops. You can also Google for "C# loops".

        RayNinjaTrader Customer Service

        Comment


          #5
          Your first question:

          You can use the MAX and MIN functions.

          If Close[0] == MAX(Close,var1)
          {
          Enterlong;
          }

          In you example var1=10. But now you can backtest var1 for all values between 2 and .....
          Last edited by Nick88; 07-02-2008, 06:19 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Waxavi, Today, 02:10 AM
          0 responses
          6 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by TradeForge, Today, 02:09 AM
          0 responses
          11 views
          0 likes
          Last Post TradeForge  
          Started by Waxavi, Today, 02:00 AM
          0 responses
          2 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by elirion, Today, 01:36 AM
          0 responses
          4 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by gentlebenthebear, Today, 01:30 AM
          0 responses
          5 views
          0 likes
          Last Post gentlebenthebear  
          Working...
          X