Ask! - page 175

 

Ah thats a much better method. I was fiddling with if (Ask == OrderTakeProfit()) {..} cycling through every open order which i think was a bit flawed when back testing. Thanks!

 

How do you comment a number that will comment a string?

string 2;

2="EURUSD";

HOW DO I CREATE A COMMENT WHERE 2 WILL COMMENT AS EURUSD ON THE GRAPH??

PLEASE HELP - CONFUSED!

DAVE

 

You can not do that in mql.

In mql a variable name can not be a number nor can it start with number, so the only solution is to add some letter, underscore or some allowed character in front of the "2"

1Dave7:
string 2;

2="EURUSD";

HOW DO I CREATE A COMMENT WHERE 2 WILL COMMENT AS EURUSD ON THE GRAPH??

PLEASE HELP - CONFUSED!

DAVE
 

How do i do an array in descending order on the following:

double D0=0,D1=0,D2=0,D3=0,D4=0,D5=0,D6=0,D7=0);

D0=iCustom(NULL,0,"XYZ",0,0);

D1=iCustom(NULL,0,"XYZ",1,0);

D2=iCustom(NULL,0,"XYZ",2,0);

D3=iCustom(NULL,0,"XYZ",3,0);

D4=iCustom(NULL,0,"XYZ",4,0);

D5=iCustom(NULL,0,"XYZ",5,0);

D6=iCustom(NULL,0,"XYZ",6,0);

D7=iCustom(NULL,0,"XYZ",7,0);

HOW DO I DO A INITIALIZE A DESCENDING ARRAY OF THE VALUES OF (D0,D1,D2,D3,D4,D5,D6,D7)?? HOW DO I ADDRESS THE RESULTS OF THE ARRAY IN MY EA?

APPRECIATE YOUR HELP - I WILL BE VERY HAPPY IF I CAN GET PAST THIS BOTTLE NECK!

Dave

 

If you need only the values sorted, you can do something like this :

double array[8];

array[0]=iCustom(NULL,0,"XYZ",0,0);

array[1]=iCustom(NULL,0,"XYZ",1,0);

array[2]=iCustom(NULL,0,"XYZ",2,0);

array[3]=iCustom(NULL,0,"XYZ",3,0);

array[4]=iCustom(NULL,0,"XYZ",4,0);

array[5]=iCustom(NULL,0,"XYZ",5,0);

array[6]=iCustom(NULL,0,"XYZ",6,0);

array[7]=iCustom(NULL,0,"XYZ",7,0);

ArraySort(array,WHOLE_ARRAY,0,MODE_ASCEND);

and then the sorted values will be in the "array" array

1Dave7:
double D0=0,D1=0,D2=0,D3=0,D4=0,D5=0,D6=0,D7=0);

D0=iCustom(NULL,0,"XYZ",0,0);

D1=iCustom(NULL,0,"XYZ",1,0);

D2=iCustom(NULL,0,"XYZ",2,0);

D3=iCustom(NULL,0,"XYZ",3,0);

D4=iCustom(NULL,0,"XYZ",4,0);

D5=iCustom(NULL,0,"XYZ",5,0);

D6=iCustom(NULL,0,"XYZ",6,0);

D7=iCustom(NULL,0,"XYZ",7,0);

HOW DO I DO A INITIALIZE A DESCENDING ARRAY OF THE VALUES OF (D0,D1,D2,D3,D4,D5,D6,D7)?? HOW DO I ADDRESS THE RESULTS OF THE ARRAY IN MY EA?

APPRECIATE YOUR HELP - I WILL BE VERY HAPPY IF I CAN GET PAST THIS BOTTLE NECK!

Dave
 
mladen:
If you need only the values sorted, you can do something like this :
double array[8];

array[0]=iCustom(NULL,0,"XYZ",0,0);

array[1]=iCustom(NULL,0,"XYZ",1,0);

array[2]=iCustom(NULL,0,"XYZ",2,0);

array[3]=iCustom(NULL,0,"XYZ",3,0);

array[4]=iCustom(NULL,0,"XYZ",4,0);

array[5]=iCustom(NULL,0,"XYZ",5,0);

array[6]=iCustom(NULL,0,"XYZ",6,0);

array[7]=iCustom(NULL,0,"XYZ",7,0);

ArraySort(array,WHOLE_ARRAY,0,MODE_ASCEND);

and then the sorted values will be in the "array" array

WOW!!!!!!!!!!!! I would of never have figured that out - Thanks a whole bunch!!!

 

Please help getting this array working - Puzzled!!!

[/PHP] EUR=(iMA("EURUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("EURUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i+Delta)); //RED

GBP=(iMA("GBPUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("GBPUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i+Delta)); //LIME

double array[7];

array[0]=iCustom(NULL,0,"EURUSD",0,0);

array[1]=iCustom(NULL,0,"GBPUSD",1,0);

array[2]=iCustom(NULL,0,"AUDUSD",2,0);

array[3]=iCustom(NULL,0,"USDCHF",3,0);

array[4]=iCustom(NULL,0,"USDJPY",4,0);

array[5]=iCustom(NULL,0,"NZDUSD",5,0);

array[6]=iCustom(NULL,0,"USDCAD",6,0);

ArraySort(array,WHOLE_ARRAY,0,MODE_ASCEND);

a=array[0];b=array[1];c=array[2];d=array[3];e=array[4];f=array[5];g=array[6];

{

ObjectCreate("DISPLAY10", OBJ_LABEL, 1, 0, 0);

ObjectSetText("DISPLAY10", DoubleToStr(a,0), 10, "ArialBold", Red);//"EURUSD =" ,

ObjectSet("DISPLAY10", OBJPROP_CORNER, 1);

ObjectSet("DISPLAY10", OBJPROP_XDISTANCE, 80);

ObjectSet("DISPLAY10", OBJPROP_YDISTANCE, 20);

//return(0);

}

{

ObjectCreate("DISPLAY20", OBJ_LABEL, 1, 0, 0);

ObjectSetText("DISPLAY20", DoubleToStr(b,0), 10, "ArialBold", Lime);//"GBPUSD =" ,

ObjectSet("DISPLAY20", OBJPROP_CORNER, 1);

ObjectSet("DISPLAY20", OBJPROP_XDISTANCE, 80);

ObjectSet("DISPLAY20", OBJPROP_YDISTANCE, 40);

//return(0);

}

[PHP]

I tried to get a value for a,b and display it, but only shows 0 for a, and 0 for b and all the other c-f values. I was hoping to get a ascending order of the currencies. Can you help figure out why this is not working???

I wish I could buy you a beer for your help!

 

Check lines that go like this :

array[0]=iCustom(NULL,0,"EURUSD",0,0);

That line means that you have an indicator called "EURUSD" and that you are calling it to get some value and assign it to 1st element of "array". If it does not exist (the indicator with that name, which I asume is true) it will assign value 0 to the array element. What are you exactly trying to retrieve with that line?

1Dave7:
EUR=(iMA("EURUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("EURUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i+Delta)); //RED

GBP=(iMA("GBPUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("GBPUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i+Delta)); //LIME

double array[7];

array[0]=iCustom(NULL,0,"EURUSD",0,0);

array[1]=iCustom(NULL,0,"GBPUSD",1,0);

array[2]=iCustom(NULL,0,"AUDUSD",2,0);

array[3]=iCustom(NULL,0,"USDCHF",3,0);

array[4]=iCustom(NULL,0,"USDJPY",4,0);

array[5]=iCustom(NULL,0,"NZDUSD",5,0);

array[6]=iCustom(NULL,0,"USDCAD",6,0);

ArraySort(array,WHOLE_ARRAY,0,MODE_ASCEND);

a=array[0];b=array[1];c=array[2];d=array[3];e=array[4];f=array[5];g=array[6];

{

ObjectCreate("DISPLAY10", OBJ_LABEL, 1, 0, 0);

ObjectSetText("DISPLAY10", DoubleToStr(a,0), 10, "ArialBold", Red);//"EURUSD =" ,

ObjectSet("DISPLAY10", OBJPROP_CORNER, 1);

ObjectSet("DISPLAY10", OBJPROP_XDISTANCE, 80);

ObjectSet("DISPLAY10", OBJPROP_YDISTANCE, 20);

//return(0);

}

{

ObjectCreate("DISPLAY20", OBJ_LABEL, 1, 0, 0);

ObjectSetText("DISPLAY20", DoubleToStr(b,0), 10, "ArialBold", Lime);//"GBPUSD =" ,

ObjectSet("DISPLAY20", OBJPROP_CORNER, 1);

ObjectSet("DISPLAY20", OBJPROP_XDISTANCE, 80);

ObjectSet("DISPLAY20", OBJPROP_YDISTANCE, 40);

//return(0);

}

I tried to get a value for a,b and display it, but only shows 0 for a, and 0 for b and all the other c-f values. I was hoping to get a ascending order of the currencies. Can you help figure out why this is not working???

I wish I could buy you a beer for your help!
 
mladen:
Check lines that go like this :
array[0]=iCustom(NULL,0,"EURUSD",0,0);
That line means that you have an indicator called "EURUSD" and that you are calling it to get some value and assign it to 1st element of "array". If it does not exist (the indicator with that name, which I asume is true) it will assign value 0 to the array element. What are you exactly trying to retrieve with that line?

The array is to get a value from "EURUSD", then to do a ascending order from low to high compared to other currencies, and then to display the rankings of low to the screen. EURUSD like the other currencies just give me a 0.00?? What am I doing wrong here??

 

Do it like this:

array[0]=iClose("EURUSD",0,0); [/PHP]

and so on. That way array will be filled with close prices for symbols you select. If you are using a custom indicator then the form is the following :

[PHP]array[0]=iCustom("EURUSD",0,"indicator name",0,0);
1Dave7:
The array is to get a value from "EURUSD", then to do a ascending order from low to high compared to other currencies, and then to display the rankings of low to the screen. EURUSD like the other currencies just give me a 0.00?? What am I doing wrong here??