View Full Version : 2 ticks offset strategy
alex12lad
07-22-2007, 07:36 PM
Hi,
I don't know C++ and need some help in implementing one strategy.
I want to enter long 2 ticks below the ask generated by one of the Kwikpop indicators. This indicator = 1, only for the signal bar when it was generated.
Of course, 2 ticks below the ask could be generated on the current bar, or on the next one, or the following one or never.
So, it looks like I have to save the ask on the signal bar and then subtract 0.5. I'm not sure I'm doing it correctly.
That's the excerpt:
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
double x;
///condition set 1 (trying to get the current
///ask and save it but how?!)
if (N [0] == 1)
{
x = GetCurrentAsk();
}
/// Condition set 2
/// if the condition of 2 ticks below comes, let's say, only on the second
/// bar after signal, then N[0] wouldn't be equal 1, but
///on the previous bar N[1] was equal 1.
if (N[0] == 1
||
N[1] == 1
||
N[2] == 1)
{
EnterLongLimit(2,double.x-0.5);
}
Unfortuanately, there are compilations errors.
I'd appreciate your reply.
Alex. alex12Lad@yahoo.com
http://www.ninjatrader-support.com/vb/images/statusicon/user_online.gif http://www.ninjatrader-support.com/vb/images/buttons/report.gif (http://www.ninjatrader-support.com/vb/report.php?p=12999) http://www.ninjatrader-support.com/vb/images/misc/progress.gif
NinjaTrader_Dierk
07-23-2007, 01:50 AM
Sorry, due to bandwidth reasons we are unable to provide support down to the level of coding or reviewing actual strategies/indicators. You might want to consider contacting a NinjaScript consultant: http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm
alex12lad
07-24-2007, 04:21 PM
Hi Dierk,
Thank you for your reply.
I'm just trying to fix an error which is generated through Strategy Wizard.
Try to take any strategy and go Long or Short with + or - offset through a Wizard. It seems to be straightforward but, unfortunately, the results are totally unpredictable and haphazard.
I'd appreciate your reply.
Alex.
NinjaTrader_Dierk
07-24-2007, 11:30 PM
>> the results are totally unpredictable and haphazar
Please be specific. Can you provide a scenario on how to reproduce the problems you experience? Thanks
alex12lad
07-25-2007, 06:15 AM
I'm using one of the Kwikpop indicators for NT which is NTKPPowerPops which is equal 1 for 'go long' signal bar and -1 on short signal bar. Everywhere else it's equal 0. So when I try to enter long 2 ticks below, these 2 ticks below may occur on a second bar after signal but there JPKPpowerpops is not equal 1 already, and buy signal isn't generated. When these 2 ticks below occur on the same bar where signal is generated then my coding seems to work but it happens not so often. When you try to do it through a strategy wizard it gives a buy signal 20-30 ticks away from the price.
NinjaTrader_Ray
07-25-2007, 06:29 AM
From a programming standpoint,
If you have something like:
Low[0] - (2 * TickSize)
You will get an offset of 2 ticks off of the low of a bar. If you are getting values that you are not expecting, I would add some Print() debug statements in your code to try to determine what is happening.
alex12lad
07-25-2007, 06:44 AM
When a signal occurs it may not be the low of the bar ( I assumed that it's a Current Ask), so it looks like i have to save the price when a signal occurs. I did like this:
'double x' and then, 'if NTKPPOWERPOPS[0] = 1, x = GetCurrentAsk()';(see coding below),
but compiler doesn't take it, with strange 2 messages: you might need declare a classs, etc., and end of file needed.
NinjaTrader_Dierk
07-25-2007, 07:11 AM
- double clicking on the error will get you to the erroneous code
- "end of file" errors usually are related to incorrect brackets (like '{}' or '()') .
alex12lad
07-26-2007, 04:23 AM
how to code in C++:
If N[0] = 1, 'save current ask'
NinjaTrader_Dierk
07-26-2007, 04:27 AM
As pointed out below, unfortunately we are unable to provide support down to the level of coding or reviewing actual strategies/indicators. You might want to consider contacting a NinjaScript consultant: http://www.ninjatrader.com/webnew/pa...injaScript.htm (http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm)
Thanks for your understanding.
NinjaTrader_Dierk
07-26-2007, 04:39 AM
I did a quick google search for C# primers and found this:
http://codemonkey.sunsite.dk/training/languages/csharp/csharpprimer.html
May be it is of help...
piper
08-12-2007, 11:54 AM
Hi Dierk,
reading this thread, I have had an issue similar to Alex, inasmuch as an EnterLong instruction is not implemented immediately by NT.
It can be delayed one or even two bars after the command is issued by my strategy.
As Alex says, the result is umpredictable.
Why is the command not immediately submitted by NT, in the same bar as it is generated ?
thanks for your assistance,
Peter.
NinjaTrader_Dierk
08-12-2007, 11:11 PM
Sorry I don't know. EnterLong should place an order right after bar close. It could be something related to multiple entries in the same direction. Please check out TraceOrders in order to understand what your strategy does: http://www.ninjatrader-support.com/HelpGuideV6/TraceOrders.html
piper
08-13-2007, 06:19 AM
Thanks for the reply.
Interesting that NT waits till bar close before placing the order.
Even with CalculateOnBarClose = false ?
why's that?
Peter
NinjaTrader_Dierk
08-13-2007, 06:22 AM
Order are placed right away if CalculateOnBar=false is set. I suggest trying with e.g. the SampleMACrossOver strategy.