| 
Rank: Newbie
 Groups: Registered Users, SubscribersJoined: 9/29/2016(UTC)
 Posts: 5
 
 Thanks: 1 times
 | 
            
	      
                  I'm trying to trigger a buy signal with:   Mov(C,5,E) > PREV   and the sell signal with:   Mov(C,5,E) < PREV     The idea was to buy when the moving avarage is rising and sell when falling. But the code doesn't work. What's the proper way?                     | 
    | 
             | 
            
         | 
    |  | 
        
        
        
            
        
            
            
    | 
Rank: Advanced Member
 Groups: Registered, Registered Users, SubscribersJoined: 7/25/2005(UTC)
 Posts: 1,042
 
 Was thanked: 57 time(s) in 54 post(s)
 | 
            
	      
                Hi tekken
Try these Buy and Sell signals. PREV is inappropriate to what you're trying to do. To explain my code for Buy, the current moving average is tested for higher than the previous bars moving average, and for Sell the current moving average is tested for lower than the previous bars moving average. The use of an Alert() function limits the signal to just one bar, thus eliminating a multiple succession.of unwanted extra signals
 {Buy}
Buy:=Mov(C,5,E) > Ref(Mov(C,5,E),-1) ;
Buy:=Buy AND Alert(Buy=0,2);
Buy;
 {Sell}
Sell:=Mov(C,5,E) < Ref(Mov(C,5,E),-1) ;
Sell:=Sell AND Alert(Sell=0,2);
Sell;
Hipe this helps.
Roy | 
    | 
              1 user thanked mstt for this useful post. |  | 
    |  | 
        
        
        
    
        
            
            
    | 
Rank: Newbie
 Groups: Registered Users, SubscribersJoined: 9/29/2016(UTC)
 Posts: 5
 
 Thanks: 1 times
 | 
            
	      
                Hi Roy, that code worked just fine.
Explanation was also helpful, thanks! | 
    | 
             | 
            
         | 
    |  | 
        
        
        
    
                           
    
| 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.