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

Notification

Icon
Error

Options
Go to last post Go to first unread
noumann  
#1 Posted : Tuesday, March 8, 2016 9:17:17 PM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

Hello everyone,

I’m trying to write this indicator:

BUY signal = the first time H>Ref(Mov(H,5,E),-1)

The system remains bullish even if for the next bars H< Ref(Mov(H,5,E),-1)

SELL signal = the first time L<Ref(Mov(L,5,E),-1

The system remains out until again H>Ref(Mov(H,5,E),-1)

Simultaneous BUY and SELL signals:

1.If in the previous bar the system is OUT, the buy signal takes  place even if  simultaneously  L<Ref(Mov(L,5,E),-1

2. If in the previous bar the system is IN ,the sell signal takes place even if simultaneously H>Ref(Mov(H,5,E),-1)

I’m trying to write the indicator in a binary way in order to have 1 if the system is bullish and 0 if the system is bearish.

Could you help me?

Thank you 

mstt  
#2 Posted : Wednesday, March 9, 2016 8:11:24 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi noumann Here's some indicator code that might help you but I don't think it solves all of the issues that need attention. What it does do is show you how to limit a signal to the first bar only (see the second BUY and SELL variables), and it shows you how to create a latch using the BUY and SELL signals. The "Init" variable allows the latch to capture the first BUY signal, which would otherwise be missed if the "Init" variable was not present. Hopefully this gives you a starting point. {<New Indicator>} BUY:= H>Ref(Mov(H,5,E),-1); SELL:=L<Ref(Mov(L,5,E),-1); BUY:=BUY*Alert(BUY=0,2); SELL:=SELL*Alert(SELL=0,2); Init:=Cum(IsDefined(BUY+SELL))=1; Bullish:=BarsSince(Init+BUY)<BarsSince(Init+SELL); {Display Plots} BUY+4; SELL+2; Bullish; Roy
noumann  
#3 Posted : Thursday, March 10, 2016 9:56:50 AM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

Roy, thank you for your reply and your suggestions.I'm trying to work about it but i can't solve all the possible issues.That is: 1.Go Long the first time H>Ref(Mov(H,5,E),-1) 2.Stay Long even if H<Ref(Mov(H,5,E),-1) but we need thet L>Ref(Mov(L,5,E),-1); 3.We go out the first time that L<Ref(Mov(L,5,E),-1; 4.We remain out until the first time that H>Ref(Mov(H,5,E),-1); 5.For each bar we can have only one signal,that is,if we are out and for the next bar we have simulteneously buy and sell signal,we go long. 6.Conversly,if we are in and for the next bar we have simulteneously buy and sell signal,we sell. Forgive my poor english.Thank you again
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.