Hi, could someone give a hand of help?
edit your post and use the code button to insert your code properly </> or Alt-S
don't use links to the errors put them in your post or attach them
Hi, could someone give a hand of help?
I;m trying code a EA for MT4 .
The EA checks if the Fibonacci Retracements tool exists on the open chart of the trading instrument. If it exists, the EA reads the price value corresponding to Level 0 and the price value corresponding to Level 1 in the Fibo. It stores these values. The value of Level 1 is permanent and does not change.
If the price value corresponding to Level 0 increases, then automatically adjusts the fibo tool accordingly with the price.
If the value of Level 0 decreases, it holds the fibo tool at the highest price recorded before the fall, in which case the fibo ratios will not change.
I use the code:
<
/>
But after compiling I receive these errors: https://prnt.sc/oT4ikDLzzYbE
Hello .
You don't need to use GetValueByShift for fibonacci as the lines are horizontal and dont change
Here is an example that reads all the fibo lines on the chart , their price and their ratio .
Specific to your issue , to get the prices use these :
double onePrice=ObjectGetDouble(ChartID(),sparam,OBJPROP_PRICE,0);//get 100% retracement price double zeroPrice=ObjectGetDouble(ChartID(),sparam,OBJPROP_PRICE,1);//get 0% retracement price
Then the fibo offers the ratio of each level which can help you project the price of any level the user has active
int total_levels=(int)ObjectGetInteger(ChartID(),sparam,OBJPROP_LEVELS); double onePrice=ObjectGetDouble(ChartID(),sparam,OBJPROP_PRICE,0);//get 100% retracement price double zeroPrice=ObjectGetDouble(ChartID(),sparam,OBJPROP_PRICE,1);//get 0% retracement price double range=onePrice-zeroPrice; for(int i=0;i<total_levels;i++) { double value=ObjectGetDouble(ChartID(),sparam,OBJPROP_LEVELVALUE,i);//ratio double price=zeroPrice+range*value; }
The example in full code for testing :
fibonacci object line values
#property copyright "Read the discussion" #property link "https://www.mql5.com/en/forum/441057" #property strict int OnInit() { //--- create timer // EventSetTimer(60); ChartSetInteger(ChartID(),CHART_EVENT_OBJECT_CREATE,true); //--- return(INIT_SUCCEEDED); } void OnTick() { } void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- if(id==CHARTEVENT_OBJECT_CREATE){ if(ObjectGetInteger(ChartID(),sparam,OBJPROP_TYPE)==OBJ_FIBO){ int total_levels=(int)ObjectGetInteger(ChartID(),sparam,OBJPROP_LEVELS); Print("Fibo spotted , "+IntegerToString(total_levels)+" levels"); double onePrice=ObjectGetDouble(ChartID(),sparam,OBJPROP_PRICE,0);//get 100% retracement price double zeroPrice=ObjectGetDouble(ChartID(),sparam,OBJPROP_PRICE,1);//get 0% retracement price double range=onePrice-zeroPrice; for(int i=0;i<total_levels;i++) { double value=ObjectGetDouble(ChartID(),sparam,OBJPROP_LEVELVALUE,i); double price=zeroPrice+range*value; Print("Level["+IntegerToString(i)+"] :: "+DoubleToString(value,2)+" :: "+DoubleToString(price,_Digits)); } }} } //+------------------------------------------------------------------+
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I;m trying code a EA for MT4 .
The EA checks if the Fibonacci Retracements tool exists on the open chart of the trading instrument. If it exists, the EA reads the price value corresponding to Level 0 and the price value corresponding to Level 1 in the Fibo. It stores these values. The value of Level 1 is permanent and does not change.
If the price value corresponding to Level 0 increases, then automatically adjusts the fibo tool accordingly with the price.
If the value of Level 0 decreases, it holds the fibo tool at the highest price recorded before the fall, in which case the fibo ratios will not change.
I use the code:
<
/>
But after compiling I receive these errors: https://prnt.sc/oT4ikDLzzYbE