Ask! - page 173

 

Howto solve the lack of mixed type datastructure

codersguru:
Hi folks,

I've got a lot of private messages asking me for helping with some pieces of code.

Here you can post your questions related to MQL4, and I'll do my best to answer them.

Hello,

I would like to use your invitation to pose the following problem.

What would be the best solution to storing and sorting a list of symbols based on their price changes since one cannot use a mixed type datastructure like: EURUSD->1.29, USDGBP->0.22 ?

There is no enum and there are no mixed type data structures that can hold a string and a related double value in mql4. The solutions I can think of is either to use a file, but that would require almost constant disk reading and writing activity. Or to use three arrays; 1 for the symbol list, one for the storage and tracking of index place values and one for the actual values.

Seems one has to code arround a very basic (simple) problem. The only thing I would like is to compare all the euro pairs to each other for relative strength. How would you solve this, what datastructure would you recommend ?

Thank's for any answers or directions to this newbie !

Bibberpool

 

Search For Relative Strength and Correlation Indicators

liverpool:
Hello,

What would be the best solution to storing and sorting a list of symbols based on their price changes since one cannot use a mixed type datastructure like: EURUSD->1.29, USDGBP->0.22 ?

...

Seems one has to code arround a very basic (simple) problem. The only thing I would like is to compare all the euro pairs to each other for relative strength. How would you solve this, what datastructure would you recommend ?

Thank's for any answers or directions to this newbie ! Bibberpool

Hi Bibberpool,

Search this Forex TSD site for Relative Strength indicators and Correlation indicators...

These type of indicators are designed to analyze different pairs and prices and their relative strengths.

You may find good examples for what you want to do.

Hope this helps,

Robert

 

Thank you for your answer

cosmiclifeform:
Hi Bibberpool,

Search this Forex TSD site for Relative Strength indicators and Correlation indicators...

These type of indicators are designed to analyze different pairs and prices and their relative strengths.

You may find good examples for what you want to do.

Hope this helps,

Robert

Hi thank you for your answer and I will certainly search the suggested threads. However there is just so much code arround.

In the meanwhile I did a short prototype in C. Just took a basic insertion sort since the data consists only out of small sets and updated that routine to update a string array accordingly.

I will (copy/paste) port it to my first mql4 program later this week. Here's the code maybe it's usefull to others or someone wants to comment on it to create something better.

#include

int main(void) {

int max = 5;

int array[5] = { 3, 5, 2, 1, 4 };

char *symbl[5] = { "EURUSD", "EURGBP", "EURJPY", "EURCHF", "EURCAD" };

int idx = 0;

int swp = 0;

int tmp = 0;

char *tmpsymb = NULL;

printf("--- before\n");

for(idx = 0; idx <= max - 1; idx++) {

printf("%d - %s\n", array, symbl);

}

for(idx = 1 ; idx <= max - 1; idx++) {

swp = idx;

while(swp > 0 && array[swp] < array[swp - 1]) {

tmp = array[swp];

tmpsymb = symbl[swp];

array[swp] = array[swp - 1];

symbl[swp] = symbl[swp - 1];

array[swp - 1] = tmp;

symbl[swp - 1] = tmpsymb;

swp--;

}

}

printf("--- after\n");

for(idx = 0; idx <= max - 1; idx++) {

printf("%d - %s\n", array, symbl);

}

return 0;

}

the program should print:

--- before

3 - EURUSD

5 - EURGBP

2 - EURJPY

1 - EURCHF

4 - EURCAD

--- after

1 - EURCHF

2 - EURJPY

3 - EURUSD

4 - EURCAD

5 - EURGBP

 

Looking for indies from author Kravchuk

Hi Community,

I am looking for indies from author Kravchuk, who designs indies for sell. I was willing to buyu but we can't recomcile on form of payment (not amount!?). Does anyone have his indies ft.dejavu, ft .rainbow,barstatline,diver,linerenko? I would appreciate your help. Thank you

 
bershk:
Hi Community, I am looking for indies from author Kravchuk, who designs indies for sell. I was willing to buyu but we can't recomcile on form of payment (not amount!?). Does anyone have his indies ft.dejavu, ft .rainbow,barstatline,diver,linerenko? I would appreciate your help. Thank you

Hi bershk,

If your request isn't obsolete yet we may help here - we did work with some of these indicators.

Please note you should buy license from the author and we don't provide any decompiled or illegally obtained stuff.

If you are interested to buy - here are current prices from the author:

Dejavu - $20; Rainbow - $15; Barstatline - $10; Diver - $20; LineRenko - $15.

If you need help to purchase them please write us to info@raitsoft.com, we will help to buy license without any commission.

 

hallo friends ...................

i have been starting learning to program in mql4, and for start iam analayzing idicators and ea .

i heve "daily_close _line" indicator and i looked at the code and run out thise tow lines of code which i heve no idea what they are doing and how they work.

may same one please take a look at the code and tell me whats going on.

thanks a loot in advance.

eran

//*

//* my_DailyOpen_indicator

//*

//* Revision 1.1 2005/11/13 Midnite

//* Initial DailyOpen indicator

//* based pm

//*

#property copyright "Midnite"

#property link "me@home.net"

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 DodgerBlue

#property indicator_style1 2

#property indicator_width1 1

double TodayOpenBuffer[];

extern int TimeZoneOfData= 0;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,TodayOpenBuffer);

SetIndexLabel(0,"Open");

SetIndexEmptyValue(0,0.0);

return(0);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int lastbar;

int counted_bars= IndicatorCounted();

if (counted_bars>0) counted_bars--;

lastbar = Bars-counted_bars;

DailyOpen(0,lastbar);

return (0);

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int DailyOpen(int offset, int lastbar)

{

int shift;

int tzdiffsec= TimeZoneOfData * 3600;

double barsper30= 1.0*PERIOD_M30/Period();

bool ShowDailyOpenLevel= True;//<<<<---------- thise line-------------------------------

// lastbar+= barsperday+2; // make sure we catch the daily open

lastbar= MathMin(Bars-20*barsper30-1, lastbar);//<<<<-------------------thise line-----------------------

for(shift=lastbar;shift>=offset;shift--){

TodayOpenBuffer[shift]= 0;

if (ShowDailyOpenLevel){

if(TimeDay(Time[shift]-tzdiffsec) != TimeDay(Time[shift+1]-tzdiffsec)){ // day change

TodayOpenBuffer[shift]= Open[shift];

TodayOpenBuffer[shift+1]= 0; // avoid stairs in the line

}

else{

TodayOpenBuffer[shift]= TodayOpenBuffer[shift+1];

}

}

}

return(0);

}
 

ERAN123

It is doing the following : it finds the daily open price (taking into account TimeZoneOfData as time zone shift) and draws that line through that day. Here is a picture at which it us easy to see how it draws the same daily open price trough the day :

ERAN123:
i have been starting learning to program in mql4, and for start iam analayzing idicators and ea .

i heve "daily_close _line" indicator and i looked at the code and run out thise tow lines of code which i heve no idea what they are doing and how they work.

may same one please take a look at the code and tell me whats going on.

thanks a loot in advance.

eran

//*

//* my_DailyOpen_indicator

//*

//* Revision 1.1 2005/11/13 Midnite

//* Initial DailyOpen indicator

//* based pm

//*

#property copyright "Midnite"

#property link "me@home.net"

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 DodgerBlue

#property indicator_style1 2

#property indicator_width1 1

double TodayOpenBuffer[];

extern int TimeZoneOfData= 0;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,TodayOpenBuffer);

SetIndexLabel(0,"Open");

SetIndexEmptyValue(0,0.0);

return(0);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int lastbar;

int counted_bars= IndicatorCounted();

if (counted_bars>0) counted_bars--;

lastbar = Bars-counted_bars;

DailyOpen(0,lastbar);

return (0);

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int DailyOpen(int offset, int lastbar)

{

int shift;

int tzdiffsec= TimeZoneOfData * 3600;

double barsper30= 1.0*PERIOD_M30/Period();

bool ShowDailyOpenLevel= True;//<<<<---------- thise line-------------------------------

// lastbar+= barsperday+2; // make sure we catch the daily open

lastbar= MathMin(Bars-20*barsper30-1, lastbar);//<<<<-------------------thise line-----------------------

for(shift=lastbar;shift>=offset;shift--){

TodayOpenBuffer[shift]= 0;

if (ShowDailyOpenLevel){

if(TimeDay(Time[shift]-tzdiffsec) != TimeDay(Time[shift+1]-tzdiffsec)){ // day change

TodayOpenBuffer[shift]= Open[shift];

TodayOpenBuffer[shift+1]= 0; // avoid stairs in the line

}

else{

TodayOpenBuffer[shift]= TodayOpenBuffer[shift+1];

}

}

}

return(0);

}
Files:
daly_open.gif  30 kb
 
mladen:
ERAN123

It is doing the following : it finds the daily open price (taking into account TimeZoneOfData as time zone shift) and draws that line through that day. Here is a picture at which it us easy to see how it draws the same daily open price trough the day :

sory i ment thise line :

double barsper30= 1.0*PERIOD_M30/Period();

and thise one also.

lastbar= MathMin(Bars-20*barsper30-1, lastbar);

for what the "20" and "-1" and how the 2 lines work together?

thank you a loot.

 

Originally wrote something else.

Forget about those lines : they are, for some reason trying to limit the start where values are started to be calculated (and that should be some hours from the oldest bar on chart). What did the coder want to achieve with it maybe known only to him

ERAN123:
sory i ment thise line :

double barsper30= 1.0*PERIOD_M30/Period();

and thise one also.

lastbar= MathMin(Bars-20*barsper30-1, lastbar);

for what the "20" and "-1" and how the 2 lines work together?

thank you a loot.
 

thanks a loot my friend .....you helped me