Thanks for your reply.
I use below code for Day Open Price.
if(TimeDay(Time[i]) != TimeDay(Time[i+1]))
It does work for me. Even Month and Year, but Week is not.
Thanks,
Max
if(TimeDayOfWeek(Time[i]) != TimeDayOfWeek(Time[i+1]))
Your code asks if bar i is the start of a new day not a new week. You want to find the "Week Open Price," here are three ways:
double wop = iOpen(NULL, PERIOD_W1, 0)
datetime BOW = iTime(NULL, PERIOD_W1, 0); int iBOW = iBarShift(NULL,0, BOW); double wop = Open[iBow];
- Find the first bar of the new week: the DOW(Monday) < DOW(Friday)
int i=0; while( TimeDayOfWeek(Time[i]) >= TimeDayOfWeek(Time[i+1]) ) ++i; double wop = Open[i];
WHRoeder:
int i=0; while( TimeDayOfWeek(Time[i]) >= TimeDayOfWeek(Time[i+1]) ) ++i; double wop = Open[i];
That was awesome. Yeah, I found what I want. Thank you so much - @WHRoeder
Everything OK at any TimeFrames. But indicator Opened wrong Price & Time when I want to use it at the "W1 / Weekly" TimeFrame.
Best,
Max
All the best.
int start() { int indicatorCounted = IndicatorCounted(); if( indicatorCounted < 0 ) { } if( indicatorCounted > 0 ) { indicatorCounted--; } int days = 0; int limit = Bars - indicatorCounted; for(int i = 0; i < limit; i++) { if( TimeDay(Time[i]) != TimeDay(Time[i+1]) ) { double openDay = Open[i]; datetime openTime = Time[i]; datetime closeTime = Time[i] + 60 * 60 * 24; string levelOpen = openDay + pips2dbl ; ObjectCreate(levelName, OBJ_FIBO, 0, openTime, levelOpen, closeTime, openDay ); ...
Please somebody help me about my above issue.
I am still waiting good reply, thanks.
string levelOpen = openDay + pips2dbl
Why is this a string? It should be a double.
ObjectCreate(levelName, OBJ_FIBO, 0, openTime, levelOpen, closeTime, openDay );
Once this has been created it cannot be created again with the same name.
Once this has been created it cannot be created again with the same name.
Thanks for your answers.
As you mentioned, I has been fixed like below.
string levelName = "- Daily Open - " + TimeMonth( Time[0] ) + "/" + TimeDay(Time[0]);
I tested with 'Strategy Tester' right now yes new FIBO object opens, but previous day FIBOs does not remove even I choice History 1 like below code.
int History = 1; ... days--; } if(days >= History ) { break; }
I need help, please.
Please study this and fully understand what is happening in the code
static datetime bar_time=0; if(bar_time==Time[0]) //Only check if a new bar/// return(0); bar_time=Time[0]; static datetime openTime=0; int i=0; while(TimeDay(Time[i])==TimeDay(Time[i+1])) i++; if(openTime!=Time[i]) { openTime=Time[i]; double openDay = Open[i]; datetime closeTime = Time[i] + 60 * 60 * 24; double levelOpen=openDay+pips2dbl; if(ObjectFind(0,levelName)!=0) ObjectCreate(levelName,OBJ_FIBO,0,openTime,levelOpen,closeTime,openDay); else { ObjectMove(0,levelName,0,openTime,levelOpen); ObjectMove(0,levelName,1,closeTime,openDay); } }
The Fibo is only created once and then moved at the start of a new day.
Almost I will spend whole of my life for this code Man. I solved my issue with your brilliant code! I studied from your like an educational code.
Thank you so much more!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I try below code for Week Open Price on Indicator. I have not any error code but below code does not shows me correct time.
Any help would be better.
Best,
Max