Rank: Member
Groups: Registered, Registered Users Joined: 3/19/2012(UTC) Posts: 13
|
Hi Everyone,
Needing some help it seems, as I am pulling my hair out!
Have created latches to grab values on trade triggers - eg. When the trade triggers to go short, it grabs the high of the day, as shown here.
var1:= Mov((C - LLV(L,opt1))/(HHV(H,opt1) - LLV(L,opt1)),opt2,S)*100;
ShortEntry:= ref(var1,-1)<ref(Mov(var1,opt3,S),-1)
and
ref(mov(c,opt7,w),-1)>ref(mov(c,opt8,w),-1)
and
l<ref(l,-1);
Trigger:= If(ShortEntry,H,PREV);
H>trigger
Note: This is the system tester code. Along with this is a stop order code which only has a difference in the last line, so instead of H>trigger, it is just trigger.
If there is a shortentry triggered, it gets the high; if not, it retains the value from the last time the triggered event happened.
Here is my issue - there can be more than one trigger event before the trade is supposed to close. Therefore it is grabbing a new value every time the event occurs, even though I am already in the trade.
What I am looking to do is have the original SHORTENTRY HIGH value held when I am short, even if other shortentry triggers come along. As it is now, it is dumping the value for when the trade was entered because another trigger has happened.
Hope that makes sense.
I have tried wrapping the trigger in a multitude of IFs, but cannot seem to come up with the magic formula.
Looking for something like this, I guess:
If SHORTENTRY is TRUE and no position or a long position is held, THEN enter the short trade AND retain the HIGH as a STOP, OTHERWISE see IF a short trade is already held, and IF so, retain the PREVIOUS HIGH from that trigger UNTIL a longentry occurs or a STOP based on the short trade HIGH is hit.
Again, hope it makes sense. Please let me know if you have any questions.
Thanks very much for all your help, Darren
PS. I have a picture of the indicator that shows the issue nicely, but don't see how to upload, so help there would be appreciated as well.
|