Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
Your EA will always load (if it does not have a coding error that would prevent it to compile)
You just have to decide where do you want it to stop doing the "usual job" it does and prevent it from doing it for an unauthorized ones. Normally you put that checking routine at the beginning of the start() - something like this :
PHP Code:
//+------------------------------------------------------------------+
//| Dll_call.mq4 |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
static bool alerted = false;
int a = 907671;
int b = AccountNumber();
if (b != a)
{
if (!alerted)
{
Comment("Checking Account No! (" + DoubleToStr(b, 0) + ") wrong Acc");
alerted = true;
}
return (0);
}
//
//
// the part that is not executed when account number is wrong
//
//
alerted = false;
Comment("continuing the rest of the job");
return(0);
}
But also, this kind of checking is hackable by a decompiler in a matter of minutes.
PS: changed the Alert() to Comment() so you can check it in visual back test
Quote:
Originally Posted by jimmynz
thanks for the help, but still no.
werid thing is i tried making an EA with the usual code to check acc #:
int a = 907671;
int b = AccountNumber();
if (b != a) {
Alert("Checking Account No! (" + DoubleToStr(li_16, 0) + ") wrong Acc");
return (0)}
as an EA it loads no matter what the number is, but if i make it as an indi it works fine?
this is the def file. look ok?
does it need to go in librarys with the DLL?
I created a short dll example project to try and show you how this works, unfortunately we cannot attach a dll file in the forum. If you PM me with an e-mail address I could e-mail you the dll to try.
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
Comment("\nReturn from DLL_Example = ",GetDoubleFromDLL());
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
}
Hope this helps, I know how frustrating this can be!
So you're great plan is to take two free EA's that you probably found here and 'merge' them together and sell it for 2K a pop? You've got some nerve buddy! Maybe if you're really lucky one of the two guys that actually gave up their time, effort and knowledge for free will offer to do it for you.
Oh but wait! If the code is 'messed up' then the EA's are mostly likely commercial EA's that have been decompiled. Is that it? Moron!!!
Lux
Oh, nice speech. Let me tell you this:
No matter what EA you're looking at, most likely there will be someone with the same idea already have the EA made. Free EA's? Are you kidding me? Which EA right on this forum had that potentials?
Also, there's alot of people calling themselves developers are also copying from others, selling for $3000 club subscriptions. And worst, with EA's that will blow your accounts flat. .... ZERO
Also, I had never took any EA's from here. Which EA is worth for the merge on this forum? Also, if the code is messed up, it could be me asking programmers to code an EA. Then as more features needed, I'm asking different programmers...TO HELP !
Different coding styles could over the time, messed up codes.
Also, I didn't decompile any commercial EA. The reason you said I am, is the fact that you're doing it yourself. I don't know what type of mess a decompiler will caused. But for sure, if you are so sure that a decompiler could caused a mess, then you've probably been using it. Otherwise you'd never know.
One advice, before calling others moron or try to act like a police / hero saving the day, judge yourself first. If not, those words coming from your mouth could forced you to swallow them back in.
Yes, i know that the above can't be used directly in an EA, but is it possible to achieve same results by recoding the above MA? if so, i'd really appreciate some help on that.
extern int ma1period=5;
extern int ma1method=1;
extern int ma1tf=0;
extern int ma2period=5;
extern int ma2method=1;
extern int ma2tf=10080;
extern double lots=1;
int init(){}
int deinit(){}
double CMA (int tf,int period, int shift, int method)
{
double MA=iMA(NULL,tf,period,0,method,0,shift)
return(MA)
}
int start()
{
int BarsCount=0;
if (Bars> BarsCount)
{
BarsCount=Bars;
double ma1.1=CMA(ma1tf,ma1period,1,ma1method);
double ma1.2=CMA(ma1tf,ma1period,2,ma1method);
double ma2.1=CMA(ma2tf,ma2period,1,ma2method);
double ma2.2=CMA(ma2tf,ma2period,2,ma2method);
bool ma1upsignal =ma1.2<ma1.1;
bool ma1downsignal =ma1.2>ma1.1;
bool ma2upsignal =ma2.2<ma2.1;
bool ma2downsignal =ma2.2>ma2.1;
if (ma1upsignal&&ma2upsignal)
{
OrderSend(Symbol(),OP_BUY,lots,Ask,3,NULL,NULL,NULL,NULL,0,Green);
}
if (ma1downsignal&&ma2downsignal)
{
OrderSend(Symbol(),OP_SELL,lots,Bid,3,NULL,NULL,NULL,NULL,0,Green);
}
if ((ma1upsignal&&ma2downsignal)||(ma1downsignal&&ma2upsignal))
{
int total=OrdersTotal(); //Script to close all open orders.
for(int i=total-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
int type = OrderType();
switch(type)
{
//Close opened long positions
case OP_BUY : OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
break;
//Close opened short positions
case OP_SELL : OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
}
}
}
}
This is the piece of code i'm working on. The compiler says "the variable BarsCount is not defined". What do i do? As far as I can see, the variable has been initialized and given a value.
Anyone got some code on how to count consecutive buy/sell bars in a row? I want to count how many times on a chart (enter number of bars to check) there are 1 sell bars in a row, 32sell bars in a row, 3 sell bars in a row, 4 sell bars in a row (same w/ buy) etc.
I know I need to loop it, but I can't quite figure out how.
Wrote a simple prog.
It is supposed to enter only one order at a time,& exit w/ a take profit or a stop loss.
It is set up for M30 on GBPUSD.
Ie: some of the constants sed in the prog are found by "eyeball" estimates. This should not greatly effect the prog... it also does not work w/ different constants. (At least, when tested w/ the Strategy Tester, set on fast or medium: not "tick by tick". (too slow...)
Anyhow the prog, when tested does not enter an order AND does not ever! check in the "up" direction. (This, via the "print"/trace)
(it is supposed to check: enter w/ a buy or enter w/ a sell)
Incidental logic: check 2 consecutive bars. If bar 1 has both: a higher high & a higher low, prog thinks that the next bar will be up.
(Symetrically for down.)
Take profit & stop loss are set accordingly.
The prog also did not work when the "if" statements were nested....
Thanks for looking at this.
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//------------------------------------down order start
if (ABC == 0)// no orders out is true
OrdTot_OK = true;
if (ABC == 0)// no orders out is true
Print ("on down order sequence, no orders were out");
if ((C-D) > Size1)//high of 2 less low of 1 > .0063
BigDown = true;
if ((C-D) > Size1)//high of 2 less low of 1 > .0063
Print ("on down order sequence, found a big breakout down");
if (High[1]< High[2])
High2down=true;
if (High[1]< High[2])
Print ("on down order sequence, the consecutive bars have decreasing highs");
if(Low[1]< Low[2])
Low2down=true;
if(Low[1]< Low[2])
Print ("on down order sequence, the consecutive bars have decreasing lows");
if (High2down && Low2down)
TrendDown=true;
if (High2down && Low2down)
Print ("on down order sequence, TrendDown flag is set");
if (TrendDown)
SL_Trailing_Down = High[1];
if (TrendDown)
Print ("on down order sequence, did set the stop_loss");
if (TrendDown)
TakeProfitDown = Bid - (.005);
if (TrendDown)
Print ("on down order sequence, got a takeprofit", TakeProfitDown);
if (TrendDown && BigDown)
DownAndBig = true;
if (DownAndBig && OrdTot_OK)
ticketdown= OrderSend(Symbol(),OP_SELL,lot, Bid,slip,SL_Trailing_Down,TakeProfitDown,Blue);
if (DownAndBig && OrdTot_OK)
Print ("on down order sequence, tried to enter a ticket", ticketdown);
if (ticketdown < 0)
Print("OrderSend_Down failed with error #",GetLastError());
return(0);
//----------------------------------------------down order done
//---------------------------------------------------up order start
if (ABC == 0)
OrdTot_OK = true;
if (ABC == 0)
Print ("on the going up sequence, no orders were out");
if ((A - B) > Size1)
BigUp = true;
if ((A - B) > Size1)
Print ("on the going up sequence, the size test for the two bars was ok");
if (High[1] > High[2])
High2Up = true;//44
if (High[1] > High[2])
Print ("on the going up sequence, the test for increasing highs was ok");
if(Low[1] > Low[2])
Low2Up=true;
if(Low[1] > Low[2])
Print ("on the going up sequence, the test for increasing lows was ok");
if (High2Up && Low2Up)
TrendUp1=true;
if (High2Up && Low2Up)
Print ("on the going up sequence, did set the flag for going up");
if (TrendUp1)
SL_Trailing_Up = Low[1] ;
if (TrendUp1)
Print ("on the going up sequence, established the stoploss");
if (TrendUp1)
TakeProfitUp = Ask + (.005);
if (TrendUp1)
Print ("on the going up sequence, established the takeprofit", TakeProfitUp);
if (TrendUp1 && BigUp)
UpAndBig = true;
if ( UpAndBig && OrdTot_OK)
ticketup = OrderSend(Symbol(), OP_BUY,lot, Ask,slip, SL_Trailing_Up,TakeProfitUp,Red);
if (UpAndBig && OrdTot_OK)
Print ("on the going up sequence, tried to send in an order", ticketup);
if (ticketup < 0)
Print("OrderSend_Up failed with error #",GetLastError());
return(0);
//-------------------------------------------------up order done