Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NinjaTrader 8 Strategy help!
Hey, I need a simple strategy code temple that I can add more conditions to, so please add notes in the code where needed. Right now I have this code.
if (CrossBelow(Close,ParabolicSAR1,1))
{EnterShort(Convert.ToInt32(DefaultQuantity), "");}
// Set 2
if (BarsSinceEntryExecution()==4)
{ExitShort(Convert.ToInt32(DefaultQuantity), "", "");}
Which I add the conditions I want, then when they are met it opens a position, then 4 bars have passed it closes the position. I need it to close the positions on 5 minute intervals instead of 4 bars have passed. So if the order was opened at 2:20 it closes at 2:25, if opened at 2:21 it closes at 2:25, if opened at 2:27 it closes at 2:30, if opened at 2:29 it closes at 2:30, and so on and so on.
Just replace if (BarsSinceEntryExecution()==4)

with something like this just change to 5 min instead of 20

You should convert your start time to a UTC time, say 'start'.

You can now compare your start time to the current UTC time using:

start.AddMinutes(20) > DateTime.UtcNow
Possibly Related Threads…
Last Post
Replies: 4
Views: 2,185
05-27-2020, 12:49 AM
Last Postwaldo
Replies: 1
Views: 5,746
05-29-2018, 11:44 AM
Last Postjoseheredia
Replies: 0
Views: 3,347
04-16-2017, 06:00 AM
Last Postwaldo

Forum Jump:

Users browsing this thread: 1 Guest(s)

Copyright TradingFuturo, LLC.

Futures and forex trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones’ financial security or life style. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.

Hypothetical Performance Disclosure:

Hypothetical performance results have many inherent limitations, some of which are described below. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown; in fact, there are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. One of the limitations of hypothetical performance results is that they are generally prepared with the benefit of hindsight. In addition, hypothetical trading does not involve financial risk, and no hypothetical trading record can completely account for the impact of financial risk of actual trading. for example, the ability to withstand losses or to adhere to a particular trading program in spite of trading losses are material points which can also adversely affect actual trading results. There are numerous other factors related to the markets in general or to the implementation of any specific trading program which cannot be fully accounted for in the preparation of hypothetical performance results and all which can adversely affect trading results.

Current time: 10-01-2020, 03:14 PM