Rank: Newbie
Groups: Registered, Registered Users Joined: 10/31/2004(UTC) Posts: 6
|
I'm using a latch to capture a price value after a trigger event, and I'm using that value as an indicator that overlays on the price plot. The problem is that when the trigger event is no longer valid, the latch value goes to "0" as programmed, but this obviously doesn't plot well -- screws up scaling. It works fine in a separate window, but then that does not accomplish the purpose of an indicator that readily shows price relationships. What I want to do is have the indicator default to a null value, and not show anything when the trigger event is no longer true. Any ideas how to create this?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
I use 20% below/over close for null when I overlay a indicator that swings back and forth across the price chart: If(myindicator>(1.2*C),(1.2*C),If(myindicator<(0.8*C),(0.8*C),myindicator)) It doesn't seem to mess up the current chart when I overlay it.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 10/31/2004(UTC) Posts: 6
|
John -- thanks for the tip. I'm not sure I understand what "myindicator" represents -- is this a null value? If so, what is the coding for it? I want to be sure I'm clear on what I'm trying to do, here's the formula;
N:=C>Ref(HHV(C,20),-1); TR:=If(PREV=0,If(N,C,0),If(C<PREV-2*ATR(14),0,PREV)); tr
Rather than go to zero (highlighted) to reset, which causes the indicator to drop to the zero line, I want to reset to cause a null condition so that the indicator does not plot across those bars at all.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
I am really bad at looking at anything that is imbedded in if statements. I like to breakout the logic into several variables so I can manipulate them. Don't understand why you need a null value instead of zero. To control scaling on a chart , right click the indicator- select "scaling" - select "overlay without scaling" and you can plot any indicator over another without messing things up. To create a crossover of 2 indicators that have a good crossover but are "overlayed without scale" you can"normalize" both.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
The short answer to the main problem is that you cannot make NULL values in MetaStock. There is a longer answer that says you can, but there's a catch. It is possible to create an indicator that starts plotting some number of bars into the chart (i.e. that doesn't plot from the very first bar); it is also possible to create an indicator that doesn't plot all the way to the right hand side of the chart; it is possible to combine these so that you have an indicator that doesn't touch either of the left or right edges of the chart. What you cannot do is "turn on" an indicator that has been previously "turned off". The key to then solving your trailing stop function is to use some formatting to hide the values of the "tr" function when not being used in a trade. There are several ways to do this; this is just one of them. Code:
N:=C>Ref(HHV(C,20),-1);
tr:=If(PREV=0,If(N,C,0),If(C<PREV-2*ATR(14),0,PREV));
hide:=0.9*ValueWhen(1,tr<>0,tr);
sl:=If(tr=0, hide, tr);
{plot}
sl;
hide;
Format each of the elements as discrete dots, set the size as appropriate, then colour the "hide" element the same as the chart background colour. As the "hide" element is plotted after "sl" it will obscure the "sl" when the two have the same value. There are some small issues, but I am sure some judicious work will be able to resolve these if you come across them. You can still set your entry and exit signals based on the "tr" computation. Hope this helps. wabbit [:D]
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.