How to code? - page 231

 

Excellent, thanks!

 

man, arrays and functions, not my cup of tea.

 

Help for EA

I want to do the following:

Using M15 frames and opening during this interval two orders maximum by comparing the current price with the previous M15 close(close[1]). However, I do not know how to write the code for that since I want this procedure to be taken place every following M15 frame. How to keep the right variables for counting 2 orders in maximum every M15 since the start function always executes itself?

Thank you

 

Need Help with an Open Pending Orders script.

I know there are a lot of scripts on here that open and close orders but I can't find one that will open pending orders.

What I need is 2 scripts, 1 Sellstop and 1 Buystop.

I would like the Buystop to open a Buystop order 15 pips above the daily Pivot and the SellStop to open 15 pips below the Daily pivot.

I have played around with it and got the code below for a SellStop, but I am not a coder and it doesn't work. I quess I have let something out.

Can anyone help me with this, Please.

PS. nevermind, I got it. I had to change my Bid price to the PVTGreen . I was getting a 130 error..

It works now...

Ok, One more problem, Can someone tell me how to change the Expiration time from 24hrs later to 22:00 same day.

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

//| script "send pending order with expiration data" |

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

int start()

{

int ticket,expiration;

double point;

double PVTYellow = iCustom(NULL, 0, "pivot_alllevels", 0, 0, 0);

double PVTBlue = iCustom(NULL, 0, "pivot_alllevels", 0, 1, 0);

double PVTGreen = iCustom(NULL, 0, "pivot_alllevels", 0, 2, 0);

double PVTRed = iCustom(NULL, 0, "pivot_alllevels", 0, 3, 0);

double PVTMagenta = iCustom(NULL, 0, "pivot_alllevels", 0, 4, 0);

//----

point=MarketInfo(Symbol(),MODE_POINT);

expiration=TimeCurrent()+PERIOD_D1*60;

//----

while(true)

{

ticket = OrderSend(Symbol(),OP_SELLSTOP, 0.10, PVTGreen-15*Point, 3, PVTGreen+20*Point, PVTGreen-20*Point, 0,0,expiration,Red);

if(ticket<=0) Print("Error = ",GetLastError());

else { Print("ticket = ",ticket); break; }

//---- 10 seconds wait

Sleep(10000);

}

//----

return(0);

}

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

To make the expiration 22:00 you could do this...

int iHour = TimeHour(TimeCurrent());

int iMinute = TimeMinute(TimeCurrent());

int iDiff = 22%iHour;

datetime dtExpiryDate = (TimeCurrent()+(iDiff*60*60))-(iMinute*60);

Print(TimeToStr(dtExpiryDate));

There's no error checking so if you think you'll need it be sure to add it.

Lux

 

Grab Market Watch Symbols

Hi Everyone,

I was wondering if there is a way to grab all the symbols available in market watch for monitoring instead of manually feeding the EA?

in other words i want my EA to go through whatever symbol that is available in the market watch window and monitor them for a certain criteria.

any help is greatly appreciated.

 

Help me - Account Balance Sunday

Hi,

I'm trying since yesterday to tinker a cache of my all week since the Account Balance Sunday (market success Opening) reveals.

I need To bring to run an EA Account Balance of Sunday at the market success Opening to the Equity Manager correctly.

double usedacc = 0;

...

if (usedacc == 0 | | DayOfWeek () == 0) usedacc = Account Balance ();

...

Just does not work

Maybe someone can help me as I best l Can

Sorry to the bad English

 

please delete this post - thx

 

how do I get data from indicator

Hi all,

i need for an EA for the values FIBO100 and FIBO0 from the indicator. How do I get it ?

Thanks

derumuro

Files:
 

How do you get it?

Mate I struck a similar problem

Scott

"inter script" communication (or "inter indicator" communication) in MQL goes exclusively throught buffers. This code :

trendset = iCustom(NULL,0,"VGA HISTOGRAM~",0,0);

Means that you want to retreive the value for the current bar from the first (public) buffer of "VGA HISTOGRAM~" indicator. You can not retreive values of variables declared in other indicator (and it does not matter if they are declared as external) You might try with global variables, but global variables are drag to work with and offer more chance to make an error than to work properly with them or you can write a DLL (metatrader uses only one instance of a DLL per chart, regardless of the parameters, so you can make a kind of a "semaphore" that would hold and return values values depending on IDs of any sort - that would ensure inter mql code communication and would avoid wrong variables reading (global variables for example can be easily mistaken and you can read variables from a completely different chart without even knowing it))

regards

Mladen

I actually made a work around for this I will share with you.

In your indicator make a new function so things dont get messy.

void PASSINFO() {

int trendcondtemp; //change this to your desired name it matters not, leave it if your lazy

if (Close[1] > Open[2] && Volume[1] < Volume[2]) trendcondtemp=1; //bullish - this just sets a value to the variable use your code

if (Close[1] < Open[2] && Volume[1] < Volume[2]) trendcondtemp=2; //bearish - same thing different smell

if (Volume[1] > Volume[2])trendcondtemp=3; //fuckall happening - meh

if (Symbol()=="USDCHF") GlobalVariableSet("TRENDSETUSDCHF ",trendcondtemp);

if (Symbol()=="GBPUSD") GlobalVariableSet("TRENDSETGBPUSD",trendcondtemp);

if (Symbol()=="EURUSD") GlobalVariableSet("TRENDSETEURUSD",trendcondtemp);

if (Symbol()=="USDJPY") GlobalVariableSet("TRENDSETUSDJPY",trendcondtemp);

if (Symbol()=="USDCAD") GlobalVariableSet("TRENDSETUSDCAD",trendcondtemp);

if (Symbol()=="NZDUSD") GlobalVariableSet("TRENDSETNZDUSD",trendcondtemp);

if (Symbol()=="AUDUSD") GlobalVariableSet("TRENDSETAUDUSD",trendcondtemp);

if (Symbol()=="AUDNZD") GlobalVariableSet("TRENDSETAUDNZD",trendcondtemp);

if (Symbol()=="AUDCAD") GlobalVariableSet("TRENDSETAUDCAD",trendcondtemp);

if (Symbol()=="EURUSD") GlobalVariableSet("TRENDSETEURUSD",trendcondtemp);

if (Symbol()=="AUDCHF") GlobalVariableSet("TRENDSETAUDCHF",trendcondtemp);

if (Symbol()=="AUDJPY") GlobalVariableSet("TRENDSETAUDJPY",trendcondtemp);

if (Symbol()=="CHFJPY") GlobalVariableSet("TRENDSETCHFJPY",trendcondtemp);

if (Symbol()=="EURGBP") GlobalVariableSet("TRENDSETEURGBP",trendcondtemp);

if (Symbol()=="EURAUD") GlobalVariableSet("TRENDSETEURAUD",trendcondtemp);

if (Symbol()=="EURCHF") GlobalVariableSet("TRENDSETEURCHF",trendcondtemp);

if (Symbol()=="EURJPY") GlobalVariableSet("TRENDSETEURJPY",trendcondtemp);

if (Symbol()=="EURNZD") GlobalVariableSet("TRENDSETEURNZD",trendcondtemp);

if (Symbol()=="GBPCHF") GlobalVariableSet("TRENDSETGBPCHF",trendcondtemp);

if (Symbol()=="GBPAUD") GlobalVariableSet("TRENDSETGBPAUD",trendcondtemp);

if (Symbol()=="GBPCAD") GlobalVariableSet("TRENDSETGBPCAD",trendcondtemp);

if (Symbol()=="GBPJPY") GlobalVariableSet("TRENDSETGBPJPY",trendcondtemp);

if (Symbol()=="NZDJPY") GlobalVariableSet("TRENDSETNZDJPY",trendcondtemp);

//add oil/gold/sheckles/whatever you trade after this I covered all that my broker does

}

Ok now because its currency dependent theres no chance of it crossing with another currency and stuffing the values up. You now have to put this into your start / whatever function prior to you calling the value.

int trendset;

if (Symbol()=="USDCHF") trendset= GlobalVariableGet("TRENDSETUSDCHF");

if (Symbol()=="GBPUSD") trendset= GlobalVariableGet("TRENDSETGBPUSD");

if (Symbol()=="EURUSD") trendset= GlobalVariableGet("TRENDSETEURUSD");

if (Symbol()=="USDJPY") trendset= GlobalVariableGet("TRENDSETUSDJPY");

if (Symbol()=="USDCAD") trendset= GlobalVariableGet("TRENDSETUSDCAD");

if (Symbol()=="NZDUSD") trendset= GlobalVariableGet("TRENDSETNZDUSD");

if (Symbol()=="AUDUSD") trendset= GlobalVariableGet("TRENDSETAUDUSD");

if (Symbol()=="AUDNZD") trendset= GlobalVariableGet("TRENDSETAUDNZD");

if (Symbol()=="AUDCAD") trendset= GlobalVariableGet("TRENDSETAUDCAD");

if (Symbol()=="EURUSD") trendset= GlobalVariableGet("TRENDSETEURUSD");

if (Symbol()=="AUDCHF") trendset= GlobalVariableGet("TRENDSETAUDCHF");

if (Symbol()=="AUDJPY") trendset= GlobalVariableGet("TRENDSETAUDJPY");

if (Symbol()=="CHFJPY") trendset= GlobalVariableGet("TRENDSETCHFJPY");

if (Symbol()=="EURGBP") trendset= GlobalVariableGet("TRENDSETEURGBP");

if (Symbol()=="EURAUD") trendset= GlobalVariableGet("TRENDSETEURAUD");

if (Symbol()=="EURCHF") trendset= GlobalVariableGet("TRENDSETEURCHF");

if (Symbol()=="EURJPY") trendset= GlobalVariableGet("TRENDSETEURJPY");

if (Symbol()=="EURNZD") trendset= GlobalVariableGet("TRENDSETEURNZD");

if (Symbol()=="GBPCHF") trendset= GlobalVariableGet("TRENDSETGBPCHF");

if (Symbol()=="GBPAUD") trendset= GlobalVariableGet("TRENDSETGBPAUD");

if (Symbol()=="GBPCAD") trendset= GlobalVariableGet("TRENDSETGBPCAD");

if (Symbol()=="GBPJPY") trendset= GlobalVariableGet("TRENDSETGBPJPY");

if (Symbol()=="NZDJPY") trendset= GlobalVariableGet("TRENDSETNZDJPY");

Please Note!!! (you prolly already realize this) but you gotta have the indicator running on your currency your ea is running on for the values to change else you will just get the old variable thats stored for weeks in mt4.