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
-
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,
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 RideMe, 04-07-2024, 04:54 PM
|
5 responses
28 views
0 likes
|
Last Post Today, 08:48 AM | ||
Started by f.saeidi, Today, 08:13 AM
|
1 response
5 views
0 likes
|
Last Post Today, 08:47 AM | ||
Started by DavidHP, Today, 07:56 AM
|
1 response
6 views
0 likes
|
Last Post Today, 08:16 AM | ||
Started by kujista, Today, 06:23 AM
|
3 responses
10 views
0 likes
|
Last Post
by kujista
Today, 08:15 AM
|
||
Started by Mindset, Yesterday, 02:04 AM
|
2 responses
18 views
0 likes
|
Last Post Today, 08:15 AM |
Comment