Ask! - page 52

 
pawang:

2.) According to point 1.) the real case is... how to create a bullish/bearish divergence?

When the conditions: There is a highest Price and highest RSI of defined time frame. And then after the time runs... we meet a new highest Price, but not followed by new RSI's high (RSI fail to make a new high).

//this gives you highest/lowest prices on last 10 bars starting with current(last on the graph - zero bar)

double highestPrice = High;

double lowestPrice = Low;

/*

this gives you lowest/highest rsi on last 10 bars starting with current - 0 bar

*/

double lowestRSI=9999, highestRSI=-9999;

int currentBar = 0;

int endBar = 10;

for(currentBar=0; currentBar<endBar; currentBar++) lowestRSI = MathMin(lowestRSI, iRSI(Symbol(),0,14,PRICE_CLOSE,currentBar));

for(currentBar=0; currentBar<endBar; currentBar++) highestRSI = MathMax(lowestRSI, iRSI(Symbol(),0,14,PRICE_CLOSE,currentBar));

//starting at bar #10 you go back 10 bars on the chart looking for lowest price

//thus you'll get lowest price from bar #10 to bar #20

double lowestPrice10_20 = Low;

to get divergence, you'll need to compare rsi & price over periods

if(lowestPrice10_20 lowestRSI){

//on bars 10-20 lowest rsi is higher than on bars 0-10

//on bars 10-20 lowest price is lower than on bars 0-10

//i hope thats correct

}

you need to start looking at mql4.com for documentation & this forum, most info is covered

 

How can I write this EA ?

How can I write this EA :

1 - Open 1 StopBuy 0.01 at Price + 20 and 1 StopSell 0.01 at Price -20, TP 20.

2 - If one order executed, cancel other.

3 - If executed order is a buy order, reverse sell 1 StopSell double (0.02) at entryprice -20 or opposite if sell order.

4 - and each time a stop order is executed reverse double 20 points far, till TP is executed.Then close all open orders for this pair.

Thanks for help.

 

Try this I put an alert on it it's great

Files:
ifish.mq4  3 kb
 

anybody can help me with code

anybody can help me how to code the indicator with expired so the indicator can run...and how to code indicator so it only can run with 1 account id only.

thx

 
increase:
Try this I put an alert on it it's great

thanks a lot increase it works like magic, is it possible to make an EA that place order in the opposite direction when there is a break and target only 5 pips ?

 

sound alert for each indicator

can we change the sound alert for each indicator, if so how ?

 

EA not working on forward testing

Dear Codersguru,

Could you please help look into my EA below. Its work perfectly fine in backtesting but not on live demo trading account. They is no buy or sell action at all after the crosses. Thank you very much.

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

//| 5/13-v2-SOS.mq4 |

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

extern int Unique_Ref_Number=513;

extern int TakeProfit = 5;

extern int StopLoss=5;

extern double Lots = 1;

extern int Max_Contracts = 1;

extern int emaShortPeriod=5;

extern int emaLongPeriod=13;

extern bool MoneyManagement=true;

extern int Risk=2;

int init() { return(0); }

int deinit() { return(0); }

int Crossed()

{

double emaLong_1=iMA(NULL,0,emaLongPeriod,0,1,PRICE_CLOSE,2);

double emaLong=iMA(NULL,0,emaLongPeriod,0,1,PRICE_CLOSE,1);

double emaShort_1=iMA(NULL,0,emaShortPeriod,0,1,PRICE_CLOSE,2);

double emaShort=iMA(NULL,0,emaShortPeriod,0,1,PRICE_CLOSE,1);

if (emaShort_1emaLong ) return (1); //up trend

if (emaShort_1>emaLong_1 && emaShort<emaLong ) return (2); //down trend

return (0); //no action

}

int start()

{

double BuyStopLoss, SellStopLoss, Lotsize ;

int cnt, ticket;

static datetime ordertime;

int total=OrdersTotal();

if(MoneyManagement==true)

{Lotsize=NormalizeDouble((AccountFreeMargin()*Risk/10000),1);}

else

{ Lotsize=Lots; }

BuyStopLoss=MathMin(MathMin(MathMin(Low[1],Low[2]),Low[3]),Ask-StopLoss*Point);

SellStopLoss=MathMax(MathMax(MathMax(High[1],High[2]),High[3]),Bid+StopLoss*Point);

if(Time[0]>ordertime && total<Max_Contracts)

{

// check for long position (BUY) possibility

if(Crossed()==1 )

{

OrderSend(Symbol(),OP_BUY,Lotsize,Ask,1,BuyStopLoss,Ask+TakeProfit*Point,"5-13-Long",Unique_Ref_Number,0,Green);

ordertime=Time[0];

return(0);

}

// check for short position (SELL) possibility

if(Crossed()==2 )

{

OrderSend(Symbol(),OP_SELL,Lotsize,Bid,1,SellStopLoss,Bid-TakeProfit*Point,"5-13-Short",Unique_Ref_Number,0,Red);

ordertime=Time[0];

return(0);

}

}

return(0);

}

 

Codersguru,

I need yr help for a MT4 EA.

Day start at 0000 GMT.

1) Draw 5 horizontal lines (different colors). Yesterday OHLC and yesterday (H+L)/2 median line.

2) Sound and pop up alerts when price touches any of the 5 lines.

It would be great if u could help. Thanks...

 
MiniMe:
the indicator is for drawing trend line

all I want is to be able to change the thinkness of the trend line

Help pls

Alan

Here it is. Hope this is what you wanted.

Files:
 
Maji:
Here it is. Hope this is what you wanted.

Thanks a lot Maji, exactly what I was looking for

Reason: