logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
penguin  
#1 Posted : Monday, August 20, 2012 12:57:49 AM(UTC)
penguin

Rank: Newbie

Groups: Registered, Registered Users
Joined: 8/19/2012(UTC)
Posts: 7

I am starting out in using the MDK. I would like to find out that did anyone try to draw a swing line using MDK. Something similar to the ZigZag function. Thank you
wabbit  
#2 Posted : Monday, August 20, 2012 6:59:47 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Returning values for these sort of lines is easy. Iterate through the chart twice, the first is to define the points, then the second is to fill in the values between the points found in the first pass (you can also do it one pass using internal loops).


wabbit [:D]

penguin  
#3 Posted : Tuesday, August 21, 2012 4:02:30 AM(UTC)
penguin

Rank: Newbie

Groups: Registered, Registered Users
Joined: 8/19/2012(UTC)
Posts: 7

Thanks for the reply. Any simple code snippets.
wabbit  
#4 Posted : Tuesday, August 21, 2012 8:41:13 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Modified ZZ (snippet)

Code:

for(int i=l_iMinRecords; i<=l_iMaxRecords; i++)
{
 l_lfHigh = a_psDataRec->sHigh.pfValue[ i ];
 l_lfLow = a_psDataRec->sLow.pfValue[ i ];
 l_lfRetracement = fabs(l_psRetracement->pfValue[ i ]);

 if(i==l_iMinRecords)
 {
 l_lfLastPeakPrice = l_lfHigh;
 l_lfLastTroughPrice = l_lfLow;
 l_iLastPeakIndex = i;
 l_iLastTroughIndex = i;
 }
 else
 {
 if(l_iDirection!=UP)
 {
 if(l_iMethod==0)//pct
 l_lfTriggerPrice = l_lfLastTroughPrice * (1.0f + l_lfRetracement);
 else
 l_lfTriggerPrice = l_lfLastTroughPrice + l_lfRetracement;
 }
 else
 {
 if(l_iMethod==0)//pct
 l_lfTriggerPrice = l_lfLastPeakPrice * (1.0f - l_lfRetracement);
 else
 l_lfTriggerPrice = l_lfLastPeakPrice - l_lfRetracement;
 }

 if(l_iDirection != UP && l_lfHigh > l_lfTriggerPrice) //retracement forms a new TROUGH
 {
 l_lfLastPeakPrice = l_lfHigh;
 l_iLastPeakIndex = i;
 l_iDirection = UP;
 }
 else if(l_iDirection != DN && l_lfLow < l_lfTriggerPrice) // retracement forms a new PEAK
 {
 l_lfLastTroughPrice = l_lfLow;
 l_iLastTroughIndex = i;
 l_iDirection = DN;
 }
 else if(l_iDirection == UP && l_lfHigh>=l_lfLastPeakPrice) // continuation of the uptrend following a recent trough
 {
 l_lfLastPeakPrice = l_lfHigh;
 l_iLastPeakIndex = i;
 l_iDirection = UP;
 }
 else if(l_iDirection == DN && l_lfLow<=l_lfLastTroughPrice) //continuation of downtrend following a recent peak
 {
 l_lfLastTroughPrice = l_lfLow;
 l_iLastTroughIndex = i;
 l_iDirection = DN;
 }
 }

 {... lots more to do here ...}
}



wabbit [:D]

penguin  
#5 Posted : Tuesday, August 21, 2012 9:00:53 PM(UTC)
penguin

Rank: Newbie

Groups: Registered, Registered Users
Joined: 8/19/2012(UTC)
Posts: 7

Hi wabbit, This will be a great help to me. Thank you. Regards penguin
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.