- Don't post code that won't even compile.
- Give your object a name.
- Don't post code that won't even compile.
- Give your object a name.
Well I would have if I were able to...
Played around a little bit more since posting it here earlier and was successful compiling it without any errors or warnings this time. Here you go:
void OnTick() { DayOfWeek(); if(DayOfWeek()==5) { ObjectCreate("TrendLine",OBJ_TREND,0,Time[24],Open[24],Time[0],Close[0]); } }
I gave him help. You gave him nonsense. The code has nothing to so with Sunday.
I gave him help. You gave him nonsense. The code has nothing to so with Sunday.
I was able to get the code to compile without errors but it still doesn't do what I want it to. Any other ideas?
Show the code
Show the code
- We have no idea what you want or what your code is doing. "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
- Open Object list (Charts (Alt+C) → Objects → Objects List (Control+B)) and verify your object has been created.
- Add a Print statement so you know you have called your create code.
Hello there,
absolute coding noob here — this is my first try at an EA.
The code should create a trend line with one anchor point at the open of Friday and second anchor point at the close of the same day.
Time frame is 1h bars. The idea is to look at the 1h chart and be easily able to see the PA on Fridays for the whole 1h data history, or on as many Fridays as possible.
p.s. A rectangle can do the trick as well, don't have to be a trend line.
Here's how far I've come:
Would appreciate any hints, thanks in advance.
since i quite free at this moment , iam willing to share my approach regarding this issues and here my code
#property strict void OnTick() { static int timeCurrent=0 ; if(DayOfWeek()==5) if(Hour()==23 && timeCurrent!=Hour()) { //CHECK FOR THE HIGHEST BAR int barHigh = iHighest(Symbol(),PERIOD_CURRENT,MODE_HIGH,23,0); //CONVERT THE HIGEST BAR TO PRICE double priceHigh = iHigh(Symbol(),PERIOD_CURRENT,barHigh); //CHECK FOR THE LOWEST BAR int barLow = iLowest(Symbol(),PERIOD_CURRENT,MODE_LOW,23,0); //CONVERT THE LOWEST BAR TO PRICE double priceLow = iLow(Symbol(),PERIOD_CURRENT,barLow); //DRAW OBJ RECTANGLE AND OTHER PROPERTIES ... string RECTANGLE="RECTANGLE"+(string)ObjectsTotal(); ObjectCreate(PERIOD_CURRENT,RECTANGLE,OBJ_RECTANGLE,0,TimeCurrent(),priceHigh,TimeCurrent()-82800,priceLow); ObjectSetInteger(PERIOD_CURRENT,RECTANGLE,OBJPROP_BACK,True); } timeCurrent=Hour(); }//END ONTICK
As shown above my approach might differ from other . How iam doing it is quite simple , first filter day and time . Once filtering is done , then check for the lowest and highest values after that draw obj_rectangle using the lowest and highest values .
You can review this code for studies purpose
Hope get your message correctly
regard
Cosmas
since i quite free at this moment , iam willing to share my approach regarding this issues and here my code
As shown above my approach might differ from other . How iam doing it is quite simple , first filter day and time . Once filtering is done , then check for the lowest and highest values after that draw obj_rectangle using the lowest and highest values .
You can review this code for studies purpose
Hope get your message correctly
regard
Cosmas

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello there,
absolute coding noob here — this is my first try at an EA.
The code should create a trend line with one anchor point at the open of Friday and second anchor point at the close of the same day.
Time frame is 1h bars. The idea is to look at the 1h chart and be easily able to see the PA on Fridays for the whole 1h data history, or on as many Fridays as possible.
p.s. A rectangle can do the trick as well, don't have to be a trend line.
Here's how far I've come:
Would appreciate any hints, thanks in advance.