- Joined
- 30 June 2007
- Posts
- 7,200
- Reactions
- 1,226
Thanks Gringotts Bank, I haven't heard of SAR before, will check it out.
I take it there's no simple way to adjust the stoploss precent on the fly then?
JJZ
Is there an easy way to adjust a stop based on holding time?
For example, purchase a stock with a 15% stop loss:
ApplyStop( stopTypeLoss, stopModePercent, 15, 2, 0, 0 );
Then after 30 days reduce it to:
ApplyStop( stopTypeLoss, stopModePercent, 10, 2, 0, 0 );
Thanks
JJZ
periods = 10;
for (i = 0 ; i < periods ; i++);
{
iif((Ref(Close,-i) > 1), Count++, Count--);
}
Plot( Count, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
Count = 0
Hi All,
I have been trying to learn Amibroker code independently without asking dumb questions here however I have never been able to work out how to create counters in loops. Can anyone assist?
An example would be:
Code:periods = 10; for (i = 0 ; i < periods ; i++); { iif((Ref(Close,-i) > 1), Count++, Count--); } Plot( Count, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
This comes up with "error 29: Variable 'count' used without having been intitialize."
If I add the code
Code:Count = 0
Then count is always equal to 0 and does not give me the desired outcome which in this case would be to add and plot the number of times the close is above 1 in the past 10 bars.
threshold = 1;
periods = 10;
count = Sum( (C > threshold) - (C < threshold), periods );
Hi All,
I have been trying to learn Amibroker code independently without asking dumb questions here however I have never been able to work out how to create counters in loops. Can anyone assist?
periods = 10;
threshold = 1;
for ( i = 0; i < periods-1 && i < BarCount; i++ )
cnt[i] = Null;
for( i = periods-1; i < BarCount; i++ ) {
count = 0;
for( j = 0; j < periods; j++ ) {
if( C[i-j] > threshold )
count++;
else
count--;
}
cnt[i] = count;
}
Plot( cnt, "Loop (array)", colorYellow, ParamStyle("Style") );
Plot( count, "Loop (last element)", colorYellow, styleDashed );
Plot( Sum( (C > threshold) - (C < threshold), periods ), "Sum() (array)", ColorOrange, ParamStyle("Style") );
Plot( LastValue(Sum( (C > threshold) - (C < threshold), periods )), "Sum() (last element)", ColorOrange, styleDashed );
//Plot( Sum( (C > threshold), periods ), _DEFAULT_NAME(), ColorGreen, ParamStyle("Style") );
//Plot( Sum( (C < threshold), periods ), _DEFAULT_NAME(), colorRed, ParamStyle("Style") );
Here is a goody. Where do I start in order to create a present time DOM histogram. Further clarity is -- an histogram of the real time market depth in number of shares or contracts. Politeness please.
Here is a goody. Where do I start in order to create a present time DOM histogram. Further clarity is -- an histogram of the real time market depth in number of shares or contracts. Politeness please.
Not market depth as in number of shares or contracts in queue to at least 5 levels.Great idea.
Maybe start with GetRTData().
There's a Bid Vs Ask Dashboard in the library.
Yes I think Ami. will need this, that and the other to get the data but I asked the question anyway. I see Ninjacator has one.Don't reinvent the wheel, take a free trial of Iguana2
Hey guys need some help with 'param' in amibroker.
Range Period=Param("Range Period" , 100, 20, 200, 1);
Max Range %=Param("Max Range %" , 10, 1, 20, 1);
Am i doing it right? i want Range period default value at 100 days, minimum and maximum value of 20 to 200. Same goes for Max range%, at 10% with range of 1 to 20%.
Also what "step - defines minimum increase of the parameter via slider in the Parameters dialog"? from amibroker online guide.
Cheers for any answers.
I have been looking for an answer to what is going to be a simple question for those who know Amibroker well.
I am trying to code a simple proof-of-concept backtest with two exits. I am using EOD data, and I'll describe this long-only for simplicity.
So, given that I am in a long position:
The first exit is a stop loss. I want to exit immediately if the low of the day crosses the low of the previous day
The second exit will exit at the close of the third day, assuming the stop loss has not been hit.
I can code these exits separately, but what is tripping me up when I try to combine them is the fact that they have different SellPrice requirements.
This works:
SetTradeDelays(0 ,0 ,0 ,0 ); // no delays, entries and exits trigger today
x = Ref(L,-1 ); // low of prev day for stop loss exit
SellPrice = x;
Sell=Cross(x,Low);
And so does this
SetTradeDelays(0 ,0 ,0 ,0 ); // no delays, entries and exits trigger today
SellPrice = Close;
Sell = BarsSince(Buy)==2;
But how do I get them to work properly together?
Any help appreciated, thanks.
Untested, but should work ok.
SetStopPrecedence( stopTypeNBar, stopTypeProfit, stopTypeTrailing, stoptypeloss );//good to include
Sellprice = ref(L,-1);
Sell = Sellprice>=L and Sellprice<=H;
Applystop(stoptypenbar,stopmodebars,3);
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?