[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Help Needed with writing MS Code



PureBytes Links

Trading Reference Links

Hello All,

I have some code for a trailing stop which I have written in another 
language for another of my software applications. 

However, I am now trying to convert this code to MS but am having 
some serious difficulties :-(  

The code:

Factor= AverageTrueRange[10](close)*2.5

BuyStop = CLOSE - Factor

IF BuyStop > BuyStop[1] THEN
	
	IF CLOSE > CLOSE[1] THEN
		
		BuyStop = CLOSE - Factor
		
	ELSE
		
		BuyStop = BuyStop[1]
		
	ENDIF
	
ELSE
	
	IF CLOSE > BuyStop[1] THEN
		
		BuyStop = BuyStop[1]
		
	ELSE
		
		BuyStop = CLOSE - Factor
			
	ENDIF
	
ENDIF

RETURN	BuyStop


Basically, what I want to achieve is as follows:

- As the price closes higher the stop moves up and remains at "close-
AverageTrueRange[10](close)*2.5" distance below current bar.
- If the price fails to make new highs but remains above yesterdays 
stop level, then the stop moves horizontal for the next period ie. 
Remains at same level as yesterday
- Once the closing price drops below the current stop level, the stop 
resets itself at the next bar to "close-AverageTrueRange[10](close)
*2.5"


Any Help much appreciated....



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/