Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,960
Thanks: 92 times Was thanked: 155 time(s) in 150 post(s)
|
Originally Posted by: kerrydianne Hi I am trying to design a template to go with an Explorer/system that I have set up.
How do I get my Expert Advisor to show only the first buy and sell signals?? That is, assume I only want one trade open at a time. So a 2nd buy or sell signal should not show until the first trade has closed.
Thanks Kerry
Hi, There are a few ways you can limit conditions depending on the complexity and number of conditions. Here is one example using some moving average criteria: Code:bc:=C > Mov(C,20,S)+1{enter long condition};
be:=Cross(Mov(C,20,S),C){close long condition};
sc:=C < Mov(C,20,S)-1{enter short condition};
se:=Cross(C,Mov(C,20,S)){close short condition};
If( bc=1, 1, If(sc=1, -1, If(be OR se,0,PREV)))
One that uses a simple Buy/Sell criteria could be written as: Code:bc:=Cross(C,Mov(C,20,S)){buy signal condition};
sc:=Cross(Mov(C,20,S),C){sell signal condition};
trade:=If( bc=1, 1, If(sc=1, 0, PREV));
cross( trade= x, 0.5)
You will need to change the Trade=X, in the above formula to Trade= 1, or Trade= 0, depending on the condition you are defining, so basically you would use that formula once for your limited "Buy" signal and once for your limited "Sell" signal, the only difference between the 2 formulas being the value of X.
If these do not meet your criteria you may wish to request custom formula work at https://www.metastock.com/customer/resources/Formulas/CustomFormulaForm.aspx although there is a charge for this. Edited by user Wednesday, April 8, 2020 11:26:45 PM(UTC)
| Reason: Not specified
|