ADX Cross EA GPL (forex-tsd)

 

First of all before i begin... i want to thank mladen and mrtools

All credits go to both of them.

I make no lie , that am a newbie and for the last 2 months i have immersed myself into the world of MQL coding.. by reading and learning how others do their stuff..

The purpose of this thread is to guide noobies like me to learn...

So i have been creating an EA based on ADX Cross mtf developed by mladen .... I give him all the credits and respect.

I am willing for anyone to take me by hand and help me learn how to make it work...

I have done 80% of the work ... and it is free for anyone to use on this forum

I have attached the base indicator and the EA template i have been using.

PROBLEM : How to make the EA fire trades from one adx signal to another

This is the error am getting...

These are the source codes

EA: adxcrossea.mq4

Indicator : adxcrossmtf.mq4

 
mwambaFX:
First of all before i begin... i want to thank mladen and mrtools

All credits go to both of them.

I make no lie , that am a newbie and for the last 2 months i have immersed myself into the world of MQL coding.. by reading and learning how others do their stuff..

The purpose of this thread is to guide noobies like me to learn...

So i have been creating an EA based on ADX Cross mtf developed by mladen .... I give him all the credits and respect.

I am willing for anyone to take me by hand and help me learn how to make it work...

I have done 80% of the work ... and it is free for anyone to use on this forum

I have attached the base indicator and the EA template i have been using.

PROBLEM : How to make the EA fire trades from one adx signal to another

This is the error am getting...

These are the source codes

EA: adxcrossea.mq4

Indicator : adxcrossmtf.mq4

mwambaFX

That adxcross indicator is showing only arrows

So all you need to test if the desired bar is different from EMPTY_VALUE or not (buffer 0 for cross up and buffer 1 for cross down). No need to check multiple values of the same buffer

 

Thank you mladen made the changes you suggested... the EA only made 2 trades and stopped after that...i uploaded version 2. Kindly advise.

version 2: adxcrosseav2.mq4

Files:
 

version 3: one million trades per second... i think there is an error or something i have skipped doing... mladen mrtools

adxcrosseav3.mq4

Files:
 
mwambaFX:
version 3: one million trades per second... i think there is an error or something i have skipped doing... mladen mrtools

adxcrosseav3.mq4

Will check it a bit later (you probably omitted to add a control to have just one active order opened)

 
mladen:
Will check it a bit later (you probably omitted to add a control to have just one active order opened)

Hi Mladen...any bug you found?

 

mladen and mrtools please help me here... managed to figure how most of the stuff... just remaining one problem i am not able to get my head around...

I would the EA to open at current signal bar and not shifted ... please help me make it open at current bar.. thank you

Files:
de30m15.png  19 kb
 

//|---------signal conditions

int limit=0;

for(int i=0;i<=limit;i++)

{

//|---------main signal

double adxup=iCustom(NULL,0,"adxcrossmtf",TimeFrame,AdxPeriod,0,i);

double adxdown=iCustom(NULL,0,"adxcrossmtf",TimeFrame,AdxPeriod,1,i);

string BUY="false";

string SELL="false";

if(adxup>0&&adxup!=EMPTY_VALUE)BUY="true";

if(adxdown>0&&adxdown!=EMPTY_VALUE)SELL="true";

string SignalBUY="false";

string SignalSELL="false";

if(BUY=="true"/*&&MABUY=="true"*/)if(ReverseSystem)SignalSELL="true";else SignalBUY="true";

if(SELL=="true"/*&&MASELL=="true"*/)if(ReverseSystem)SignalBUY="true";else SignalSELL="true";

}

//|---------open orders

double SL,TP,SLP,TPP,OPP;

int Ticket,TicketH,TicketP,Expire=0;

if(Expiration>0)Expire=TimeCurrent()+(Expiration*60)-5;

if(OrdersTotal()<MaxOrders)

{

if (SignalBUY=="true"&&NewBarBuy())

{

if(HideSL==false&&StopLoss>0){SL=Ask-StopLoss*Point;OPP=Bid-StopLoss*Point;SLP=Bid;}else {SL=0;}

if(SL>0&&SL>(Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)){SL=Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point;}

if(HideTP==false&&TakeProfit>0){TP=Ask+TakeProfit*Point;TPP=Bid-(TakeProfit*2)*Point;}else {TP=0;TPP=0;}

Ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SL,TP,EAName,Magic,0,Blue);

if(Hedge)TicketH=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,TP,SL,EAName,Magic,0,Red);

if(ReverseAtStop&&StopLoss>0)TicketP=OrderSend(Symbol(),OP_SELLSTOP,Lots,OPP,Slippage,SLP,TPP,EAName,Magic,Expire,Red);

}

if (SignalSELL=="true"&&NewBarSell())

{

if(HideSL==false&&StopLoss>0){SL=Bid+StopLoss*Point;OPP=Ask+StopLoss*Point;SLP=Ask;}else {SL=0;}

if(SL>0&&SL<(Ask+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)){SL=Ask+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point;}

if(HideTP==false&&TakeProfit>0){TP=Bid-TakeProfit*Point;TPP=Ask+(TakeProfit*2)*Point;}else {TP=0;TPP=0;}

Ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP,EAName,Magic,0,Red);

if(Hedge)TicketH=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,TP,SL,EAName,Magic,0,Blue);

if(ReverseAtStop&&StopLoss>0)TicketP=OrderSend(Symbol(),OP_BUYSTOP,Lots,OPP,Slippage,SLP,TPP,EAName,Magic,Expire,Red);

}

}

//|---------close orders

if(Hedge==false)

{

if((SELL=="true")||(ReverseSystem==false&&HideSL&&(OrderOpenPrice()-Ask)/Point>=StopLoss)||(ReverseSystem==false&&HideTP&&(Bid-OrderOpenPrice())/Point>=TakeProfit)||(ReverseSystem&&HideSL&&(Bid-OrderOpenPrice())/Point>=StopLoss)||(ReverseSystem&&HideTP&&(OrderOpenPrice()-Ask)/Point>=TakeProfit))

{

if(ReverseSystem)CloseSellOrders(Magic);else CloseBuyOrders(Magic);

}

if((BUY=="true")||(ReverseSystem==false&&HideSL&&(Bid-OrderOpenPrice())/Point>=StopLoss)||(ReverseSystem==false&&HideTP&&(OrderOpenPrice()-Ask)/Point>=TakeProfit)||(ReverseSystem&&HideSL&&(OrderOpenPrice()-Ask)/Point>=StopLoss)||(ReverseSystem&&HideTP&&(Bid-OrderOpenPrice())/Point>=TakeProfit))

{

if(ReverseSystem)CloseBuyOrders(Magic);else CloseSellOrders(Magic);

}

}

else

{

if((HideSL&&StopLoss>0&&(OrderOpenPrice()-Ask)/Point>=StopLoss)||(HideTP&&TakeProfit>0&&(Bid-OrderOpenPrice())/Point>=TakeProfit))

{

CloseBuyOrders(Magic);

}

if((HideSL&&StopLoss>0&&(Bid-OrderOpenPrice())/Point>=StopLoss)||(HideTP&&TakeProfit>0&&(OrderOpenPrice()-Ask)/Point>=TakeProfit))

{

CloseSellOrders(Magic);

}

}