PDA

View Full Version : Entry and EXIT an SMA


Sailor
11-14-2008, 04:06 AM
Hello,

I have two question.

1) I want to go short if the price is below the sma20 for a longer time and it comes to kiss the sma20. All the time as the price is below the SMA20 a limit order is set at the sma20 and will be automaticly modified as the SMA 20 changed ofer time.

2) I want to exit the trade on a SMAxx Target on a specific Timeframe. This taregt must be modified automaticly as the sma is changed over time. The same will be with the STOP Loss. IF one of each is hit the oter oder must be canceled.

Thanks for yoour help
Sailor

NinjaTrader_Josh
11-14-2008, 07:35 AM
Hi Sailor,

One of our NinjaScript trainees will respond later today. Thank you for your patience.

NinjaTrader_Bertrand
11-14-2008, 09:20 AM
Hi Sailor,

Thanks for your post.

Please take a look at the following screenshots from our strategy wizard -

1. The first enters a limit order at the SMA when the last 3 closes were below it, you can of course add more here to make the entry condition tighter.

2. The second exits the short trade at the SMA of the Low price with the use of a limit order.

Please also review this link here - http://www.ninjatrader-support.com/HelpGuideV6/ConditionBuilder1.html

Then use the blue arrows at the top to navigate through the Condition Builder examples.

Sailor
11-18-2008, 03:29 PM
Thanks for your help. one last question how can I set a stop loss order based on the last highest high above an SMA Line ?

NinjaTrader_Bertrand
11-18-2008, 04:24 PM
Hi Sailor,

You are welcome.

Please take a look at those three screenshots, those detail all the sets of conditions you need to arrive at your custom stop value.

However you cannot use it right away in the wizard to update your stop loss order continually. You would need to move to the NinjaScript Editor then by unlocking your code. Please also review this reference sample -
http://www.ninjatrader-support2.com/vb/showthread.php?t=3222

Variable0 stores the Stop value you want to use in your order.

Sailor
11-19-2008, 03:17 AM
Betrand,

I am receiving an error after compiling
Connot convert from double to integer line 58

customvariable0 == 0

Any idea

Nice to see that you are from Hamburg, I am from Berlin.

Thanks Sailor

NinjaTrader_Bertrand
11-19-2008, 08:45 AM
Hi Sailor,

yes, both very nice cities, was in Berlin for some time, too!

How did you declare your 'customvariable0' in the Variables() section?

Also for assigning a value to your variable you should use only one equal sign -


if (Close[0] > Close[1])
customvariable0 = 0

Sailor
11-19-2008, 12:46 PM
I have found the problem it was in an other strategy which was not compiles without errors. So now it is working !

One last point what can you do if you start the srategy when the strategy in theory already executed the short sell but in realtrading the position isnt short?

Thanks

NinjaTrader_Josh
11-19-2008, 01:02 PM
When you start your strategy you start off in what is known as a Strategy Position. This position is not to be confused with your Account Position. You have a few options available at this point. You can either sync up your Account Position with your Strategy Position through manually placing orders or you can select "Wait until flat before executing live" and just wait for your strategy to kick in live.

The second is easier for most people. All you have to do is ensure your Account Position is flat, select "Wait until flat" in Tools->Options->Strategies->NinjaScript and then when your strategy crosses the flat state the next order will be a live trade. At that point in time your two positions will be in sync.

Please review this link: http://www.ninjatrader-support2.com/vb/showthread.php?t=4033

hanaa
07-06-2009, 10:02 AM
hi iam runnig a simple strategy.that does not have target or stop loss.please advise how to add stop loss and target to it
regards
hanaa

NinjaTrader_Austin
07-06-2009, 10:13 AM
Hi hanaa, thank you for your question.

If you are using the strategy wizard, the target and stop loss section is right after the 'Conditions and Actions' page.

If you are programming in NinjaScript, please read the references on SetProfitTarget (http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?SetProfitTarget), SetStopLoss (http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?SetStopLoss), and SetTrailStop (http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?SetTrailStop).