Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Scalping Strategy

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

    Scalping Strategy

    Hello,

    I'd like to get some idea on how to program a strategy I have back-tested manually. I use a custom indicator that I cannot upload here but may be able to send privately to someone who could assist.

    What I am looking for is to use it on Crude Oil (CL) when certain criteria is hit. I would have about a 10 tick stop loss and would like profits targets at 5/10/15/30 ticks. As soon as the first profit target is hit, the stop loss would be moved up. Obviously there are some variables and I wanted to express the general idea on what I'd like to accomplish.


    I've tried going through the NinjaScript from the Control Center but this may be a bit too advance for creating it there. I have not done any coding in the past and any feedback of ideas on how to go about this would be greatly appreciated.

    #2
    Hello COUUUCH,

    Thank you for your inquiry.

    Please be aware that backtesting a strategy will run the strategy as if CalculateOnBarClose is set to true as it will be running on historical data. This means that any logic in your code will run only when a bar closes. This is due to the fact that with a historical data set, only the OHLCVT of the bar is known and not each tick that made up the bar.

    If you wish for your logic to run at a tick-by-tick basis, for example, you would need to add an additional tick Bars object. Please take a look at this link in our support forum that goes into detail about intrabar granularity: http://ninjatrader.com/support/forum...ead.php?t=6652

    To set your stop loss, you will want to put this line of code in your Initialize() method:
    Code:
    SetStopLoss(CalculationMode.Ticks, 10);
    This line of code will place your stop loss 10 ticks behind the execution price.

    I am not clear about your 5/10/15/30 tick profit targets. Once the position hits a profit target, the position will exit. Are you planning to use four positions in your strategy? If so, you would want to use the follow code below to set your profit targets and stop losses for each of your entries in the Initialize() method:
    Code:
    SetStopLoss("entry1", CalculationMode.Ticks, 10);
    SetStopLoss("entry2", CalculationMode.Ticks, 10);
    SetStopLoss("entry3", CalculationMode.Ticks, 10);
    SetStopLoss("entry4", CalculationMode.Ticks, 10);
    
    SetProfitTarget("entry1", CalculationMode.Ticks, 5);
    SetProfitTarget("entry2", CalculationMode.Ticks, 10);
    SetProfitTarget("entry3", CalculationMode.Ticks, 15);
    SetProfitTarget("entry4", CalculationMode.Ticks, 30);
    The entry strings (entry1, entry2, etc.) would be dependent on the signal name you have used for your entries.

    I would suggest reading this reference sample from our support forum that will go into depth of modifying prices of stop losses and profit targets: http://ninjatrader.com/support/forum...ead.php?t=3222

    The Reference Samples section of our support forum is a great resource overall. This link will bring you to the table of contents for various reference samples for many different things one may want to do in their strategy: http://ninjatrader.com/support/forum...ead.php?t=3220

    Please, let us know if you have any additional questions.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Zachary,

      Thank you for replying. As far as clarification, let's say I am trying to use just 3 profit targets on this trades, so 3 positions yes.

      I'm on the second step of the New Strategy window, specifically on the User Defined Inputs. From what I understand, the Type should be "int"? I'm not sure what default and min. is.

      Same thing on Conditions and Actions. Would I need more than one set here?

      Thanks.

      Comment


        #4
        Hello COUUUCH,

        I would highly recommend that you look over the Educational Resources for NinjaScript in the NinjaTrader help guide for useful information on how to start creating your own strategies and indicators: http://ninjatrader.com/support/helpG..._resources.htm

        I am not clear of what you are wanting to specify in the User Defined Inputs section. If you are planning to create variables to hold the value of profit target ticks, int would work fine. Default denotes the default value that will be used for the particular variable and min is the minimum valued allowed.

        The number of sets in Conditions and Actions would depend on if you plan on using multiple conditions or not.

        I would also suggest watching these two videos on our YouTube channel that go into the creation of strategies:
        Automated Strategy Development Level 1
        Learn NinjaScript Tip #1

        Please, let us know if we may be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        598 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        555 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X