hi guys,
anyone have the code or knows how to code a volatility-based stop for multicharts?
code debug
Hello, I have tried to convert the VT-Trader codes into EasyLanguage, but somehow it is not plotting as what it supposed to be comparing with VT's Chart that i attached above.
Could anyone help to identify what I did wrong in the code? I have attached a screen shot of the plotted indicator in MC, it doesn't looks right, the red line is the trailing stop indicator. Thanks!
Here is the code in EasyLanguage:
Could anyone help to identify what I did wrong in the code? I have attached a screen shot of the plotted indicator in MC, it doesn't looks right, the red line is the trailing stop indicator. Thanks!
Here is the code in EasyLanguage:
Code: Select all
inputs:
ATRLength( 14 ), SmthLength( 14 ), Factor( 2.824 );
variables:
DeltaStop( 0 ), TrStop( 0 );
DeltaStop = Factor * XAverage(AvgTrueRange( ATRLength ), SmthLength);
If Close = TrStop[1] then
TrStop = TrStop[1];
If Close[1] <= TrStop[1] and Close < TrStop[1] then
TrStop = minlist(TrStop[1], (Close+DeltaStop));
If Close[1] >= TrStop[1] and Close > TrStop[1] then
TrStop = maxlist(TrStop[1], (Close-DeltaStop));
If Close > TrStop[1] then
TrStop = Close - DeltaStop
else TrStop = Close + DeltaStop;
Plot1(TrStop, "Trailing Stop");
Last edited by liang323 on 19 May 2008, edited 2 times in total.
Try this out:
Code: Select all
inputs:
ATRLength( 14 ), SmthLength( 14 ), Factor( 2.824 );
variables:
DeltaStop( 0 ), TrStop( 0 );
DeltaStop = Factor * XAverage(AvgTrueRange( ATRLength ), SmthLength);
If Close = TrStop[1] then
TrStop = TrStop[1]
else
If Close[1] <= TrStop[1] and Close < TrStop[1] then
TrStop = minlist(TrStop[1], (Close+DeltaStop))
else
If Close[1] >= TrStop[1] and Close > TrStop[1] then
TrStop = maxlist(TrStop[1], (Close-DeltaStop))
else
If Close > TrStop[1] then
TrStop = Close - DeltaStop
else
TrStop = Close + DeltaStop;
Plot1(TrStop, "TrailingStop");