How to code? - page 329

 

how can i watch live yearly candle

i made the yearly candle but they working offline is there any way to make them working live

 
kfma8899:
i made the yearly candle but they working offline is there any way to make them working live

No, you can not. Any offline chart can not be used as a live chart (all you can do is simulate it by sending events to opened offline charts that a new tick has been generated/arrived and the it look like a live chart, but it s still an offline chart)

 

how to increase the number of the yearly candles i got only 8 candles

how to increase the number of the yearly candles i got only 8 candles

 
kfma8899:
how to increase the number of the yearly candles i got only 8 candles

Download more data that will be used to generate yearly offline charts

 

Hi Mrtools

Please help me auto setup TimeFrame for this indicator

support_and_resistance__mtfalerts.mq4

when i add indicator to M1 chart Timeframe of indicator is 15

when i move from M1 to m15 timeframe indicator will auto set timeframe = 60

when i move from M15 to m30 timeframe indicator will auto set timeframe = 240

....

m1: TimeFrame = 15

m5: TimeFrame = 30

m15: TimeFrame = 60

m30: TimeFrame = 240

H1: TimeFrame = 240

h4: TimeFrame = 1440

D1: TimeFrame = 10080

Thank you!

 

Pls can somebody help me with this code...it always repeat the same alert.e.g if it bring buy alert on a pair, after about 7 candle, it will bring the same buy alert on the same pair.I want it to work that when it bring BUY alert on a pair,it will not bring BUY signal again on that pair until after it has delivered SELL signal:

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Lime

#property indicator_color2 Red

//--- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//external variable......

extern int barsToProcess=100;

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

//| 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()

{

int counted_bars=IndicatorCounted(),

limit;

if(counted_bars>0)

counted_bars--;

limit=Bars-counted_bars;

if(limit>barsToProcess)

limit=barsToProcess;

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

{

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);

}

static datetime lastAlerted=0;

static string AlertType1="";

static string AlertType2="";

//up alerts

if((ema5>ema13)&&(ema5>b4ema5)&&(ema13>b4ema13)&&(mom>b4mom)&&(mom>98.6591)&&(lastAlerted!=Time[0])&&(AlertType1!="Buy")){

ExtMapBuffer1=High+5*Point;

}else

ExtMapBuffer1=0.0;

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

//sell alerts

if((ema5<ema13)&&(ema5<b4ema5)&&(ema13<b4ema13)&&(mom<b4mom)&&(mom<100.6872)&&(lastAlerted!=Time[0])&&(AlertType2!="Sell")){

ExtMapBuffer2=Low-5*Point;

}else

ExtMapBuffer2=0.0;

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

return(0);

}

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

 
Mastercash:
Pls can somebody help me with this code...it always repeat the same alert.e.g if it bring buy alert on a pair, after about 7 candle, it will bring the same buy alert on the same pair.I want it to work that when it bring BUY alert on a pair,it will not bring BUY signal again on that pair until after it has delivered SELL signal:

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Lime

#property indicator_color2 Red

//--- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//external variable......

extern int barsToProcess=100;

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

//| 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()

{

int counted_bars=IndicatorCounted(),

limit;

if(counted_bars>0)

counted_bars--;

limit=Bars-counted_bars;

if(limit>barsToProcess)

limit=barsToProcess;

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

{

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);

}

static datetime lastAlerted=0;

static string AlertType1="";

static string AlertType2="";

//up alerts

if((ema5>ema13)&&(ema5>b4ema5)&&(ema13>b4ema13)&&(mom>b4mom)&&(mom>98.6591)&&(lastAlerted!=Time[0])&&(AlertType1!="Buy")){

ExtMapBuffer1=High+5*Point;

}else

ExtMapBuffer1=0.0;

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

//sell alerts

if((ema5<ema13)&&(ema5<b4ema5)&&(ema13<b4ema13)&&(mom<b4mom)&&(mom<100.6872)&&(lastAlerted!=Time[0])&&(AlertType2!="Sell")){

ExtMapBuffer2=Low-5*Point;

}else

ExtMapBuffer2=0.0;

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

return(0);

}

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

Try to save the last alert type to AlertType1 or AlertType2 (you never saved what kind of the alert is the last nor when was the last alert triggered)

 

Hi,

I want to put the actual time on my chart (every second). I put this in an infinit loop.

But it doesn't work as I want :-(

Why

That's my code:

while(!IsStopped())

{

ObjectMove ("Time", OBJ_TEXT,0,Time[0],High[0]+2*pips2dbl);

ObjectSetText("Time",TimeToStr(TimeCurrent()),10,"Tahoma",Gray);

Sleep(100);

}

 
sunshineh:
Hi,

I want to put the actual time on my chart (every second). I put this in an infinit loop.

But it doesn't work as I want :-(

Why

That's my code:

while(!IsStopped())

{

ObjectMove ("Time", OBJ_TEXT,0,Time[0],High[0]+2*pips2dbl);

ObjectSetText("Time",TimeToStr(TimeCurrent()),10,"Tahoma",Gray);

Sleep(100);

}

sunshineh

That can work only in EAs

Sleep() does not work in indicators

 

Thanks mladen,

but how an I realize it, that the actual time is shown on the chart?

Even when I put this code in my ea, the object "Time" isn't updating every second. Why? Takes it to much time to update the text object??

But that is not a solution for me. Perhaps it is possible to "create" ticks for the indicator, so that it is updating every second?!