Coding help - page 222

 

Thanks for the code and encoding Altoronto,

Thanks A lot, i'm ready for the next step

 

Thank you Altoronto,

The next step for this code is to determine the same line for all periods, at the same point, no changes during the day, at the first minute for the candle at 00:00 for the day in progress.

I have attached a picture with descriptions for better understanding:

Can you or some body help me coding this, and encoding into indicator?

Thank you again,

If this finally works i will send a bottle of nice Chilean wine to those who help me,

Thanks again,

Daniel1983

Files:
 
daniel1983:
Thank you Altoronto,

The next step for this code is to determine the same line for all periods, at the same point, no changes during the day, at the first minute for the candle at 00:00 for the day in progress.

I have attached a picture with descriptions for better understanding:

Can you or some body help me coding this, and encoding into indicator?

Thank you again,

If this finally works i will send a bottle of nice Chilean wine to those who help me,

Thanks again,

Daniel1983

Daniel1983

If you are using first closed bar high and low, there will be changes during the day

 

Mr Mladen,

Why will be changes during day? i thinking only make calculus once and for only the first candle OF EACH DAY. Not the following candles, don't get it

at t=1 of day 1 make calculus for t= 0 of day 1, result draw a line

only for the day you are using indicator, at 23:59 of the day make stop working until next day indicator price for 1st candle

next day

at t=1 of day 2 make calculus for t= 0 of day 2, result draw a line

hope here is more clear

 
daniel1983:
Mr Mladen,

Why will be changes during day? i thinking only make calculus once and for only the first candle OF EACH DAY. Not the following candles, don't get it

at t=1 of day 1 make calculus for t= 0 of day 1, result draw a line

only for the day you are using indicator, at 23:59 of the day make stop working until next day indicator price for 1st candle

next day

at t=1 of day 2 make calculus for t= 0 of day 2, result draw a line

hope here is more clear

daniel1983

High[1] and Low[1] means high and low of the firt closed bar of the current chart. If that chart is not a daily chart, you will get an intraday changes as the high and low change. Also, in any case but when you use daily chart, you have a mix of data from different time frames

 

Ok Mladen, let me see if i understand, i think the problem is that i am mixing 2 timeframes in the same code, so if i only use 1 timeframe for example everything for 1 minute charting, it should work:

lets make everything for a minute chart,

code formula por price where the line shall be =

double minuteOpen = iOpen(NULL,PERIOD_M1,1);

double number = (minuteOpen+High[1]+Low[1])/3;

this way i think the code for the Horizontal-line at price calculated should be for t=1, but it does not work

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

//| Custom indicator initialization function |

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

int init()

{

//----

return(0);

}

int deinit() {

Comment("");

ObjectDelete("KeyLine");

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

double minuteOpen = iOpen(NULL,PERIOD_M1,1);

double number = (minuteOpen+High[1]+Low[1])/3;

Comment("Key Line: ",number);

ObjectDelete("KeyLine");

ObjectCreate("KeyLine", OBJ_HLINE,1, CurTime(),number);

ObjectSet("KeyLine",OBJPROP_COLOR,Orange);

ObjectSet("KeyLine",OBJPROP_STYLE,STYLE_SOLID);

ObjectsRedraw();

return(0);

}

 
daniel1983:
Ok Mladen, let me see if i understand, i think the problem is that i am mixing 2 timeframes in the same code, so if i only use 1 timeframe for example everything for 1 minute charting, it should work:

lets make everything for a minute chart,

code formula por price where the line shall be =

double minuteOpen = iOpen(NULL,PERIOD_M1,1);

double number = (minuteOpen+High[1]+Low[1])/3;

this way i think the code for the Horizontal-line at price calculated should be for t=1, but it does not work

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

//| Custom indicator initialization function |

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

int init()

{

//----

return(0);

}

int deinit() {

Comment("");

ObjectDelete("KeyLine");

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

double minuteOpen = iOpen(NULL,PERIOD_M1,1);

double number = (minuteOpen+High[1]+Low[1])/3;

Comment("Key Line: ",number);

ObjectDelete("KeyLine");

ObjectCreate("KeyLine", OBJ_HLINE,1, CurTime(),number);

ObjectSet("KeyLine",OBJPROP_COLOR,Orange);

ObjectSet("KeyLine",OBJPROP_STYLE,STYLE_SOLID);

ObjectsRedraw();

return(0);

}

No

You should do it like this :

double number = )iOpen(NULL,PERIOD_D1,1)+iHigh(NULL,PERIOD_D1,1)+iLow(NULL,PERIOD_D1,1))/3

And that way you are going to get all the data from daily data (no time data from different time frames mixing)

 

Thank you Mladen,

i think maybe i am going too fast. Let's go a little back without entering any formula, lets start from before, lets make the indicator do only the following task:

Draw a single horizontalline at opening price of the first minute candle of each day, candle at 00:01 minute, and erase it at 23:59 minute.

The price for this line does not change in time for all periods the same price until 23:59 when it is erased, and reinitiate again at 00:01 of the next day.

How would this be?

 
daniel1983:
Thank you Mladen,

i think maybe i am going too fast. Let's go a little back without entering any formula, lets start from before, lets make the indicator do only the following task:

Draw a single horizontalline at opening price of the first minute candle of each day, candle at 00:01 minute, and erase it at 23:59 minute.

The price for this line does not change in time for all periods the same price until 23:59 when it is erased, and reinitiate again at 00:01 of the next day.

How would this be?

If you use the formula I posted, then it will behave exactly like that : as soon as the day changes, the value will change too and will stay fixed till the next day

 

Thank you Mladen, i did the changes, the indicator looks like this, but still don't do anything in chart...

//------------------------------------------------------------------

#property copyright "www.forex-tsd.com"

#property link "www.forex-tsd.com"

//------------------------------------------------------------------

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

//| Custom indicator initialization function |

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

int init()

{

//----

return(0);

}

int deinit() {

Comment("");

ObjectDelete("KeyLine");

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

double number = (iOpen(NULL,PERIOD_D1,1)+iHigh(NULL,PERIOD_D1,1)+iLow(NULL,PERIOD_D1,1))/3;

Comment("Key Line: ",number);

ObjectDelete("KeyLine");

ObjectCreate("KeyLine", OBJ_HLINE,1, CurTime(),number);

ObjectSet("KeyLine",OBJPROP_COLOR,Orange);

ObjectSet("KeyLine",OBJPROP_STYLE,STYLE_SOLID);

ObjectsRedraw();

return(0);

}

What i am doing wrong now?

Thank you

Reason: