MQL4 Learning - page 22

 

Speed programming

1) When I run my program, usually sell stop and buy stop pop up. But, sometimes only one pending order pops up.When I was debugging, I noticed that one time first market tick created one pending order, and another tick created another pending order.

Strange??The market was not volatile.

2) The program also adjusts pending orders. It runs good until certain time (usually about 45 seconds) and then stops modifying some one pending order.

3)When market goes 1 tick down, then in about 1-2 seconds the pending orders go 1 tick down too.

It looks to me that the codes does not catch all market ticks.

My question is ; is there some available function (e.g. RefreshRates();) that makes the code to catch all the ticks and process them

Thank you all.

 

Thank you very much for posting questions,Julia. I get to learn.

 

In my opinion (difficult to say just like that) your problem may occur not because the program don't catch all ticks (by default all ticks are taken into account) but because the context is still busy when you want to execute some orders and then they are delayed to the next ticks.

If you run an EA on a live account the OrderSend or Modifiy should be programmed to take into account the context.

 
jlpi:
In my opinion (difficult to say just like that) your problem may occur not because the program don't catch all ticks (by default all ticks are taken into account) but because the context is still busy when you want to execute some orders and then they are delayed to the next ticks. If you run an EA on a live account the OrderSend or Modifiy should be programmed to take into account the context.

I tried on live account and the problem is not solved.

I need to hear what other experienced programmers say.

Thank you all.

 

Values of the zig zag peaks and valley's

Is there anyway to get the values of the peaks and valley's of this zig zag indicator for the most recent High to the previous High and the most recent Low to the previous Low???

Dave <<<
Files:
 

Stoch Cross over indicator not working

Hi

Trying to modify existing code from a macd to stoch cross over (so it shows once on main screen if the stoch crosss over and its over 20) but the code doesnt work

Any help please ?

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Blue

#property indicator_color2 Red

//---- input parameters

extern int Stoch_K = 5;

extern int Stoch_D = 3;

extern int Stoch_Slowing = 2;

extern bool UseAlert=false;

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0,233);

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexEmptyValue(0,0.0);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1,234);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexEmptyValue(1,0.0);

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

int limit;

int counted_bars=IndicatorCounted();

//---- check for possible errors

if(counted_bars<0) return(-1);

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//---- main loop

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

{

ExtMapBuffer1 = 0; ExtMapBuffer2 = 0;

double stochk0 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, i);

double stochk2 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, i+1);

double stochk10 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, i);

double stochk12 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, i+1);

if (stochk0 > stochk10 && stochk2 < stochk12)

ExtMapBuffer1 = iLow(NULL, 0, i+1);

if (stochk0 stochk12)

ExtMapBuffer2 = iHigh(NULL, 0, i+1);

}

return(0);

}

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

 

loooooooooooooooooooooooooooool

find a place on a chart when this condition is true

if (stochk0 > stochk10)

double stochk0 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, i);

double stochk10 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, i);

Or at least find me at least 2 differences!

 

.

Im sorry I dont understand your reply Shinigami

 

Hi!

I'm doing an indicator which are wrinting arrows over bars according to my criteria. What I want is the indicator to draw arrows based on the 1 Hour timeframe no matter what timeframe is currently selected. Right now it just draws arrows. The strategy involves MA's and them you can program to just use H1 period (iMA(..H1_PERIOD..) or something) but how about price? Low[]? Close[]? Can you make it just calculate on 1 Hour no matter the choosen timefram but stull display the arrows on say the 5 minute chart?

 

Comments Input by User

Is there anyway to allow the user to input comments using an indicator input??

I then can use a ObjectCreate to place them on the graph and they will stay put when I max the graph and downsize the graph. Is this possible?? And how should I code the indicator input?? For use in my Manual Trade Log I am creating.

Dave <<<
Reason: