Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
zigzag
Collapse
X
-
zigzag
Hi, I am using zigzag inside an automated strategy to identify ABC patterns where in a long trade A[High] B[Low] C[Higher high] - once in a trade I want to use C as my stop. Unfortunately I dont know how to tell Ninja that once we are in a trade I want it to use the C prior to the trade as my stop and not any 'new' C that it may identify after trade entry. How do I 'anchor' the C prior to the trade as the C to use? TIATags: None
-
mullum,
I am not sure if I understand exactly your problem. If you mean that after the C (the higher high) is formed you go short and you want C to be your stop loss then to find the barsago you use:
c_barsago=ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 1, 100))]);
and to find the value:
c_value=ZigZag(................................... ).ZigZagHigh[c_barsago];
In order to "lock" your stop C to the above value you need to use a switch.
Something like this:
if(initializing your strategy)
{
......;
......;
switch=1;
}
else
switch=2;
if(switch=1 && ......)
{
c_barsago=....;
c_value=...;
switch=2;
}
if(switch=2 && ....)
{
profitTarget= ...
stopLoss = c_value;
}
Cheers
-
zigzag
Thanks Astra
What I am doing is [in long trade] we identify A[first low] B[High] C[lower low] and we then set buy stop @ B with a stoploss at C.
So regarding your suggestion I only need to find the C value not bars ago - correct? And the I use a switch to lock the C value correct? Thanks very much for your help
Comment
-
No, you need both. You cannot find the C value if you don't have the bars ago. Because in the bars ago you define the instance, in your case 1.Originally posted by mullum View Post
So regarding your suggestion I only need to find the C value not bars ago - correct?
With the ZigZag indicator is very important the timing: In real time, the time the C is formed is after at least a minimum of 2 bars in the opposite direction. You can capture this moment in your code by using: if(peak_barsago>trough_barsago)
{
and load here all your targets and stop losses PLUS the switch in this statement.
}
Comment
-
zigzag
Thanks Astra - my programming skills are not up to scratch - I have tried but am unable to complete your instructions. I paid someone to write the initial code for me but he wasn't up to the task and now I have 99% completed code and am not sure where to go from here - thx anyway
Comment
-
Hi mullum,
I meant "switch", the programming technique that is widely used to have control of building blocks visits - in this case "if" statements, because it reseambles the behavior of an ordinary real world (light?) switch. Can be any word you define as such. For example, in the variables section you can define a "switch-technique" as, say, private int tralala=0;Originally posted by mullum View PostHi Astra
Can you point me in the direction to find info on how to write the correct code for a switch - I cant find it in the NT help files - thanks
Sorry for the confusion, but I assumed you were aware of it because the zigzag indicator is considered an advance indicator in terms of programming skills and almost always you need a switch-technique to make it work.
Now, I am a trader not a programmer (only over a year experience with C#) . But as at the moment I am developing an indicator that makes use of the zigzag I can be of help if I can. If you wish post the relevant part of your code here (without the details) and see.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
72 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
44 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
25 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
29 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
60 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment