You will need to include your full entry code for "trade" to be effective.
Below is a detailed example showing the buytrigger as only 1 component of the buyformula. The same is also applicable to the exit.
{Expert Adviser - Highlight bars when in Trade} buytrigger:= Sum(C>Ref(C,-1),3)=3; buyformula:= Ref(buytrigger,-1) AND OPEN>Ref(C,-1); exittrigger:= Sum(C<Ref(C,-1),2)=2; exitformula:= Ref(exittrigger,-1) AND OPEN<Ref(C,-1); set:= buyformula; reset:= exitformula; init:=Cum(set+ reset>-1) =1; trade:=BarsSince( init OR set)<BarsSince( init OR reset); trade
{Expert Adviser - BuyTrigger Symbol} {Also use this code for Explorations} {Will only show buytriggers when not in a trade} buytrigger:= Sum(C>Ref(C,-1),3)=3; buyformula:= Ref(buytrigger,-1) AND OPEN>Ref(C,-1); exittrigger:= Sum(C<Ref(C,-1),2)=2; exitformula:= Ref(exittrigger,-1) AND OPEN<Ref(C,-1); set:= buyformula; reset:= exitformula; init:=Cum(set+ reset>-1) =1; trade:=BarsSince( init OR set)<BarsSince( init OR reset); trade<1 AND buytrigger
{Expert Adviser - ExitTrigger Symbol} {Will only show exittriggers when in a trade} buytrigger:= Sum(C>Ref(C,-1),3)=3; buyformula:= Ref(buytrigger,-1) AND OPEN>Ref(C,-1); exittrigger:= Sum(C<Ref(C,-1),2)=2; exitformula:= Ref(exittrigger,-1) AND OPEN<Ref(C,-1); set:= buyformula; reset:= exitformula; init:=Cum(set+ reset>-1) =1; trade:=BarsSince( init OR set)<BarsSince( init OR reset); trade AND exittrigger
For BuyTrigger Explorations use the code for the EA - BuyTrigger Symbol
--- On Fri, 12/3/10, skypilot_jw <jweidner@xxxxxxxxxx> wrote:
From: skypilot_jw <jweidner@xxxxxxxxxx> Subject: [EquisMetaStock Group] Latch Code Question To: equismetastock@xxxxxxxxxxxxxxx Received: Friday, 12 March, 2010, 5:21 PM
I use MS 9.0 EOD and have set up an expert with the usual buy and sell latch parameters of:
set:= buy formula; reset:= exit formula; init:=Cum(set+ reset>-1) =1; trade:=BarsSince( init OR set)<BarsSince( init OR reset); trade AND Alert(trade= 0,2)
I also use the same code in the explorer to find securities which have triggered.
My question is this. When my expert triggers a buy signal, I place a buy order for the next day based on the high of the triggered signal. If the market price the next day does not exceed the high, then my buy order is not executed. However, the code has latched the security and will not reset until the latch code triggers the exit formula (Close below 21 EMA for example). After the market close when I run another exploration, the same security will not appear on the explorer report because it is stll latched (has met the entry formula but hasn't triggered the exit formula). Is
there a way to code it so that when a security triggers a buy, and the following day's high is lower than the previous day's high, the latch exits and will re-latch when the buy formula is met again.
Thanks for your help with this.
|