لتبليغ الإدارة عن موضوع أو رد مخالف يرجى الضغط على هذه الأيقونة الموجودة على يمين المشاركة لتطبيق قوانين المنتدى


سجل من هنا
العودة   هوامير البورصة السعودية > >
التسجيل اضف الموقع لمفضلتك بحث جوجل فوركس هوامير التقويم البحث مشاركات اليوم اجعل كافة الأقسام مقروءة
 

حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

منتدى التحليل الفني والاساسي



إضافة رد
 
أدوات الموضوع انواع عرض الموضوع
قديم 01-06-2014, 11:59 AM  
#1
أبوعبيّد
عضو موقوف
 
تاريخ التسجيل: Jun 2008
العمر: 21
المشاركات: 10,066

حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

السلام عليكم ورحمة الله وبركاته
ملف وورد لـ موضوع أستاذنا " علمتني الايـام "
هنـــا
==
لتحميل الملف :

==
أخوكم أبوعبيّد
أبوعبيّد غير متواجد حالياً   رد مع اقتباس
قديم 01-06-2014, 09:47 PM   #2
تراحــــــيب
عضو هوامير المميز
 
تاريخ التسجيل: Dec 2005
المشاركات: 7,447

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

تراحــــــيب غير متواجد حالياً   رد مع اقتباس
قديم 01-06-2014, 10:54 PM   #3
Stock112
عضو هوامير المميز
 
تاريخ التسجيل: Jul 2006
المشاركات: 52

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

جهد تشكر عليه بارك الله فيك
Stock112 غير متواجد حالياً   رد مع اقتباس
قديم 02-06-2014, 07:55 AM   #4
faisalnet
عضو هوامير المميز
 
تاريخ التسجيل: Mar 2010
المشاركات: 1,983

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

الله يوفقك و يجزاك خير ..
faisalnet غير متواجد حالياً   رد مع اقتباس
قديم 02-06-2014, 09:38 PM   #5
كاركتير
عضو هوامير المميز
 
تاريخ التسجيل: May 2011
المشاركات: 187

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

بارك الله فيك
كاركتير غير متواجد حالياً   رد مع اقتباس
قديم 02-06-2014, 10:00 PM   #6
أبوعبيّد
عضو موقوف
 
تاريخ التسجيل: Jun 2008
العمر: 21
المشاركات: 10,066

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

اقتباس:
المشاركة الأصلية كتبت بواسطة TRAHEEB مشاهدة المشاركة
حيـاك الله ياتراحيب ..
شاكر لك تـواجدك يالغااالي ..
أبوعبيّد غير متواجد حالياً   رد مع اقتباس
قديم 03-06-2014, 10:55 PM   #7
عزيز77
كاتب قدير
 
تاريخ التسجيل: Jul 2006
المشاركات: 9,909

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

جزاك الله كل خير..
الموضوع قيم ومفيد

المعادلات...مرتبطة برسيفرات...قديمة...وانتهت الصلاحية..

هل اجد عندك ...معادلات....مؤشر الذهب وراحة البال...؟؟؟بحثت عنه لم اجده..
عزيز77 غير متواجد حالياً   رد مع اقتباس
قديم 03-06-2014, 11:09 PM   #8
الرأي الأول
عضو هوامير المميز
 
تاريخ التسجيل: Sep 2011
المشاركات: 12,390

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

ياليت تسعفنا بافضل 3 معادلات ذهبيه يعتمد عليها ولها نتائج ممتازه

لللايمي بروكر
الرأي الأول غير متواجد حالياً   رد مع اقتباس
قديم 04-06-2014, 11:57 AM   #9
بندر بن عبدالله
عضو هوامير المميز
 
تاريخ التسجيل: Jan 2006
المشاركات: 227

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

اقتباس:
المشاركة الأصلية كتبت بواسطة عزيز77 مشاهدة المشاركة
جزاك الله كل خير..
الموضوع قيم ومفيد

المعادلات...مرتبطة برسيفرات...قديمة...وانتهت الصلاحية..

هل اجد عندك ...معادلات....مؤشر الذهب وراحة البال...؟؟؟بحثت عنه لم اجده..
اتمنى انه هذا طلبك اخوي عزيز
وجدتة مع مجموعة مؤشرات ولم اتعامل معه ...

// **************************
// BEING EXPLORATION CODE
// **************************

// -- what will be our lookback range for the hh and ll?
nBars = Param("Number of bars", 12, 5, 40);
bTrace = Param("Include trace output", 1, 0, 1);
nNoPivsInSetup = Param("No. Pivs in Setup", 4, 3, 4, 1);
bShowTCZ = Param("Show TCZ", 1, 0, 1);
nMinBarsBtwPivs = Param("Min. number of bars btw. pivots", 1, 1, 10, 1);
nMinPctBtwPivs = Param("Min. percent diff. btw. pivots", .05, .04, .2, .01);
bLastBarCanBePiv = Param("Last bar can be a pivot", 1, 0, 1);
retrcTolerance = .01;
tczTolerance = .005;
nNumBarsToScan = 120;

// -- added from exploration version 20040204
nExploreBarIdx = 0;
nExploreDate = 0;
nCurDateNum = 0;
DN = DateNum();
DT = DateTime();

// -- key exploration variables
bTCZLong = False;
bTCZShort = False;
nAnchorPivIdx = 0;

ADX8 = ADX(8);

// 1 - INDICATOR, 2 - COMMENTARY, 3 - SCAN,
// 4 - EXPLORATION, 5 - BACKTEST / Optimize
if(Status("action")==1) {
bDraw = True;
bUseLastVis = Param("Use last visible bar", 1, 0, 1);
} else {
bDraw = False;
bUseLastVis = False;
bTrace = False;
nExploreDate = Status("rangetodate");
for (i=LastValue(BarIndex());i>=0;i--) {
nCurDateNum = DN[i];
if (nCurDateNum == nExploreDate) {
nExploreBarIdx = i;
}
}
// -- if(Status("action")==1...
}

GraphXSpace=7;

// -- basic candle chart
// -- if this appears inside if , strange
// drawing results!
PlotOHLC(Open, High, Low, Close,
"BIdx = " + BarIndex() +
"\n" + "O = " + O + "\n"+"H = "+ H + "\n"+"L = " + L
+ "\n"+"C ",
colorBlack, styleCandle);

if (bDraw) {
Plot(MA(C, 21), "21 bar MA", colorAqua,
styleLine+styleNoRescale+styleNoLabel);
Plot(MA(C, 55), "55 bar MA", colorGreen,
styleLine+styleNoRescale+styleNoLabel);
//Plot(MA(C, 233), "233 bar MA", colorDarkRed,
// styleLine+styleNoRescale+styleNoLabel);
}

// -- Create 0-initialized arrays the size of barcount
aHPivs = H - H;
aLPivs = L - L;
aHPivHighs = H - H;
aLPivLows = L - L;
aHPivIdxs = H - H;
aLPivIdxs = L - L;
aAddedHPivs = H - H;
aAddedLPivs = L - L;
aLegVol = H - H;
aRetrcVol = H - H;

nHPivs = 0;
nLPivs = 0;

lastHPIdx = 0;
lastLPIdx = 0;
lastHPH = 0;
lastLPL = 0;
curPivBarIdx = 0;

// -- looking back from the current bar, how many bars
// back were the hhv and llv values of the previous
// n bars, etc.?
aHHVBars = HHVBars(H, nBars);
aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);
aLLV = LLV(L, nBars);

// -- Initialize value of curTrend
nLastVisBar = LastValue(
Highest(IIf(Status("barvisible"), BarIndex(), 0)));

curBar = IIf(nlastVisBar > 0 AND bUseLastVis, nlastVisBar,
IIf(Status("action")==4 AND nExploreBarIdx > 0, nExploreBarIdx,
LastValue(BarIndex())));

curTrend = "";
if (aLLVBars[curBar] < aHHVBars[curBar])
curTrend = "D";
else
curTrend = "U";

// -- Loop through bars. Search for
// entirely array-based approach
// in version
/* *******************
Find main pivots
******************* */

// -- Make sure there are enough bars!
if (curBar >= nNumBarsToScan) {
for (i=0; i<nNumBarsToScan; i++) {

// -- value of curBar dependent on two parameters
curBar = IIf(nlastVisBar > 0 AND bUseLastVis,
nlastVisBar-i,
IIf(Status("action")==4 AND nExploreBarIdx > 0,
nExploreBarIdx-i,
LastValue(BarIndex())-i));

// -- Have we identified a pivot? If trend is down...
if (aLLVBars[curBar] < aHHVBars[curBar]) {

// ... and had been up, this is a trend change
if (curTrend == "U") {
curTrend = "D";
// -- Capture pivot information
curPivBarIdx = curBar - aLLVBars[curBar];
aLPivs[curPivBarIdx] = 1;
aLPivLows[nLPivs] = L[curPivBarIdx];
aLPivIdxs[nLPivs] = curPivBarIdx;
nLPivs++;
}
// -- or current trend is up
} else {
if (curTrend == "D") {
curTrend = "U";
curPivBarIdx = curBar - aHHVBars[curBar];
aHPivs[curPivBarIdx] = 1;
aHPivHighs[nHPivs] = H[curPivBarIdx];
aHPivIdxs[nHPivs] = curPivBarIdx;
nHPivs++;
}
// -- If curTrend is up...else...
}

// -- loop through bars
}
}
/* *******************
Found main pivots
******************* */

/* *************************
Finding missed pivot(s)
************************* */

// -- Start at last bar. Reestablish curBar
curBar =
IIf(nlastVisBar > 0 AND bUseLastVis,
nlastVisBar,
IIf(Status("action")==4 AND nExploreBarIdx > 0,
nExploreBarIdx,
LastValue(BarIndex()))
);

// -- Make sure I found at least two of each above.
if (nHPivs >= 2 AND nLPivs >= 2) {

lastLPIdx = aLPivIdxs[0];
lastLPL = aLPivLows[0];

lastHPIdx = aHPivIdxs[0];
lastHPH = aHPivHighs[0];

nLastHOrLPivIdx = Max(lastLPIdx, lastHPIdx);

nAddPivsRng = curBar - nLastHOrLPivIdx;
aLLVAfterLastPiv = LLV(L, nAddPivsRng);
nLLVAfterLastPiv = aLLVAfterLastPiv[curBar];
aLLVIdxAfterLastPiv = LLVBars(L, nAddPivsRng);
nLLVIdxAfterLastPiv = curBar - aLLVIdxAfterLastPiv[curBar];
aHHVAfterLastPiv = HHV(H, nAddPivsRng);
nHHVAfterLastPiv = aHHVAfterLastPiv[curBar];
aHHVIdxAfterLastPiv = HHVBars(H, nAddPivsRng);
nHHVIdxAfterLastPiv = curBar - aHHVIdxAfterLastPiv[curBar];

// -- Later want to add last high pivot only if
// not in buy mode from last and still in trade

/*
Note - I'm only interested in adding pivots if I'm in
a higher-highs or lower-lows scenario
*/


// -- OK, let's start where the last high pivot occurs after the
// last Low pivot
if (lastHPIdx > lastLPIdx) {

/* There are at least two possibilities here. One is that
the previous high was higher, indicating that this is a
possible short retracement or one in the making.
The other is that the previous high was lower, indicating
that this is a possible long retracement in the working.
However, both depend on opposing pivots. E.g., if I find
higher highs, what if I have lower lows?

If the highs are descending, then I can consider:
- a lower low, and leave it at that
- a higher high and higher low
- a lower low and another lower high
*/
if (aHPivHighs[0] < aHPivHighs[1]) {

if (nLLVAfterLastPiv < aLPivLows[0] AND
(nLLVIdxAfterLastPiv - lastHPIdx - 1) >= nMinBarsBtwPivs
AND nLLVIdxAfterLastPiv != curBar ) {

// -- OK, we'll add this as a pivot.
// Mark it for plotting...
aLPivs[nLLVIdxAfterLastPiv] = 1;
aAddedLPivs[nLLVIdxAfterLastPiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nLPivs; j++) {
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
}
aLPivLows[0] = nLLVAfterLastPiv;
aLPivIdxs[0] = nLLVIdxAfterLastPiv;
nLPivs++;

// -- Test whether to add piv given last piv is high
// AND we have lower highs
}

// -- Here, the last piv is a high piv, and we have
// higher-highs. The most likely addition is a
// Low piv that is a retracement.
} else {

if (nLLVAfterLastPiv > aLPivLows[0] AND
(nLLVIdxAfterLastPiv - lastHPIdx - 1) >= nMinBarsBtwPivs
AND nLLVIdxAfterLastPiv != curBar ) {

// -- OK, we'll add this as a pivot.
// Mark it for plotting...
aLPivs[nLLVIdxAfterLastPiv] = 1;
aAddedLPivs[nLLVIdxAfterLastPiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nLPivs; j++) {
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
}
aLPivLows[0] = nLLVAfterLastPiv;
aLPivIdxs[0] = nLLVIdxAfterLastPiv;
nLPivs++;

// -- Test whether to add piv given last piv is high
// AND we have lower highs
}
// -- The last piv is a high and we have higher highs
// OR lower highs
}

/* ****************************************************************
Still finding missed pivot(s). Here, the last piv is a low piv.
**************************************************************** */
} else {

// -- First case, lower highs
if (aHPivHighs[0] < aHPivHighs[1]) {

if (nHHVAfterLastPiv < aHPivHighs[0] AND
(nHHVIdxAfterLastPiv - lastLPIdx - 1) >= nMinBarsBtwPivs
AND nHHVIdxAfterLastPiv != curBar ) {

// -- OK, we'll add this as a pivot.
// Mark that for plotting
aHPivs[nHHVIdxAfterLastPiv] = 1;
aAddedHPivs[nHHVIdxAfterLastPiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nHPivs; j++) {
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nhPivs-(j+1)];
}
aHPivHighs[0] = nHHVAfterLastPiv;
aHPivIdxs[0] = nHHVIdxAfterLastPiv;
nHPivs++;

// -- Test whether to add piv given last piv is high
// AND we have lower highs
}

// -- Second case when last piv is a low piv, higher highs
// Most likely addition is high piv that is a retracement.
// Considering adding a high piv as long as it is higher
} else {

// -- Where I have higher highs,
if (nHHVAfterLastPiv > aHPivHighs[0] AND
(nHHVIdxAfterLastPiv - lastLPIdx - 1) >= nMinBarsBtwPivs
AND nHHVIdxAfterLastPiv != curBar ) {

// -- OK, we'll add this as a pivot.
// Mark it for plotting...
aHPivs[nHHVIdxAfterLastPiv] = 1;
aAddedHPivs[nHHVIdxAfterLastPiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nHPivs; j++) {
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nhPivs-(j+1)];
}
aHPivHighs[0] = nHHVAfterLastPiv;
aHPivIdxs[0] = nHHVIdxAfterLastPiv;
nHPivs++;

// -- Test whether to add piv given last piv is high
// AND we have lower highs
}

}

}

// -- If there are at least two of each
}

/* ****************************************
// -- Done with finding pivots
***************************************** */

if (bDraw) {

// -- OK, let's plot the pivots using arrows
PlotShapes(
IIf(aHPivs==1, shapeDownArrow, shapeNone),
colorRed, 0, High, Offset=-15);
PlotShapes(
IIf(aAddedHPivs==1, shapeDownArrow, shapeNone),
colorDarkRed, 0, High, Offset=-15);
PlotShapes(
IIf(aLPivs==1, shapeUpArrow , shapeNone),
colorGreen, 0, Low, Offset=-15);
PlotShapes(
IIf(aAddedLPivs==1, shapeUpArrow , shapeNone),
colorDarkGreen, 0, Low, Offset=-15);
}

/* ****************************************
// -- Done with discovering and plotting pivots
***************************************** */

// -- I'm going to want to look for possible retracement
risk = 0;
profInc = 0;
nLeg0Pts = 0;
nLeg0Bars = 0;
nLeg0Vol = 0;
nLeg1Pts = 0;
nLeg1Bars = 0;
nLeg1Vol = 0;
nLegBarsDiff = 0;
nRtrc0Pts = 0;
nRtrc0Bars = 0;
nRtrc0Vol = 0;
nRtrc1Pts = 0;
nRtrc1Bars = 0;
nRtrc1Vol = 0;

minRtrc = 0;
maxRtrc = 0;
minLine = 0;
maxLine = 0;
triggerLine = 0;
firstProfitLine = 0;
triggerInc = 0;
triggerPrc = 0;
firstProfitPrc = 0;
retrcPrc = 0;
retrcBar = 0;
retrcBarIdx = 0;
retrcRng = 0;
aRetrcPrc = H-H;
aRetrcPrcBars = H-H;
aRetrcClose = C;
retrcClose = 0;

// -- Do TCZ calcs. Arrangement of pivs very specific
// for this setup.
if (nHPivs >= 2 AND
nLPivs >=2 AND
aHPivHighs[0] > aHPivHighs[1] AND
aLPivLows[0] > aLPivLows[1]) {

tcz500 =
(aHPivHighs[0] -
(.5 * (aHPivHighs[0] - aLPivLows[1])));

tcz618 =
(aHPivHighs[0] -
(.618 * (aHPivHighs[0] - aLPivLows[1])));

tcz786 =
(aHPivHighs[0] -
(.786 * (aHPivHighs[0] - aLPivLows[0])));

retrcRng = curBar - aHPivIdxs[0];
aRetrcPrc = LLV(L, retrcRng);
retrcPrc = aRetrcPrc[curBar];
aRetrcPrcBars = LLVBars(L, retrcRng);
retrcBarIdx = curBar - aRetrcPrcBars[curBar];
retrcClose = aRetrcClose[retrcBarIdx];

// -- bTCZLong setup?
bTCZLong = (

// -- Are retracement levels arranged in
// tcz order?
tcz500 >= (tcz786 * (1 - tczTolerance))
AND
// .681 is below .786 for long setups
tcz618 <= (tcz786 * (1 + tczTolerance))
AND

// -- Is the low in the tcz range
// -- Is the close >= low of tcz range
// and low <= high of tcz range
retrcClose >= ((1 - retrcTolerance) * tcz618)
AND
retrcPrc <= ((1 + retrcTolerance) * tcz500)
);

// -- risk would be high of signal bar minus low of zone
//risk = 0;

// -- lower highs and lower lows
} else if (nHPivs >= 2 AND nLPivs >=2
AND aHPivHighs[0] < aHPivHighs[1]
AND aLPivLows[0] < aLPivLows[1]) {

tcz500 =
(aHPivHighs[1] -
(.5 * (aHPivHighs[1] - aLPivLows[0])));

tcz618 =
(aHPivHighs[0] -
(.618 * (aHPivHighs[1] - aLPivLows[0])));

tcz786 =
(aHPivHighs[0] -
(.786 * (aHPivHighs[0] - aLPivLows[0])));

retrcRng = curBar - aLPivIdxs[0];
aRetrcPrc = HHV(H, retrcRng);
retrcPrc = aRetrcPrc[curBar];
aRetrcPrcBars = HHVBars(H, retrcRng);
retrcBarIdx = curBar - aRetrcPrcBars[curBar];
retrcClose = aRetrcClose[retrcBarIdx];

bTCZShort = (
// -- Are retracement levels arranged in
// tcz order?

// .500 is below .786 for short setups
tcz500 <= (tcz786 * (1 + tczTolerance))
AND
// .681 is above .786 for short setups
tcz618 >= (tcz786 * (1 - tczTolerance))
AND

// -- Is the close <= high of tcz range
// and high >= low of tcz range
retrcClose <= ((1 + retrcTolerance) * tcz618)
AND
retrcPrc >= ((1 - retrcTolerance) * tcz500)
);

// -- Risk would be top of zone - low of signal bar
//risk = 0;
}

Filter = (bTCZShort OR bTCZLong);
AddColumn(C, "Close");
AddColumn(IIf(bTCZLong, 76, 83), "L/S", formatChar);

// **************************
// END EXPLORATION CODE
// **************************

// **************************
// BEGIN INDICATOR CODE
// **************************

// -- what will be our lookback range for the hh and ll?
nBars = Param("Number of bars", 12, 5, 40);
bTrace = Param("Include trace output", 1, 0, 1);
nNoPivsInSetup = Param("No. Pivs in Setup", 4, 3, 4, 1);
bShowTCZ = Param("Show TCZ", 1, 0, 1);
nMinBarsBtwPivs = Param("Min. number of bars btw. pivots", 1, 1, 10, 1);
nMinPctBtwPivs = Param("Min. percent diff. btw. pivots", .05, .04, .2, .01);
bLastBarCanBePiv = Param("Last bar can be a pivot", 1, 0, 1);
retrcTolerance = .01;
tczTolerance = .005;
nNumBarsToScan = 120;

// -- added from exploration version 20040204
nExploreBarIdx = 0;
nExploreDate = 0;
nCurDateNum = 0;
DN = DateNum();
DT = DateTime();

// -- key exploration variables
bTCZLong = False;
bTCZShort = False;
nAnchorPivIdx = 0;

ADX8 = ADX(8);

// 1 - INDICATOR, 2 - COMMENTARY, 3 - SCAN,
// 4 - EXPLORATION, 5 - BACKTEST / Optimize
if(Status("action")==1) {
bDraw = True;
bUseLastVis = Param("Use last visible bar", 1, 0, 1);
} else {
bDraw = False;
bUseLastVis = False;
bTrace = False;
nExploreDate = Status("rangetodate");
for (i=LastValue(BarIndex());i>=0;i--) {
nCurDateNum = DN[i];
if (nCurDateNum == nExploreDate) {
nExploreBarIdx = i;
}
}
// -- if(Status("action")==1...
}

GraphXSpace=7;

// -- basic candle chart
// -- if this appears inside if , strange
// drawing results!
PlotOHLC(Open, High, Low, Close,
"BIdx = " + BarIndex() +
"\n" + "O = " + O + "\n"+"H = "+ H + "\n"+"L = " + L
+ "\n"+"C ",
colorBlack, styleCandle);

if (bDraw) {
Plot(MA(C, 21), "21 bar MA", colorAqua,
styleLine+styleNoRescale+styleNoLabel);
Plot(MA(C, 55), "55 bar MA", colorGreen,
styleLine+styleNoRescale+styleNoLabel);
//Plot(MA(C, 233), "233 bar MA", colorDarkRed,
// styleLine+styleNoRescale+styleNoLabel);
}

// -- Create 0-initialized arrays the size of barcount
aHPivs = H - H;
aLPivs = L - L;
aHPivHighs = H - H;
aLPivLows = L - L;
aHPivIdxs = H - H;
aLPivIdxs = L - L;
aAddedHPivs = H - H;
aAddedLPivs = L - L;
aLegVol = H - H;
aRetrcVol = H - H;

nHPivs = 0;
nLPivs = 0;

lastHPIdx = 0;
lastLPIdx = 0;
lastHPH = 0;
lastLPL = 0;
curPivBarIdx = 0;

// -- looking back from the current bar, how many bars
// back were the hhv and llv values of the previous
// n bars, etc.?
aHHVBars = HHVBars(H, nBars);
aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);
aLLV = LLV(L, nBars);

// -- Initialize value of curTrend
nLastVisBar = LastValue(
Highest(IIf(Status("barvisible"), BarIndex(), 0)));

curBar = IIf(nlastVisBar > 0 AND bUseLastVis, nlastVisBar,
IIf(Status("action")==4 AND nExploreBarIdx > 0, nExploreBarIdx,
LastValue(BarIndex())));

curTrend = "";
if (aLLVBars[curBar] < aHHVBars[curBar])
curTrend = "D";
else
curTrend = "U";

// -- Loop through bars. Search for
// entirely array-based approach
// in version
/* *******************
Find main pivots
******************* */

// -- Make sure there are enough bars!
if (curBar >= nNumBarsToScan) {
for (i=0; i<nNumBarsToScan; i++) {

// -- value of curBar dependent on two parameters
curBar = IIf(nlastVisBar > 0 AND bUseLastVis,
nlastVisBar-i,
IIf(Status("action")==4 AND nExploreBarIdx > 0,
nExploreBarIdx-i,
LastValue(BarIndex())-i));

// -- Have we identified a pivot? If trend is down...
if (aLLVBars[curBar] < aHHVBars[curBar]) {

// ... and had been up, this is a trend change
if (curTrend == "U") {
curTrend = "D";
// -- Capture pivot information
curPivBarIdx = curBar - aLLVBars[curBar];
aLPivs[curPivBarIdx] = 1;
aLPivLows[nLPivs] = L[curPivBarIdx];
aLPivIdxs[nLPivs] = curPivBarIdx;
nLPivs++;
}
// -- or current trend is up
} else {
if (curTrend == "D") {
curTrend = "U";
curPivBarIdx = curBar - aHHVBars[curBar];
aHPivs[curPivBarIdx] = 1;
aHPivHighs[nHPivs] = H[curPivBarIdx];
aHPivIdxs[nHPivs] = curPivBarIdx;
nHPivs++;
}
// -- If curTrend is up...else...
}

// -- loop through bars
}
}
/* *******************
Found main pivots
******************* */

/* *************************
Finding missed pivot(s)
************************* */

// -- Start at last bar. Reestablish curBar
curBar =
IIf(nlastVisBar > 0 AND bUseLastVis,
nlastVisBar,
IIf(Status("action")==4 AND nExploreBarIdx > 0,
nExploreBarIdx,
LastValue(BarIndex()))
);

// -- Make sure I found at least two of each above.
if (nHPivs >= 2 AND nLPivs >= 2) {

lastLPIdx = aLPivIdxs[0];
lastLPL = aLPivLows[0];

lastHPIdx = aHPivIdxs[0];
lastHPH = aHPivHighs[0];

nLastHOrLPivIdx = Max(lastLPIdx, lastHPIdx);

nAddPivsRng = curBar - nLastHOrLPivIdx;
aLLVAfterLastPiv = LLV(L, nAddPivsRng);
nLLVAfterLastPiv = aLLVAfterLastPiv[curBar];
aLLVIdxAfterLastPiv = LLVBars(L, nAddPivsRng);
nLLVIdxAfterLastPiv = curBar - aLLVIdxAfterLastPiv[curBar];
aHHVAfterLastPiv = HHV(H, nAddPivsRng);
nHHVAfterLastPiv = aHHVAfterLastPiv[curBar];
aHHVIdxAfterLastPiv = HHVBars(H, nAddPivsRng);
nHHVIdxAfterLastPiv = curBar - aHHVIdxAfterLastPiv[curBar];

// -- Later want to add last high pivot only if
// not in buy mode from last and still in trade

/*
Note - I'm only interested in adding pivots if I'm in
a higher-highs or lower-lows scenario
*/


// -- OK, let's start where the last high pivot occurs after the
// last Low pivot
if (lastHPIdx > lastLPIdx) {

/* There are at least two possibilities here. One is that
the previous high was higher, indicating that this is a
possible short retracement or one in the making.
The other is that the previous high was lower, indicating
that this is a possible long retracement in the working.
However, both depend on opposing pivots. E.g., if I find
higher highs, what if I have lower lows?

If the highs are descending, then I can consider:
- a lower low, and leave it at that
- a higher high and higher low
- a lower low and another lower high
*/
if (aHPivHighs[0] < aHPivHighs[1]) {

if (nLLVAfterLastPiv < aLPivLows[0] AND
(nLLVIdxAfterLastPiv - lastHPIdx - 1) >= nMinBarsBtwPivs
AND nLLVIdxAfterLastPiv != curBar ) {

// -- OK, we'll add this as a pivot.
// Mark it for plotting...
aLPivs[nLLVIdxAfterLastPiv] = 1;
aAddedLPivs[nLLVIdxAfterLastPiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nLPivs; j++) {
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
}
aLPivLows[0] = nLLVAfterLastPiv;
aLPivIdxs[0] = nLLVIdxAfterLastPiv;
nLPivs++;

// -- Test whether to add piv given last piv is high
// AND we have lower highs
}

// -- Here, the last piv is a high piv, and we have
// higher-highs. The most likely addition is a
// Low piv that is a retracement.
} else {

if (nLLVAfterLastPiv > aLPivLows[0] AND
(nLLVIdxAfterLastPiv - lastHPIdx - 1) >= nMinBarsBtwPivs
AND nLLVIdxAfterLastPiv != curBar ) {

// -- OK, we'll add this as a pivot.
// Mark it for plotting...
aLPivs[nLLVIdxAfterLastPiv] = 1;
aAddedLPivs[nLLVIdxAfterLastPiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nLPivs; j++) {
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
}
aLPivLows[0] = nLLVAfterLastPiv;
aLPivIdxs[0] = nLLVIdxAfterLastPiv;
nLPivs++;

// -- Test whether to add piv given last piv is high
// AND we have lower highs
}
// -- The last piv is a high and we have higher highs
// OR lower highs
}

/* ****************************************************************
Still finding missed pivot(s). Here, the last piv is a low piv.
**************************************************************** */
} else {

// -- First case, lower highs
if (aHPivHighs[0] < aHPivHighs[1]) {

if (nHHVAfterLastPiv < aHPivHighs[0] AND
(nHHVIdxAfterLastPiv - lastLPIdx - 1) >= nMinBarsBtwPivs
AND nHHVIdxAfterLastPiv != curBar ) {

// -- OK, we'll add this as a pivot.
// Mark that for plotting
aHPivs[nHHVIdxAfterLastPiv] = 1;
aAddedHPivs[nHHVIdxAfterLastPiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nHPivs; j++) {
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nhPivs-(j+1)];
}
aHPivHighs[0] = nHHVAfterLastPiv;
aHPivIdxs[0] = nHHVIdxAfterLastPiv;
nHPivs++;

// -- Test whether to add piv given last piv is high
// AND we have lower highs
}

// -- Second case when last piv is a low piv, higher highs
// Most likely addition is high piv that is a retracement.
// Considering adding a high piv as long as it is higher
} else {

// -- Where I have higher highs,
if (nHHVAfterLastPiv > aHPivHighs[0] AND
(nHHVIdxAfterLastPiv - lastLPIdx - 1) >= nMinBarsBtwPivs
AND nHHVIdxAfterLastPiv != curBar ) {

// -- OK, we'll add this as a pivot.
// Mark it for plotting...
aHPivs[nHHVIdxAfterLastPiv] = 1;
aAddedHPivs[nHHVIdxAfterLastPiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nHPivs; j++) {
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nhPivs-(j+1)];
}
aHPivHighs[0] = nHHVAfterLastPiv;
aHPivIdxs[0] = nHHVIdxAfterLastPiv;
nHPivs++;

// -- Test whether to add piv given last piv is high
// AND we have lower highs
}

}

}

// -- If there are at least two of each
}

/* ****************************************
// -- Done with finding pivots
***************************************** */

if (bDraw) {

// -- OK, let's plot the pivots using arrows
PlotShapes(
IIf(aHPivs==1, shapeDownArrow, shapeNone),
colorRed, 0, High, Offset=-15);
PlotShapes(
IIf(aAddedHPivs==1, shapeDownArrow, shapeNone),
colorDarkRed, 0, High, Offset=-15);
PlotShapes(
IIf(aLPivs==1, shapeUpArrow , shapeNone),
colorGreen, 0, Low, Offset=-15);
PlotShapes(
IIf(aAddedLPivs==1, shapeUpArrow , shapeNone),
colorDarkGreen, 0, Low, Offset=-15);
}

/* ****************************************
// -- Done with discovering and plotting pivots
***************************************** */

// -- I'm going to want to look for possible retracement
risk = 0;
profInc = 0;
nLeg0Pts = 0;
nLeg0Bars = 0;
nLeg0Vol = 0;
nLeg1Pts = 0;
nLeg1Bars = 0;
nLeg1Vol = 0;
nLegBarsDiff = 0;
nRtrc0Pts = 0;
nRtrc0Bars = 0;
nRtrc0Vol = 0;
nRtrc1Pts = 0;
nRtrc1Bars = 0;
nRtrc1Vol = 0;

minRtrc = 0;
maxRtrc = 0;
minLine = 0;
maxLine = 0;
triggerLine = 0;
firstProfitLine = 0;
triggerInc = 0;
triggerPrc = 0;
firstProfitPrc = 0;
retrcPrc = 0;
retrcBar = 0;
retrcBarIdx = 0;
retrcRng = 0;
aRetrcPrc = H-H;
aRetrcPrcBars = H-H;
aRetrcClose = C;
retrcClose = 0;

// -- Do TCZ calcs. Arrangement of pivs very specific
// for this setup.
if (nHPivs >= 2 AND
nLPivs >=2 AND
aHPivHighs[0] > aHPivHighs[1] AND
aLPivLows[0] > aLPivLows[1]) {

tcz500 =
(aHPivHighs[0] -
(.5 * (aHPivHighs[0] - aLPivLows[1])));

tcz618 =
(aHPivHighs[0] -
(.618 * (aHPivHighs[0] - aLPivLows[1])));

tcz786 =
(aHPivHighs[0] -
(.786 * (aHPivHighs[0] - aLPivLows[0])));

retrcRng = curBar - aHPivIdxs[0];
aRetrcPrc = LLV(L, retrcRng);
aRetrcPrcBars = LLVBars(L, retrcRng);

retrcPrc = aRetrcPrc[curBar];
retrcBarIdx = curBar - aRetrcPrcBars[curBar];
retrcClose = aRetrcClose[retrcBarIdx];

// -- bTCZLong setup?
bTCZLong = (

// -- Are retracement levels arranged in
// tcz order?

// .500 is above .786 for long setups
tcz500 >= (tcz786 * (1 - tczTolerance))
AND
// .681 is below .786 for long setups
tcz618 <= (tcz786 * (1 + tczTolerance))
AND

// -- Is the low in the tcz range
// -- Is the close >= low of tcz range
// and low <= high of tcz range
retrcClose >= ((1 - retrcTolerance) * tcz618)
AND
retrcPrc <= ((1 + retrcTolerance) * tcz500)
);

// -- risk would be high of signal bar minus low of zone
//risk = 0;

// -- lower highs and lower lows
} else if (nHPivs >= 2 AND nLPivs >=2
AND aHPivHighs[0] < aHPivHighs[1]
AND aLPivLows[0] < aLPivLows[1]) {

tcz500 =
(aHPivHighs[1] -
(.5 * (aHPivHighs[1] - aLPivLows[0])));

tcz618 =
(aHPivHighs[0] -
(.618 * (aHPivHighs[1] - aLPivLows[0])));

tcz786 =
(aHPivHighs[0] -
(.786 * (aHPivHighs[0] - aLPivLows[0])));

retrcRng = curBar - aLPivIdxs[0];
aRetrcPrc = HHV(H, retrcRng);
retrcPrc = aRetrcPrc[curBar];
aRetrcPrcBars = HHVBars(H, retrcRng);
retrcBarIdx = curBar - aRetrcPrcBars[curBar];
retrcClose = aRetrcClose[retrcBarIdx];

bTCZShort = (
// -- Are retracement levels arranged in
// tcz order?

// .500 is below .786 for short setups
tcz500 <= (tcz786 * (1 + tczTolerance))
AND
// .681 is above .786 for short setups
tcz618 >= (tcz786 * (1 - tczTolerance))
AND

// -- Is the close <= high of tcz range
// and high >= low of tcz range
retrcClose <= ((1 + retrcTolerance) * tcz618)
AND
retrcPrc >= ((1 - retrcTolerance) * tcz500)
);

// -- Risk would be top of zone - low of signal bar
//risk = 0;
}

// -- Show zone if present
if (bTCZShort OR bTCZLong) {

// -- Be prepared to see symmetry
if (bTCZShort) {
if (aLPivIdxs[0] > aHPivIdxs[0]) {
// -- Valuable, useful symmetry information
nRtrc0Pts = aHPivHighs[0] - aLPivLows[1];
nRtrc0Bars = aHPivIdxs[0] - aLPivIdxs[1] + 1;
nRtrc1Pts = retrcPrc - aLPivLows[0];
nRtrc1Bars = retrcBarIdx - aLPivIdxs[0] + 1;
} else {
nRtrc0Pts = aHPivHighs[1] - aLPivLows[1];
nRtrc0Bars = aHPivIdxs[1] - aLPivIdxs[1] + 1;
nRtrc1Pts = aHPivHighs[0] - aLPivLows[0];
nRtrc1Bars = aHPivIdxs[0] - aLPivIdxs[0] + 1;
}
} else { // bLongSetup
if (aLPivIdxs[0] > aHPivIdxs[0]) {
nRtrc0Pts = aHPivHighs[0] - aLPivLows[1];
nRtrc0Bars = aHPivIdxs[0] - aLPivIdxs[1] + 1;
nRtrc1Pts = retrcPrc - aLPivLows[0];
nRtrc1Bars = retrcBarIdx - aLPivIdxs[0] + 1;
} else {
nRtrc0Pts = aHPivHighs[1] - aLPivLows[0];
nRtrc0Bars = aLPivIdxs[0] - aHPivIdxs[1] + 1;
nRtrc1Pts = aHPivHighs[0] - aLPivLows[0];
nRtrc1Bars = aLPivIdxs[0] - aHPivIdxs[0] + 1;
}
}

if (bShowTCZ) {
Plot(
LineArray( IIf(bTCZLong, aHPivIdxs[0], aLPivIdxs[0]),
tcz500, curBar, tcz500 , 0),
"tcz500", colorPaleBlue, styleLine);
Plot(
LineArray( IIf(bTCZLong, aHPivIdxs[0], aLPivIdxs[0]),
tcz618, curBar, tcz618, 0),
"tcz618", colorPaleBlue, styleLine);
Plot(
LineArray( IIf(bTCZLong, aHPivIdxs[0], aLPivIdxs[0]),
tcz786, curBar, tcz786, 0),
"tcz786", colorTurquoise, styleLine);
}

// -- if (bShowTCZ)
}

if (bDraw) {
Title = Name() + " (" + StrLeft(FullName(), 10) +
") ATR: " + NumToStr(ATR(1), 4.2) + " ( " +
NumToStr((C - Ref(C, -1)), 4.2) + " / " +
NumToStr((((C - Ref(C, -1)) / Ref(C, -1)) * 100), 2.1) + "% ) " +
WriteVal( SelectedValue( DateTime() ), formatDateTime) +
" \nO: " + Open +
", \nH: " + High +
", \nL: " + Low +
", \nC: " + Close + ", \n" +
// "Risk: " + WriteVal(risk, 2.1) + "% \n" +
"Rtrc 0/1 Pts: " + WriteVal(nRtrc0Pts, 2.1) + "/" +
WriteVal(nRtrc1Pts, 2.1) + " \n" +
"Rtrc 0/1 Bars: " + WriteVal(nRtrc0Bars, 2.0) + "/" +
WriteVal(nRtrc1Bars, 2.0);
}

// **************************
// END INDICATOR CODE
// **************************
بندر بن عبدالله غير متواجد حالياً   رد مع اقتباس
قديم 04-06-2014, 12:04 PM   #10
عزيز77
كاتب قدير
 
تاريخ التسجيل: Jul 2006
المشاركات: 9,909

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

اقتباس:
المشاركة الأصلية كتبت بواسطة بندر بن عبدالله مشاهدة المشاركة
اتمنى انه هذا طلبك اخوي عزيز
وجدتة مع مجموعة مؤشرات ولم اتعامل معه ...

// **************************
// being exploration code
// **************************

// -- what will be our lookback range for the hh and ll?
Nbars = param("number of bars", 12, 5, 40);
btrace = param("include trace output", 1, 0, 1);
nnopivsinsetup = param("no. Pivs in setup", 4, 3, 4, 1);
bshowtcz = param("show tcz", 1, 0, 1);
nminbarsbtwpivs = param("min. Number of bars btw. Pivots", 1, 1, 10, 1);
nminpctbtwpivs = param("min. Percent diff. Btw. Pivots", .05, .04, .2, .01);
blastbarcanbepiv = param("last bar can be a pivot", 1, 0, 1);
retrctolerance = .01;
tcztolerance = .005;
nnumbarstoscan = 120;

// -- added from exploration version 20040204
nexplorebaridx = 0;
nexploredate = 0;
ncurdatenum = 0;
dn = datenum();
dt = datetime();

// -- key exploration variables
btczlong = false;
btczshort = false;
nanchorpividx = 0;

adx8 = adx(8);

// 1 - indicator, 2 - commentary, 3 - scan,
// 4 - exploration, 5 - backtest / optimize
if(status("action")==1) {
bdraw = true;
buselastvis = param("use last visible bar", 1, 0, 1);
} else {
bdraw = false;
buselastvis = false;
btrace = false;
nexploredate = status("rangetodate");
for (i=lastvalue(barindex());i>=0;i--) {
ncurdatenum = dn[i];
if (ncurdatenum == nexploredate) {
nexplorebaridx = i;
}
}
// -- if(status("action")==1...
}

graphxspace=7;

// -- basic candle chart
// -- if this appears inside if , strange
// drawing results!
Plotohlc(open, high, low, close,
"bidx = " + barindex() +
"\n" + "o = " + o + "\n"+"h = "+ h + "\n"+"l = " + l
+ "\n"+"c ",
colorblack, stylecandle);

if (bdraw) {
plot(ma(c, 21), "21 bar ma", coloraqua,
styleline+stylenorescale+stylenolabel);
plot(ma(c, 55), "55 bar ma", colorgreen,
styleline+stylenorescale+stylenolabel);
//plot(ma(c, 233), "233 bar ma", colordarkred,
// styleline+stylenorescale+stylenolabel);
}

// -- create 0-initialized arrays the size of barcount
ahpivs = h - h;
alpivs = l - l;
ahpivhighs = h - h;
alpivlows = l - l;
ahpividxs = h - h;
alpividxs = l - l;
aaddedhpivs = h - h;
aaddedlpivs = l - l;
alegvol = h - h;
aretrcvol = h - h;

nhpivs = 0;
nlpivs = 0;

lasthpidx = 0;
lastlpidx = 0;
lasthph = 0;
lastlpl = 0;
curpivbaridx = 0;

// -- looking back from the current bar, how many bars
// back were the hhv and llv values of the previous
// n bars, etc.?
Ahhvbars = hhvbars(h, nbars);
allvbars = llvbars(l, nbars);
ahhv = hhv(h, nbars);
allv = llv(l, nbars);

// -- initialize value of curtrend
nlastvisbar = lastvalue(
highest(iif(status("barvisible"), barindex(), 0)));

curbar = iif(nlastvisbar > 0 and buselastvis, nlastvisbar,
iif(status("action")==4 and nexplorebaridx > 0, nexplorebaridx,
lastvalue(barindex())));

curtrend = "";
if (allvbars[curbar] < ahhvbars[curbar])
curtrend = "d";
else
curtrend = "u";

// -- loop through bars. Search for
// entirely array-based approach
// in version
/* *******************
find main pivots
******************* */

// -- make sure there are enough bars!
If (curbar >= nnumbarstoscan) {
for (i=0; i<nnumbarstoscan; i++) {

// -- value of curbar dependent on two parameters
curbar = iif(nlastvisbar > 0 and buselastvis,
nlastvisbar-i,
iif(status("action")==4 and nexplorebaridx > 0,
nexplorebaridx-i,
lastvalue(barindex())-i));

// -- have we identified a pivot? If trend is down...
If (allvbars[curbar] < ahhvbars[curbar]) {

// ... And had been up, this is a trend change
if (curtrend == "u") {
curtrend = "d";
// -- capture pivot information
curpivbaridx = curbar - allvbars[curbar];
alpivs[curpivbaridx] = 1;
alpivlows[nlpivs] = l[curpivbaridx];
alpividxs[nlpivs] = curpivbaridx;
nlpivs++;
}
// -- or current trend is up
} else {
if (curtrend == "d") {
curtrend = "u";
curpivbaridx = curbar - ahhvbars[curbar];
ahpivs[curpivbaridx] = 1;
ahpivhighs[nhpivs] = h[curpivbaridx];
ahpividxs[nhpivs] = curpivbaridx;
nhpivs++;
}
// -- if curtrend is up...else...
}

// -- loop through bars
}
}
/* *******************
found main pivots
******************* */

/* *************************
finding missed pivot(s)
************************* */

// -- start at last bar. Reestablish curbar
curbar =
iif(nlastvisbar > 0 and buselastvis,
nlastvisbar,
iif(status("action")==4 and nexplorebaridx > 0,
nexplorebaridx,
lastvalue(barindex()))
);

// -- make sure i found at least two of each above.
If (nhpivs >= 2 and nlpivs >= 2) {

lastlpidx = alpividxs[0];
lastlpl = alpivlows[0];

lasthpidx = ahpividxs[0];
lasthph = ahpivhighs[0];

nlasthorlpividx = max(lastlpidx, lasthpidx);

naddpivsrng = curbar - nlasthorlpividx;
allvafterlastpiv = llv(l, naddpivsrng);
nllvafterlastpiv = allvafterlastpiv[curbar];
allvidxafterlastpiv = llvbars(l, naddpivsrng);
nllvidxafterlastpiv = curbar - allvidxafterlastpiv[curbar];
ahhvafterlastpiv = hhv(h, naddpivsrng);
nhhvafterlastpiv = ahhvafterlastpiv[curbar];
ahhvidxafterlastpiv = hhvbars(h, naddpivsrng);
nhhvidxafterlastpiv = curbar - ahhvidxafterlastpiv[curbar];

// -- later want to add last high pivot only if
// not in buy mode from last and still in trade

/*
note - i'm only interested in adding pivots if i'm in
a higher-highs or lower-lows scenario
*/


// -- ok, let's start where the last high pivot occurs after the
// last low pivot
if (lasthpidx > lastlpidx) {

/* there are at least two possibilities here. One is that
the previous high was higher, indicating that this is a
possible short retracement or one in the making.
The other is that the previous high was lower, indicating
that this is a possible long retracement in the working.
However, both depend on opposing pivots. E.g., if i find
higher highs, what if i have lower lows?

If the highs are descending, then i can consider:
- a lower low, and leave it at that
- a higher high and higher low
- a lower low and another lower high
*/
if (ahpivhighs[0] < ahpivhighs[1]) {

if (nllvafterlastpiv < alpivlows[0] and
(nllvidxafterlastpiv - lasthpidx - 1) >= nminbarsbtwpivs
and nllvidxafterlastpiv != curbar ) {

// -- ok, we'll add this as a pivot.
// mark it for plotting...
Alpivs[nllvidxafterlastpiv] = 1;
aaddedlpivs[nllvidxafterlastpiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nlpivs; j++) {
alpivlows[nlpivs-j] = alpivlows[nlpivs-(j+1)];
alpividxs[nlpivs-j] = alpividxs[nlpivs-(j+1)];
}
alpivlows[0] = nllvafterlastpiv;
alpividxs[0] = nllvidxafterlastpiv;
nlpivs++;

// -- test whether to add piv given last piv is high
// and we have lower highs
}

// -- here, the last piv is a high piv, and we have
// higher-highs. The most likely addition is a
// low piv that is a retracement.
} else {

if (nllvafterlastpiv > alpivlows[0] and
(nllvidxafterlastpiv - lasthpidx - 1) >= nminbarsbtwpivs
and nllvidxafterlastpiv != curbar ) {

// -- ok, we'll add this as a pivot.
// mark it for plotting...
Alpivs[nllvidxafterlastpiv] = 1;
aaddedlpivs[nllvidxafterlastpiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nlpivs; j++) {
alpivlows[nlpivs-j] = alpivlows[nlpivs-(j+1)];
alpividxs[nlpivs-j] = alpividxs[nlpivs-(j+1)];
}
alpivlows[0] = nllvafterlastpiv;
alpividxs[0] = nllvidxafterlastpiv;
nlpivs++;

// -- test whether to add piv given last piv is high
// and we have lower highs
}
// -- the last piv is a high and we have higher highs
// or lower highs
}

/* ****************************************************************
still finding missed pivot(s). Here, the last piv is a low piv.
**************************************************************** */
} else {

// -- first case, lower highs
if (ahpivhighs[0] < ahpivhighs[1]) {

if (nhhvafterlastpiv < ahpivhighs[0] and
(nhhvidxafterlastpiv - lastlpidx - 1) >= nminbarsbtwpivs
and nhhvidxafterlastpiv != curbar ) {

// -- ok, we'll add this as a pivot.
// mark that for plotting
ahpivs[nhhvidxafterlastpiv] = 1;
aaddedhpivs[nhhvidxafterlastpiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nhpivs; j++) {
ahpivhighs[nhpivs-j] = ahpivhighs[nhpivs-(j+1)];
ahpividxs[nhpivs-j] = ahpividxs[nhpivs-(j+1)];
}
ahpivhighs[0] = nhhvafterlastpiv;
ahpividxs[0] = nhhvidxafterlastpiv;
nhpivs++;

// -- test whether to add piv given last piv is high
// and we have lower highs
}

// -- second case when last piv is a low piv, higher highs
// most likely addition is high piv that is a retracement.
// considering adding a high piv as long as it is higher
} else {

// -- where i have higher highs,
if (nhhvafterlastpiv > ahpivhighs[0] and
(nhhvidxafterlastpiv - lastlpidx - 1) >= nminbarsbtwpivs
and nhhvidxafterlastpiv != curbar ) {

// -- ok, we'll add this as a pivot.
// mark it for plotting...
Ahpivs[nhhvidxafterlastpiv] = 1;
aaddedhpivs[nhhvidxafterlastpiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nhpivs; j++) {
ahpivhighs[nhpivs-j] = ahpivhighs[nhpivs-(j+1)];
ahpividxs[nhpivs-j] = ahpividxs[nhpivs-(j+1)];
}
ahpivhighs[0] = nhhvafterlastpiv;
ahpividxs[0] = nhhvidxafterlastpiv;
nhpivs++;

// -- test whether to add piv given last piv is high
// and we have lower highs
}

}

}

// -- if there are at least two of each
}

/* ****************************************
// -- done with finding pivots
***************************************** */

if (bdraw) {

// -- ok, let's plot the pivots using arrows
plotshapes(
iif(ahpivs==1, shapedownarrow, shapenone),
colorred, 0, high, offset=-15);
plotshapes(
iif(aaddedhpivs==1, shapedownarrow, shapenone),
colordarkred, 0, high, offset=-15);
plotshapes(
iif(alpivs==1, shapeuparrow , shapenone),
colorgreen, 0, low, offset=-15);
plotshapes(
iif(aaddedlpivs==1, shapeuparrow , shapenone),
colordarkgreen, 0, low, offset=-15);
}

/* ****************************************
// -- done with discovering and plotting pivots
***************************************** */

// -- i'm going to want to look for possible retracement
risk = 0;
profinc = 0;
nleg0pts = 0;
nleg0bars = 0;
nleg0vol = 0;
nleg1pts = 0;
nleg1bars = 0;
nleg1vol = 0;
nlegbarsdiff = 0;
nrtrc0pts = 0;
nrtrc0bars = 0;
nrtrc0vol = 0;
nrtrc1pts = 0;
nrtrc1bars = 0;
nrtrc1vol = 0;

minrtrc = 0;
maxrtrc = 0;
minline = 0;
maxline = 0;
triggerline = 0;
firstprofitline = 0;
triggerinc = 0;
triggerprc = 0;
firstprofitprc = 0;
retrcprc = 0;
retrcbar = 0;
retrcbaridx = 0;
retrcrng = 0;
aretrcprc = h-h;
aretrcprcbars = h-h;
aretrcclose = c;
retrcclose = 0;

// -- do tcz calcs. Arrangement of pivs very specific
// for this setup.
If (nhpivs >= 2 and
nlpivs >=2 and
ahpivhighs[0] > ahpivhighs[1] and
alpivlows[0] > alpivlows[1]) {

tcz500 =
(ahpivhighs[0] -
(.5 * (ahpivhighs[0] - alpivlows[1])));

tcz618 =
(ahpivhighs[0] -
(.618 * (ahpivhighs[0] - alpivlows[1])));

tcz786 =
(ahpivhighs[0] -
(.786 * (ahpivhighs[0] - alpivlows[0])));

retrcrng = curbar - ahpividxs[0];
aretrcprc = llv(l, retrcrng);
retrcprc = aretrcprc[curbar];
aretrcprcbars = llvbars(l, retrcrng);
retrcbaridx = curbar - aretrcprcbars[curbar];
retrcclose = aretrcclose[retrcbaridx];

// -- btczlong setup?
Btczlong = (

// -- are retracement levels arranged in
// tcz order?
Tcz500 >= (tcz786 * (1 - tcztolerance))
and
// .681 is below .786 for long setups
tcz618 <= (tcz786 * (1 + tcztolerance))
and

// -- is the low in the tcz range
// -- is the close >= low of tcz range
// and low <= high of tcz range
retrcclose >= ((1 - retrctolerance) * tcz618)
and
retrcprc <= ((1 + retrctolerance) * tcz500)
);

// -- risk would be high of signal bar minus low of zone
//risk = 0;

// -- lower highs and lower lows
} else if (nhpivs >= 2 and nlpivs >=2
and ahpivhighs[0] < ahpivhighs[1]
and alpivlows[0] < alpivlows[1]) {

tcz500 =
(ahpivhighs[1] -
(.5 * (ahpivhighs[1] - alpivlows[0])));

tcz618 =
(ahpivhighs[0] -
(.618 * (ahpivhighs[1] - alpivlows[0])));

tcz786 =
(ahpivhighs[0] -
(.786 * (ahpivhighs[0] - alpivlows[0])));

retrcrng = curbar - alpividxs[0];
aretrcprc = hhv(h, retrcrng);
retrcprc = aretrcprc[curbar];
aretrcprcbars = hhvbars(h, retrcrng);
retrcbaridx = curbar - aretrcprcbars[curbar];
retrcclose = aretrcclose[retrcbaridx];

btczshort = (
// -- are retracement levels arranged in
// tcz order?

// .500 is below .786 for short setups
tcz500 <= (tcz786 * (1 + tcztolerance))
and
// .681 is above .786 for short setups
tcz618 >= (tcz786 * (1 - tcztolerance))
and

// -- is the close <= high of tcz range
// and high >= low of tcz range
retrcclose <= ((1 + retrctolerance) * tcz618)
and
retrcprc >= ((1 - retrctolerance) * tcz500)
);

// -- risk would be top of zone - low of signal bar
//risk = 0;
}

filter = (btczshort or btczlong);
addcolumn(c, "close");
addcolumn(iif(btczlong, 76, 83), "l/s", formatchar);

// **************************
// end exploration code
// **************************

// **************************
// begin indicator code
// **************************

// -- what will be our lookback range for the hh and ll?
Nbars = param("number of bars", 12, 5, 40);
btrace = param("include trace output", 1, 0, 1);
nnopivsinsetup = param("no. Pivs in setup", 4, 3, 4, 1);
bshowtcz = param("show tcz", 1, 0, 1);
nminbarsbtwpivs = param("min. Number of bars btw. Pivots", 1, 1, 10, 1);
nminpctbtwpivs = param("min. Percent diff. Btw. Pivots", .05, .04, .2, .01);
blastbarcanbepiv = param("last bar can be a pivot", 1, 0, 1);
retrctolerance = .01;
tcztolerance = .005;
nnumbarstoscan = 120;

// -- added from exploration version 20040204
nexplorebaridx = 0;
nexploredate = 0;
ncurdatenum = 0;
dn = datenum();
dt = datetime();

// -- key exploration variables
btczlong = false;
btczshort = false;
nanchorpividx = 0;

adx8 = adx(8);

// 1 - indicator, 2 - commentary, 3 - scan,
// 4 - exploration, 5 - backtest / optimize
if(status("action")==1) {
bdraw = true;
buselastvis = param("use last visible bar", 1, 0, 1);
} else {
bdraw = false;
buselastvis = false;
btrace = false;
nexploredate = status("rangetodate");
for (i=lastvalue(barindex());i>=0;i--) {
ncurdatenum = dn[i];
if (ncurdatenum == nexploredate) {
nexplorebaridx = i;
}
}
// -- if(status("action")==1...
}

graphxspace=7;

// -- basic candle chart
// -- if this appears inside if , strange
// drawing results!
Plotohlc(open, high, low, close,
"bidx = " + barindex() +
"\n" + "o = " + o + "\n"+"h = "+ h + "\n"+"l = " + l
+ "\n"+"c ",
colorblack, stylecandle);

if (bdraw) {
plot(ma(c, 21), "21 bar ma", coloraqua,
styleline+stylenorescale+stylenolabel);
plot(ma(c, 55), "55 bar ma", colorgreen,
styleline+stylenorescale+stylenolabel);
//plot(ma(c, 233), "233 bar ma", colordarkred,
// styleline+stylenorescale+stylenolabel);
}

// -- create 0-initialized arrays the size of barcount
ahpivs = h - h;
alpivs = l - l;
ahpivhighs = h - h;
alpivlows = l - l;
ahpividxs = h - h;
alpividxs = l - l;
aaddedhpivs = h - h;
aaddedlpivs = l - l;
alegvol = h - h;
aretrcvol = h - h;

nhpivs = 0;
nlpivs = 0;

lasthpidx = 0;
lastlpidx = 0;
lasthph = 0;
lastlpl = 0;
curpivbaridx = 0;

// -- looking back from the current bar, how many bars
// back were the hhv and llv values of the previous
// n bars, etc.?
Ahhvbars = hhvbars(h, nbars);
allvbars = llvbars(l, nbars);
ahhv = hhv(h, nbars);
allv = llv(l, nbars);

// -- initialize value of curtrend
nlastvisbar = lastvalue(
highest(iif(status("barvisible"), barindex(), 0)));

curbar = iif(nlastvisbar > 0 and buselastvis, nlastvisbar,
iif(status("action")==4 and nexplorebaridx > 0, nexplorebaridx,
lastvalue(barindex())));

curtrend = "";
if (allvbars[curbar] < ahhvbars[curbar])
curtrend = "d";
else
curtrend = "u";

// -- loop through bars. Search for
// entirely array-based approach
// in version
/* *******************
find main pivots
******************* */

// -- make sure there are enough bars!
If (curbar >= nnumbarstoscan) {
for (i=0; i<nnumbarstoscan; i++) {

// -- value of curbar dependent on two parameters
curbar = iif(nlastvisbar > 0 and buselastvis,
nlastvisbar-i,
iif(status("action")==4 and nexplorebaridx > 0,
nexplorebaridx-i,
lastvalue(barindex())-i));

// -- have we identified a pivot? If trend is down...
If (allvbars[curbar] < ahhvbars[curbar]) {

// ... And had been up, this is a trend change
if (curtrend == "u") {
curtrend = "d";
// -- capture pivot information
curpivbaridx = curbar - allvbars[curbar];
alpivs[curpivbaridx] = 1;
alpivlows[nlpivs] = l[curpivbaridx];
alpividxs[nlpivs] = curpivbaridx;
nlpivs++;
}
// -- or current trend is up
} else {
if (curtrend == "d") {
curtrend = "u";
curpivbaridx = curbar - ahhvbars[curbar];
ahpivs[curpivbaridx] = 1;
ahpivhighs[nhpivs] = h[curpivbaridx];
ahpividxs[nhpivs] = curpivbaridx;
nhpivs++;
}
// -- if curtrend is up...else...
}

// -- loop through bars
}
}
/* *******************
found main pivots
******************* */

/* *************************
finding missed pivot(s)
************************* */

// -- start at last bar. Reestablish curbar
curbar =
iif(nlastvisbar > 0 and buselastvis,
nlastvisbar,
iif(status("action")==4 and nexplorebaridx > 0,
nexplorebaridx,
lastvalue(barindex()))
);

// -- make sure i found at least two of each above.
If (nhpivs >= 2 and nlpivs >= 2) {

lastlpidx = alpividxs[0];
lastlpl = alpivlows[0];

lasthpidx = ahpividxs[0];
lasthph = ahpivhighs[0];

nlasthorlpividx = max(lastlpidx, lasthpidx);

naddpivsrng = curbar - nlasthorlpividx;
allvafterlastpiv = llv(l, naddpivsrng);
nllvafterlastpiv = allvafterlastpiv[curbar];
allvidxafterlastpiv = llvbars(l, naddpivsrng);
nllvidxafterlastpiv = curbar - allvidxafterlastpiv[curbar];
ahhvafterlastpiv = hhv(h, naddpivsrng);
nhhvafterlastpiv = ahhvafterlastpiv[curbar];
ahhvidxafterlastpiv = hhvbars(h, naddpivsrng);
nhhvidxafterlastpiv = curbar - ahhvidxafterlastpiv[curbar];

// -- later want to add last high pivot only if
// not in buy mode from last and still in trade

/*
note - i'm only interested in adding pivots if i'm in
a higher-highs or lower-lows scenario
*/


// -- ok, let's start where the last high pivot occurs after the
// last low pivot
if (lasthpidx > lastlpidx) {

/* there are at least two possibilities here. One is that
the previous high was higher, indicating that this is a
possible short retracement or one in the making.
The other is that the previous high was lower, indicating
that this is a possible long retracement in the working.
However, both depend on opposing pivots. E.g., if i find
higher highs, what if i have lower lows?

If the highs are descending, then i can consider:
- a lower low, and leave it at that
- a higher high and higher low
- a lower low and another lower high
*/
if (ahpivhighs[0] < ahpivhighs[1]) {

if (nllvafterlastpiv < alpivlows[0] and
(nllvidxafterlastpiv - lasthpidx - 1) >= nminbarsbtwpivs
and nllvidxafterlastpiv != curbar ) {

// -- ok, we'll add this as a pivot.
// mark it for plotting...
Alpivs[nllvidxafterlastpiv] = 1;
aaddedlpivs[nllvidxafterlastpiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nlpivs; j++) {
alpivlows[nlpivs-j] = alpivlows[nlpivs-(j+1)];
alpividxs[nlpivs-j] = alpividxs[nlpivs-(j+1)];
}
alpivlows[0] = nllvafterlastpiv;
alpividxs[0] = nllvidxafterlastpiv;
nlpivs++;

// -- test whether to add piv given last piv is high
// and we have lower highs
}

// -- here, the last piv is a high piv, and we have
// higher-highs. The most likely addition is a
// low piv that is a retracement.
} else {

if (nllvafterlastpiv > alpivlows[0] and
(nllvidxafterlastpiv - lasthpidx - 1) >= nminbarsbtwpivs
and nllvidxafterlastpiv != curbar ) {

// -- ok, we'll add this as a pivot.
// mark it for plotting...
Alpivs[nllvidxafterlastpiv] = 1;
aaddedlpivs[nllvidxafterlastpiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nlpivs; j++) {
alpivlows[nlpivs-j] = alpivlows[nlpivs-(j+1)];
alpividxs[nlpivs-j] = alpividxs[nlpivs-(j+1)];
}
alpivlows[0] = nllvafterlastpiv;
alpividxs[0] = nllvidxafterlastpiv;
nlpivs++;

// -- test whether to add piv given last piv is high
// and we have lower highs
}
// -- the last piv is a high and we have higher highs
// or lower highs
}

/* ****************************************************************
still finding missed pivot(s). Here, the last piv is a low piv.
**************************************************************** */
} else {

// -- first case, lower highs
if (ahpivhighs[0] < ahpivhighs[1]) {

if (nhhvafterlastpiv < ahpivhighs[0] and
(nhhvidxafterlastpiv - lastlpidx - 1) >= nminbarsbtwpivs
and nhhvidxafterlastpiv != curbar ) {

// -- ok, we'll add this as a pivot.
// mark that for plotting
ahpivs[nhhvidxafterlastpiv] = 1;
aaddedhpivs[nhhvidxafterlastpiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nhpivs; j++) {
ahpivhighs[nhpivs-j] = ahpivhighs[nhpivs-(j+1)];
ahpividxs[nhpivs-j] = ahpividxs[nhpivs-(j+1)];
}
ahpivhighs[0] = nhhvafterlastpiv;
ahpividxs[0] = nhhvidxafterlastpiv;
nhpivs++;

// -- test whether to add piv given last piv is high
// and we have lower highs
}

// -- second case when last piv is a low piv, higher highs
// most likely addition is high piv that is a retracement.
// considering adding a high piv as long as it is higher
} else {

// -- where i have higher highs,
if (nhhvafterlastpiv > ahpivhighs[0] and
(nhhvidxafterlastpiv - lastlpidx - 1) >= nminbarsbtwpivs
and nhhvidxafterlastpiv != curbar ) {

// -- ok, we'll add this as a pivot.
// mark it for plotting...
Ahpivs[nhhvidxafterlastpiv] = 1;
aaddedhpivs[nhhvidxafterlastpiv] = 1;

// ...and then rearrange s in the
// pivot information arrays
for (j=0; j<nhpivs; j++) {
ahpivhighs[nhpivs-j] = ahpivhighs[nhpivs-(j+1)];
ahpividxs[nhpivs-j] = ahpividxs[nhpivs-(j+1)];
}
ahpivhighs[0] = nhhvafterlastpiv;
ahpividxs[0] = nhhvidxafterlastpiv;
nhpivs++;

// -- test whether to add piv given last piv is high
// and we have lower highs
}

}

}

// -- if there are at least two of each
}

/* ****************************************
// -- done with finding pivots
***************************************** */

if (bdraw) {

// -- ok, let's plot the pivots using arrows
plotshapes(
iif(ahpivs==1, shapedownarrow, shapenone),
colorred, 0, high, offset=-15);
plotshapes(
iif(aaddedhpivs==1, shapedownarrow, shapenone),
colordarkred, 0, high, offset=-15);
plotshapes(
iif(alpivs==1, shapeuparrow , shapenone),
colorgreen, 0, low, offset=-15);
plotshapes(
iif(aaddedlpivs==1, shapeuparrow , shapenone),
colordarkgreen, 0, low, offset=-15);
}

/* ****************************************
// -- done with discovering and plotting pivots
***************************************** */

// -- i'm going to want to look for possible retracement
risk = 0;
profinc = 0;
nleg0pts = 0;
nleg0bars = 0;
nleg0vol = 0;
nleg1pts = 0;
nleg1bars = 0;
nleg1vol = 0;
nlegbarsdiff = 0;
nrtrc0pts = 0;
nrtrc0bars = 0;
nrtrc0vol = 0;
nrtrc1pts = 0;
nrtrc1bars = 0;
nrtrc1vol = 0;

minrtrc = 0;
maxrtrc = 0;
minline = 0;
maxline = 0;
triggerline = 0;
firstprofitline = 0;
triggerinc = 0;
triggerprc = 0;
firstprofitprc = 0;
retrcprc = 0;
retrcbar = 0;
retrcbaridx = 0;
retrcrng = 0;
aretrcprc = h-h;
aretrcprcbars = h-h;
aretrcclose = c;
retrcclose = 0;

// -- do tcz calcs. Arrangement of pivs very specific
// for this setup.
If (nhpivs >= 2 and
nlpivs >=2 and
ahpivhighs[0] > ahpivhighs[1] and
alpivlows[0] > alpivlows[1]) {

tcz500 =
(ahpivhighs[0] -
(.5 * (ahpivhighs[0] - alpivlows[1])));

tcz618 =
(ahpivhighs[0] -
(.618 * (ahpivhighs[0] - alpivlows[1])));

tcz786 =
(ahpivhighs[0] -
(.786 * (ahpivhighs[0] - alpivlows[0])));

retrcrng = curbar - ahpividxs[0];
aretrcprc = llv(l, retrcrng);
aretrcprcbars = llvbars(l, retrcrng);

retrcprc = aretrcprc[curbar];
retrcbaridx = curbar - aretrcprcbars[curbar];
retrcclose = aretrcclose[retrcbaridx];

// -- btczlong setup?
Btczlong = (

// -- are retracement levels arranged in
// tcz order?

// .500 is above .786 for long setups
tcz500 >= (tcz786 * (1 - tcztolerance))
and
// .681 is below .786 for long setups
tcz618 <= (tcz786 * (1 + tcztolerance))
and

// -- is the low in the tcz range
// -- is the close >= low of tcz range
// and low <= high of tcz range
retrcclose >= ((1 - retrctolerance) * tcz618)
and
retrcprc <= ((1 + retrctolerance) * tcz500)
);

// -- risk would be high of signal bar minus low of zone
//risk = 0;

// -- lower highs and lower lows
} else if (nhpivs >= 2 and nlpivs >=2
and ahpivhighs[0] < ahpivhighs[1]
and alpivlows[0] < alpivlows[1]) {

tcz500 =
(ahpivhighs[1] -
(.5 * (ahpivhighs[1] - alpivlows[0])));

tcz618 =
(ahpivhighs[0] -
(.618 * (ahpivhighs[1] - alpivlows[0])));

tcz786 =
(ahpivhighs[0] -
(.786 * (ahpivhighs[0] - alpivlows[0])));

retrcrng = curbar - alpividxs[0];
aretrcprc = hhv(h, retrcrng);
retrcprc = aretrcprc[curbar];
aretrcprcbars = hhvbars(h, retrcrng);
retrcbaridx = curbar - aretrcprcbars[curbar];
retrcclose = aretrcclose[retrcbaridx];

btczshort = (
// -- are retracement levels arranged in
// tcz order?

// .500 is below .786 for short setups
tcz500 <= (tcz786 * (1 + tcztolerance))
and
// .681 is above .786 for short setups
tcz618 >= (tcz786 * (1 - tcztolerance))
and

// -- is the close <= high of tcz range
// and high >= low of tcz range
retrcclose <= ((1 + retrctolerance) * tcz618)
and
retrcprc >= ((1 - retrctolerance) * tcz500)
);

// -- risk would be top of zone - low of signal bar
//risk = 0;
}

// -- show zone if present
if (btczshort or btczlong) {

// -- be prepared to see symmetry
if (btczshort) {
if (alpividxs[0] > ahpividxs[0]) {
// -- valuable, useful symmetry information
nrtrc0pts = ahpivhighs[0] - alpivlows[1];
nrtrc0bars = ahpividxs[0] - alpividxs[1] + 1;
nrtrc1pts = retrcprc - alpivlows[0];
nrtrc1bars = retrcbaridx - alpividxs[0] + 1;
} else {
nrtrc0pts = ahpivhighs[1] - alpivlows[1];
nrtrc0bars = ahpividxs[1] - alpividxs[1] + 1;
nrtrc1pts = ahpivhighs[0] - alpivlows[0];
nrtrc1bars = ahpividxs[0] - alpividxs[0] + 1;
}
} else { // blongsetup
if (alpividxs[0] > ahpividxs[0]) {
nrtrc0pts = ahpivhighs[0] - alpivlows[1];
nrtrc0bars = ahpividxs[0] - alpividxs[1] + 1;
nrtrc1pts = retrcprc - alpivlows[0];
nrtrc1bars = retrcbaridx - alpividxs[0] + 1;
} else {
nrtrc0pts = ahpivhighs[1] - alpivlows[0];
nrtrc0bars = alpividxs[0] - ahpividxs[1] + 1;
nrtrc1pts = ahpivhighs[0] - alpivlows[0];
nrtrc1bars = alpividxs[0] - ahpividxs[0] + 1;
}
}

if (bshowtcz) {
plot(
linearray( iif(btczlong, ahpividxs[0], alpividxs[0]),
tcz500, curbar, tcz500 , 0),
"tcz500", colorpaleblue, styleline);
plot(
linearray( iif(btczlong, ahpividxs[0], alpividxs[0]),
tcz618, curbar, tcz618, 0),
"tcz618", colorpaleblue, styleline);
plot(
linearray( iif(btczlong, ahpividxs[0], alpividxs[0]),
tcz786, curbar, tcz786, 0),
"tcz786", colorturquoise, styleline);
}

// -- if (bshowtcz)
}

if (bdraw) {
title = name() + " (" + strleft(fullname(), 10) +
") atr: " + numtostr(atr(1), 4.2) + " ( " +
numtostr((c - ref(c, -1)), 4.2) + " / " +
numtostr((((c - ref(c, -1)) / ref(c, -1)) * 100), 2.1) + "% ) " +
writeval( selectedvalue( datetime() ), formatdatetime) +
" \no: " + open +
", \nh: " + high +
", \nl: " + low +
", \nc: " + close + ", \n" +
// "risk: " + writeval(risk, 2.1) + "% \n" +
"rtrc 0/1 pts: " + writeval(nrtrc0pts, 2.1) + "/" +
writeval(nrtrc1pts, 2.1) + " \n" +
"rtrc 0/1 bars: " + writeval(nrtrc0bars, 2.0) + "/" +
writeval(nrtrc1bars, 2.0);
}

// **************************
// end indicator code
// **************************

الله يعطيك العافية....
نجرب ونشوووف ...بارك الله فيك
عزيز77 غير متواجد حالياً   رد مع اقتباس
قديم 04-06-2014, 02:56 PM   #11
haat
عضو هوامير المميز
 
تاريخ التسجيل: Dec 2011
المشاركات: 296

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

شكرا لك

وبارك الله فيك
haat غير متواجد حالياً   رد مع اقتباس
قديم 05-06-2014, 08:42 AM   #12
alfaf
عضو موقوف
 
تاريخ التسجيل: Aug 2007
المشاركات: 10,342

رد: حلل سهمك بإستخدام Amibroker خبرات وتجارب - ملف وورد

بارك الله فيك
alfaf غير متواجد حالياً   رد مع اقتباس
إضافة رد



مواقع النشر (المفضلة)

أدوات الموضوع
انواع عرض الموضوع

تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة

الانتقال السريع




02:38 AM


الاعلان بمنتدى هوامير البورصة
تشغيل وتطوير افاق الإقتصاد
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
جميع المواضيع و الردود المطروحة لا تعبر عن رأي المنتدى بل تعبر عن رأي كاتبها وقرار البيع والشراء مسؤليتك وحدك

بناء على نظام السوق المالية بالمرسوم الملكي م/30 وتاريخ 2/6/1424هـ ولوائحه التنفيذية الصادرة من مجلس هيئة السوق المالية: تعلن الهيئة للعموم بانه لا يجوز جمع الاموال بهدف استثمارها في اي من اعمال الاوراق المالية بما في ذلك ادارة محافظ الاستثمار او الترويج لاوراق مالية كالاسهم او الاستتشارات المالية او اصدار التوصيات المتعلقة بسوق المال أو بالاوراق المالية إلا بعد الحصول على ترخيص من هيئة السوق المالية.