|
John Crowley
 Member
Posts: 8
Joined: 6/17/2016
User Profile |
I’m trying to code a specific type of trailing stop. I have OT Pro.
It’s a trailing stop but requires certain reference points
The first reference point is the last pivot low
Using WaveTrader which has its own stop level that gives me the last pivot low value
WT_LL (0.7,14,0), this is the dotted red line in the chart as an example
The other reference point is the value of the SMA(30) at the point of the last pivot low, as defined by the WT_LL
What I want from the stop is to initially set a stop loss at the last pivot low as a starting point, if the last pivot low is below the sma 30
If the SMA 30 is below the last pivot low, the initial stop loss should be 1% below the 30sma
The stop I want to trail, based on the next pivot low
So the next pivot low should raise the stop according to the above. Ie the lower of the pivot low or 1% below the SMA(30) if the SMA is lower than the pivot
It shouldn’t trail the SMA. It should only trail when the pivot low changes
hopefully the attached explains what I'm trying to do
Can anybody could help with this?
[Edited by John Crowley on 6/18/2016 2:04 AM]
Attached file : trailing pivot stop.JPG (153KB - 441 downloads)
|
|
John Crowley
 Member
Posts: 8
Joined: 6/17/2016
User Profile |
I've gone one step further and with what actually turned out to be simpler than I thought I've produced a stop that (almost) matches with the requirements
here is the code:
#Stop
Dim myvalue as single
Dim mystop as single
If WT_LL(0.7, 14, 0) < sma(30) Then
MyValue = WT_LL(0.70, 14, 0)
Else If MyValue = sma(30)
end if
MyStop = MyValue
If Signal = Longsignal And L
Signal = ExitSignal
End if
plotprice("Stop",MyStop,green)
the plot is displayed in green on the second chart. however my problem is this:
the code of the stop is WT_ZZ(0.7,14,0) which as you can see in the attachment is the same as the indicator setting
however the movement of the stop is not using the same settings, its clearly taking differennt parameters
is this a bug?
could somebody please verify
[Edited by John Crowley on 6/18/2016 2:01 AM]
Attached file : WT settings.JPG (83KB - 423 downloads)
|
|
Jim Dean
 Sage
       Posts: 3433
Joined: 3/13/2006
Location: L'ville, GA
User Profile |
probably because the zigzag formula only ID's the pivots AFTER the fact ... it uses hindsight and therefore must be implemented with care.
plot the zigzag indicator on the chart with the same params to see when it actually "recognizes" a pivot.
|
|
John Crowley
 Member
Posts: 8
Joined: 6/17/2016
User Profile |
Thanks for the reply
I've attached the WT_ZZ indicator on the chart, same settings as the WT_LL
the two are identical, the ZZ giving the signals as per the indicator, so you can see where the change in pivot is occuring.
the stop, using the same parameters, does not behave as per the indicator settings
I've attached the indicator, and a vertical line where the change is being recognised, but the stop doesn't move with the same precision.
Attached file : WT_ZZ.JPG (79KB - 433 downloads)
|
|
Jim Dean
 Sage
       Posts: 3433
Joined: 3/13/2006
Location: L'ville, GA
User Profile |
The code you posted, as it shows up in the post anyways, has several errors in it. try attaching a zip file.
I really busy tomorrow so I don't know when I can get back to you.
|
|
John Crowley
 Member
Posts: 8
Joined: 6/17/2016
User Profile |
here is a screen shot of the code, yes when you copy and paste into the body, some of the syntax is missing.
I appreciate any time you have Jim, and appreciate just the reply itself!
In the mean time I will work on the buffer I wanted originally
Attached file : code.JPG (23KB - 456 downloads)
|