logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
htfan123  
#1 Posted : Monday, January 10, 2011 12:32:58 PM(UTC)
htfan123

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/4/2011(UTC)
Posts: 2

Hi, I am building an Expert Advisor indicator that generates buy and sell signals. Basically the system should remain a BUY until the SELL condition is met. I am having trouble with this last part. I basically created two indicators, one for the BUY conditions and one for the SELL conditions. What I don't know how to do is to write the code to tell the system that if a BUY condition has been met, it should not generate an additional signal unless there was a SELL signal generated. For example, let's say that the BUY signal is IF(C>mov(C,20,S) AND RSI(C,14)>50,1,0) and the BUY conditition is =1 And the sell condition is If( C < mov(C,20,S),1,0) = 1 then SELL I basically want that the expert advisor to generate only one SIGNAL of BUY AND wait until a new SELL signal is generated to show again (if conditions are met), a new BUY signal. Now what I get is basically a lot of BUY signals even thought a SELL signal was not generated. I was able to reduce the clutter a bit with this formula for the BUY signal in the Expert Advisor Fml("BUY SIGNAL") = 1 AND Ref(Fml("BUY SIGNAL"),-1) = 0 With this I at least removed BUY Signals if the previous one was already a BUY. I hope this was not too confusing... Thanks!
johnl  
#2 Posted : Monday, January 10, 2011 6:48:00 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

Could you use BarsSince() to test which indicator was previous to the current signal?

htfan123  
#3 Posted : Tuesday, January 11, 2011 6:07:00 AM(UTC)
htfan123

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/4/2011(UTC)
Posts: 2

Johnl, Thanks! That is exactly what I did, using some of the language used in existing indicators. Best,
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.