General Topics
Technical Topics
Brokerage Firms
Community Lounge
Site Support

Discussion in 'Automated Trading' started by shortbleu, Sep 18, 2011.

1. ### shortbleu

Not sure if it needs programming or if ninja trader 7 can do it from scratch.
How can I implement the following simple strategy with ninja trader 7?
If price is 40 ticks above the current low of the day sell short, or if price is 40 ticks below the current high of the day buy. The strategy needs to trade once a day maximum: if price moves up and down accross the +40/-40 ticks level, NT will trade only the first time the level is crossed and will not trade anymore if the level is crossed again later in the day.

2. ### Loki45

Couldn't you just manually issue 2 OCO orders (each with an ATM strategy, if desired), one above the low and one below the high of the day? Check Help if you don't know how OCO orders are issued.

3. ### shortbleu

Hi Loki45,

I thought about the OCO orders being placed at fixed price levels but the low and high will keep moving in real time and therefore the price levels where the OCO orders are placed also need to move in real time to follow the moves of the high and low.

Let me explain: if at some point in the day, the high is 105 and the low is 95, I want to sell at 135 (95+40) or I want to buy at 65 (105-40). But later in the day, there is a new low of 90 therefore I want to sell at 130 (90+40). As the low and high keep moving during the day, the levels at which I place my orders would need to move along with the high and low.

Not sure how to place orders at prices levels which keep moving with the low and high. Can someone help?

4. ### Loki45

NinjaScript has two functions that you may want to look into: Low[x], which gives you the low price of the x. bar back, and LowestBar(y) which gives you the index number of the lowest bar within a lookback period of y bars. So, for example, the lowest price within the last 100 bars would be = Low[LowestBar(100)]. That would work with the current (default) data series. You may specify other data series, though. You may want to enter the lookback period y as a parameter when you start the strategy.

Same of course for the high side.

You can get more and probably better help through the NT forum. The NT technicians there usually are pretty fast and helpful.