Coding help - page 241

 

Hello everybody,

I don't want my EA to open a position if there is already position going in the same direction at the same price level already (using renko). Essentially it would look something like this:

If previous bar direction is up, open long iff there is no long position at the same price level (+-2 pips for example). Same thing for short.

Is this possible?

 

Damn, so easy

 

Damn, so easy

Thank you Mladen

 

Mladen,I have a problem.

I found your indicator Dynamic zones Spearman, found also others. But I can't make that I want. I want in one window some correlation. You understand me? I want that the computer didn't stop, using your indicator. But that looked as Spearman Stack.

but at me it is impossible to make it. I superimpose indicators at each other, but I see only one

Files:
eurjpymh1.png  72 kb
 
Air92:
Mladen,I have a problem.

I found your indicator Dynamic zones Spearman, found also others. But I can't make that I want. I want in one window some correlation. You understand me? I want that the computer didn't stop, using your indicator. But that looked as Spearman Stack.

but at me it is impossible to make it. I superimpose indicators at each other, but I see only one

Here is how indicator from this post : https://www.mql5.com/en/forum/general looks like when I apply it multiple times in the same sub-window

Files:
spearman.gif  49 kb
 

Вот как индикатор с этого поста: https://www.mql5.com/en/forum/general выглядит, когда я применяю его несколько раз в том же дополнительном окне [/ QUOTE]

Mladen,thank you for nmc!

 
BlackCoq:
Hello everybody,

I don't want my EA to open a position if there is already position going in the same direction at the same price level already (using renko). Essentially it would look something like this:

If previous bar direction is up, open long iff there is no long position at the same price level (+-2 pips for example). Same thing for short.

Is this possible?

Maybe it would suffice to look up open price for the last 15 trades so, check if any of those fall within +- 2 pips of current price, then check if that trade is in the same direction as intended new trade and if not, send order. Would this work?

Thank you,

Axel

 
BlackCoq:
Maybe it would suffice to look up open price for the last 15 trades so, check if any of those fall within +- 2 pips of current price, then check if that trade is in the same direction as intended new trade and if not, send order. Would this work?

Thank you,

Axel

Axel

It can be done.

Simply the open orders should be scanned for desired type and their open prices should be compared to the desired new open price or the bars at which they were opened can be compared to the bar that serves as a criteria for opening

 
mladen:
Axel

It can be done.

Simply the open orders should be scanned for desired type and their open prices should be compared to the desired new open price or the bars at which they were opened can be compared to the bar that serves as a criteria for opening

Would it work to write a function like the one below 20 times or so for different "i=OrdersTotal()-1" and then call in all the function and match them against new opening price?

Thank you

 

Can somebody tell me what did I do wrong, the below code is 2 EMA cross over with alerts.It refuse to work.Pls can some one help out to compile and work on mt4 build 600 +:

#property copyright "wnk"

#property link "www.wnk.com"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Lime

#property indicator_color2 Red

//--- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//external variable......

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0,217);

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexEmptyValue(0,0.0);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1,217);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexEmptyValue(1,0.0);

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

static datetime LastAlertTime = TimeCurrent();

int counted_bars=IndicatorCounted(),

limit;

if(counted_bars<0)

return(-1);

if(counted_bars>0)

counted_bars--;

limit=Bars-counted_bars;

while(limit)

{

double ema13=iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,0);

double ema5=iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,0);

double b4ema13=iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,1);

double b4ema5=iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,1);

double mom=iMomentum(NULL,0,14,PRICE_CLOSE,0);

double b4mom=iMomentum(NULL,0,14,PRICE_CLOSE,1);

//up alerts

if((LastAlertTime!=Time[0])&&(ema5>ema13)&&(ema5>b4ema5)&&(ema13>b4ema13)&&(mom>b4mom)&&(mom>98.6591))

ExtMapBuffer1[limit]=High[limit]+5*Point;

LastAlertTime = Time[0];

Alert(Symbol()," ",Period(),"M Price UP");

//sell alerts

if((LastAlertTime!=Time[0])&&(ema5<ema13)&&(ema5<b4ema5)&&(ema13<b4ema13)&&(mom<b4mom)&&(mom<100.6872))

ExtMapBuffer2[limit]=Low[limit]-5*Point;

LastAlertTime = Time[0];

Alert(Symbol()," ",Period(),"M Price Down");

}

return(0);

}

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

Reason: