- Joined
- 24 October 2005
- Posts
- 1,302
- Reactions
- 834
Using close price in relation to DEMA 250 this way references close price of stock and not foreign index.
SetForeign( ParamList("Index","^AORD | ^GSPC"), True, True );
X1 = DEMA(C, 250);
X2 = C > X1; //Open long stock positions
X3 = C < X1; //Open short stock positions
RestorePriceArrays(True);
Okay captain I will have to give it some breathing space. Thanks for your help.
Wish you an enjoyable long weekend.
StopLevel = 1 - Param("trailing stop %", 3, 0.1, 10, 0.1)/100;
Buy = Cross( MACD(), Signal() );
Sell = 0;
trailARRAY = Null;
trailstop = 0;
for( i = 1; i < BarCount; i++ )
{
if( trailstop == 0 AND Buy[ i ] )
{
trailstop = High[ i ] * stoplevel;
}
else Buy[ i ] = 0; // remove excess buy signals
if( trailstop > 0 AND Low[ i ] < trailstop )
{
Sell[ i ] = 1;
SellPrice[ i ] = trailstop;
trailstop = 0;
}
if( trailstop > 0 )
{
trailstop = Max( High[ i ] * stoplevel, trailstop );
trailARRAY[ i ] = trailstop;
}
}
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
Plot( Close,"Price",colorBlack,styleBar);
Plot( trailARRAY,"trailing stop level", colorRed );
ApplyStop(stopTypeTrailing, stopModePoint, 2*ATR(10), True, True );
PlotShapes( IIf(Sell==4, shapeHollowDownArrow, shapeNone), colorBlue, 0,H);//trailstop
Equity(flag=1, rangetype=0);
Hi
I have a applystop which works for backtesting I think but I want to view a stop on the chart. Thanks
Hi I am new to Amibroker and have a lot of learning to do on AFL. I have the following time based sell formula which uses closing prices:
Sell = 0; //no regular sell signals
ApplyStop( stopTypeNBar, stopModeBars, 4);
Can anyone help me to alter it to use open prices?
SellPrice = Open;
Also could anyone translate the first line for me into plain speech and explain what it does to the formula?
Anyone know how I can make it so the value of a line is drawn on the line on the actual chart rather than in the axis?
Also, if its possible to create a scan to determine how many times price touches a certain line?
How about this -
In english:
Sell when -
1. the number of bars since purchase are greater or equal to the hold period
AND
2. the percentage change of the current close compared to the 1st close since purchase is < the minimum required increase
In psuedo amibroker:
Sell when:
Sell = BarsSince(Buy) >= HoldPeriod AND (C - Ref(C,- HoldPeriod))/ Ref(C,- HoldPeriod) < Min%Increase (e.g. +5%);
Cheers
S
Buy = Cross(MACD(), Signal());
Entry = ValueWhen(Buy, O);
Rule1 = C < 1.10 * Entry;
Rule2 = SetOption("HoldMinBars", 10);
Exit = IIf(Rule1, 1, 0);
Sell = IIf(Rule1 = Rule2, ApplyStop(stopTypeLoss, stopModePercent, Exit, 1, True), 0) OR Cross(Signal(), MACD());
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?