You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Need Help with iCustom function for this EA can Call an custom indicator.
Hi, Everyone,
I would like to add this (Entry.mq4) indi to this (swb grid 4.1.0.3_EA) EA with
iCustom function so I and we could use this indicator in the strategy of the EA.
the EA already uses 3 MT4 indicators Bollinger Bands , Stochastic and RSI and have
switches , so you can select either or all of them to be used , by selecting TRUE or FALSE
and I would like to add this 4th indi(Entry.mq4) to the EA.
I would appreciated very much if any one could help me.
thank you.
the EA and indi attached bellow.
Noob MQL4 help needed to understand this array
Hi, coders
Would anyone care to educate me on arrays slightly
Or perhaps I'm having more trouble understanding this loop as it pertains to this array.
#property copyright "Unfinished POS by Agent86"
double v1[];
double v2[];
double val1;
double val2;
int start()
{
while(i>=0)
{
val1=iFractals(NULL, 0, MODE_UPPER,i);
if (val1 > 0)
{
v1=High;
}
else
{
v1=v1;
}
val2=iFractals(NULL, 0, MODE_LOWER,i);
if (val2 > 0)
{
v2=Low;
}
else v2=v2;
i--;
}
return(0);
}
It's a basic fractal, and yet I can't seem to refer to any elements in the array.
I want to be able to increment i++ somehow and Print (v1); or print the previous value prior to the 0 or EMPTY_VALUE.
If I'm even going in the right direction with this.
I'm having trouble.
Print (v1): always == 0 and prints 0
I sort of understand because it's actually looping down to -1 which == 0
How and where might I put the Print statements so I can see whats going on ?
I've tried multitudes or methods and re-initialized i=0 to attempt and alternate loop so that I might refer to v1 elements but all attempts have failed.
Basically I want to view the previous fractals or mark them as A high, B low etc. for possible future use in an ABCD scheme type of EA
For now, mainly I want to Print v1 so that I can see what it's doing.
Perhaps I might design something to select a Previous Fractal such as A_high and/or B_low or some such scheme.
Am I on the wrong track with this ?
Please advise
Thanks
I would go with A FOR loop instead. While loops can lead to lockups if you forget to include the i--. Since you know the exact number of bars, it's easier to use, plus the i will never be < 0. It helps avoid confusion.
For (int i=Bars-1;i>0;i--) {
// code
}
Try setting all of the array values to 0, then go back through and assign indicator values. Also, try a print() directly after assigning your indicator value. See if it's actually returning anything at all.
Your best bet, in my guess, is to actually assign a size to the array. Say, 1000 positions. You're unlikely to need that many, plus it will reduce the calculations you're doing. All you need to do then is loop through the last 999 bars to 0 and assign values. I seem to recall MT4 has problems with array initilizations and whatnot.
Array Questions
I would go with A FOR loop instead. While loops can lead to lockups if you forget to include the i--. Since you know the exact number of bars, it's easier to use, plus the i will never be < 0. It helps avoid confusion.
For (int i=Bars-1;i>0;i--) {
// code
}
Try setting all of the array values to 0, then go back through and assign indicator values. Also, try a print() directly after assigning your indicator value. See if it's actually returning anything at all.
Your best bet, in my guess, is to actually assign a size to the array. Say, 1000 positions. You're unlikely to need that many, plus it will reduce the calculations you're doing. All you need to do then is loop through the last 999 bars to 0 and assign values. I seem to recall MT4 has problems with array initilizations and whatnot.Ok, thanks I'll try it.
Although the while statements are working well, it's not helping me to get the array elements I want to print / view etc.
I'll work on what you said and do some testing and post back.
Thanks
I would go with A FOR loop instead. While loops can lead to lockups if you forget to include the i--. Since you know the exact number of bars, it's easier to use, plus the i will never be < 0. It helps avoid confusion.
For (int i=Bars-1;i>0;i--) {
// code
}
Try setting all of the array values to 0, then go back through and assign indicator values. Also, try a print() directly after assigning your indicator value. See if it's actually returning anything at all.
Your best bet, in my guess, is to actually assign a size to the array. Say, 1000 positions. You're unlikely to need that many, plus it will reduce the calculations you're doing. All you need to do then is loop through the last 999 bars to 0 and assign values. I seem to recall MT4 has problems with array initilizations and whatnot.Still just printing the array with all 0's entries
Strange
Argent86,
There are a couple of errors in your code :Here is what you are trying to do without those issues
Access from MQ4 a dll function with: variable-argument lists
hi,
Anyone knows if this is possible: to import an dll function which uses as argument a: variable-argument lists
e.g. vprintf - C++ Reference
int vprintf ( const char * format, va_list arg );
if so how would one do it?
Thanks
MJ
How to call function with no return value
Hello Guys and Girls.
At some point in my programm I'd like to call for a function.
However the function has no return value (void). So how do I call the function,
so it executes the code inside the function exactly on the place where I call for it,
as if it was written on that place itself?
I made some example code below.. where I check some parameters, and if Ok, I want to execute the function...
Hope someone can help me with this, tx in advance, Jonkie76
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if (Price >= PRICE_CLOSE)
call function ; // At this point I'd like to call the function.How do I do that?
else
Alert("Do nothing"); //
//----
return(0);
}
//+------------------------------------------------------------------+
//===================================================================+
//FUNCTIONS
//===================================================================+
//----------------------- CLOSE ORDER FUNCTION ----------------------+
void subCloseOrder()
{
int
i,
total = 0,
ticket = 0,
err = 0,
c = 0;
total = OrdersTotal();
for(i=total-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber()==Magic)
{
switch(OrderType())
{
case OP_BUY :
for(c=0;c<NumberOfTries;c++)
{
ticket=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Violet);
err=GetLastError();
if(err==0)
{
if(ticket>0) break;
}
else
{
if(err==0 || err==4 || err==136 || err==137 || err==138 || err==146) //Busy errors
{
Sleep(5000);
continue;
}
else //normal error
{
if(ticket>0) break;
}
}
}
break;
}
}
}
}
It's very simple. You just need to call it as it would return something, just you don't need to save any result because there is no result at all with void type. (returns nothing) Like this:
int start()
{
//----
if (Price >= PRICE_CLOSE)
subCloseOrder(); // At this point I'd like to call the function.How do I do that?
else
Alert("Do nothing"); //
//----
return(0);
}
Use "void" instead. Like this :
{
...
//
//
// no need to place return at the end, but if you want then use "just" return, like this
//
//
return;
}Void means that it is not going to return value from a function and that way it effectively becomes a procedure, not a function
Hello Guys and Girls.
At some point in my programm I'd like to call for a function.
However the function has no return value (void). So how do I call the function,
so it executes the code inside the function exactly on the place where I call for it,
as if it was written on that place itself?
I made some example code below.. where I check some parameters, and if Ok, I want to execute the function...
Hope someone can help me with this, tx in advance, Jonkie76
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if (Price >= PRICE_CLOSE)
call function ; // At this point I'd like to call the function.How do I do that?
else
Alert("Do nothing"); //
//----
return(0);
}
//+------------------------------------------------------------------+
//===================================================================+
//FUNCTIONS
//===================================================================+
//----------------------- CLOSE ORDER FUNCTION ----------------------+
void subCloseOrder()
{
int
i,
total = 0,
ticket = 0,
err = 0,
c = 0;
total = OrdersTotal();
for(i=total-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber()==Magic)
{
switch(OrderType())
{
case OP_BUY :
for(c=0;c<NumberOfTries;c++)
{
ticket=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Violet);
err=GetLastError();
if(err==0)
{
if(ticket>0) break;
}
else
{
if(err==0 || err==4 || err==136 || err==137 || err==138 || err==146) //Busy errors
{
Sleep(5000);
continue;
}
else //normal error
{
if(ticket>0) break;
}
}
}
break;
}
}
}
}