Hi all,
I need a Percent Trailing Stop not based on buy signal, but with a manual value (Parameter). It shoul trailig on the high for long and low for short positions I tried to write the code, but it didn't work:
// -----------------------------------------------
StopLevel = Param("trailing stop %", 1, 0.01, 50, 0.01 );
Entry = Param("Entry", 1, 0.01, 1000, 0.01);
SetTradeDelays(0,0,0,0);
ApplyStop( stopTypeTrailing, stopModePercent, StopLevel, True );
Equity( 1, 0 );
InTrade = Flip( Buy, Sell );
SetOption("EveryBarNullCheck", True );
stopline = HighestSince( Entry, High ) * ( 1 - 0.01 * StopLevel );
Plot( Close,"Price",colorBlack,styleBar);
Plot( stopline, "trailing stop line", colorRed );
// -----------------------------------------------
What I need is: I give a manual price (ie 300,00) and Amibroker plots a trailing stop % (ie 3%) for long or shortl.
Can someone help me?
Thanks!
Jacare
---------------------------------------------
Hi,
I did some progess, it works more or less for long position, but not yet for the short ones:
_SECTION_BEGIN("@Trailing 03");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
StopLevel = Param("Trailing Stop %", 3, 0.01, 50, 0.01 );
SetTradeDelays(0,0,0,0);
Buy = Cross( MACD(), Signal() );
Sell = 0;
ApplyStop( stopTypeTrailing, stopModePercent, StopLevel, True );
Equity( 1, 0 );
InTrade = Flip( Buy, Sell );
SetOption("EveryBarNullCheck", True );
stopline = HighestSince( Buy, low ) * ( 1 - 0.01 * StopLevel );
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
Plot( Close,"Price",colorBlack,styleBar);
Plot( stopline, "trailing stop line", ParamColor( "Color", colorRed ), ParamStyle("Style") );
_SECTION_END();
// ------------------------------------
Any help??
Thanks,
Jacare
I need a Percent Trailing Stop not based on buy signal, but with a manual value (Parameter). It shoul trailig on the high for long and low for short positions I tried to write the code, but it didn't work:
// -----------------------------------------------
StopLevel = Param("trailing stop %", 1, 0.01, 50, 0.01 );
Entry = Param("Entry", 1, 0.01, 1000, 0.01);
SetTradeDelays(0,0,0,0);
ApplyStop( stopTypeTrailing, stopModePercent, StopLevel, True );
Equity( 1, 0 );
InTrade = Flip( Buy, Sell );
SetOption("EveryBarNullCheck", True );
stopline = HighestSince( Entry, High ) * ( 1 - 0.01 * StopLevel );
Plot( Close,"Price",colorBlack,styleBar);
Plot( stopline, "trailing stop line", colorRed );
// -----------------------------------------------
What I need is: I give a manual price (ie 300,00) and Amibroker plots a trailing stop % (ie 3%) for long or shortl.
Can someone help me?
Thanks!
Jacare
---------------------------------------------
Hi,
I did some progess, it works more or less for long position, but not yet for the short ones:
_SECTION_BEGIN("@Trailing 03");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
StopLevel = Param("Trailing Stop %", 3, 0.01, 50, 0.01 );
SetTradeDelays(0,0,0,0);
Buy = Cross( MACD(), Signal() );
Sell = 0;
ApplyStop( stopTypeTrailing, stopModePercent, StopLevel, True );
Equity( 1, 0 );
InTrade = Flip( Buy, Sell );
SetOption("EveryBarNullCheck", True );
stopline = HighestSince( Buy, low ) * ( 1 - 0.01 * StopLevel );
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
Plot( Close,"Price",colorBlack,styleBar);
Plot( stopline, "trailing stop line", ParamColor( "Color", colorRed ), ParamStyle("Style") );
_SECTION_END();
// ------------------------------------
Any help??
Thanks,
Jacare
Last edited: