Could you help me with this code? mt4 EA

 

Hello I have this code that adds a fibonacci configured with risk / reward .. but I need it not to be added when adding the EA to the chart as the code currently does, I need the fibonacci to be added to the chart when I use the buy or sell button so I wanted to know who can help me with this code to pass it to EA .. I am not a programmer.. thanks


#property version   "1.00"
#property strict
string system_tag="Test_";
int OnInit()
  {
   DrawOrderFiboNotRealFibo(OP_BUY,1,Open[0],Time[0],400,3,10,system_tag);
   return(INIT_SUCCEEDED);
  }
//FUNCTION TO PORT 
void DrawOrderFiboNotRealFibo(ENUM_ORDER_TYPE direction,
                              int order_ticket,
                              double open_price,
                              datetime open_time,
                              double stop_loss_points,
                              int levels,
                              int bars_time_forward,
                              string system_tags){
string object_name=system_tags+"_"+IntegerToString(order_ticket);
double sl_price=open_price;
if(direction==OP_BUY){sl_price-=(stop_loss_points*Point());}
if(direction==OP_SELL){sl_price+=(stop_loss_points*Point());}
sl_price=NormalizeDouble(sl_price,Digits());
datetime forwardtime=(datetime)(Time[0]+bars_time_forward*PeriodSeconds());
bool obji=ObjectCreate(ChartID(),object_name,OBJ_FIBO,0,open_time,open_price,forwardtime,sl_price);
  if(obji){
  ObjectSetInteger(ChartID(),object_name,OBJPROP_LEVELS,levels+2);
  //0 sl
  ObjectSetString(ChartID(),object_name,OBJPROP_LEVELTEXT,0,"StopLoss");
  ObjectSetDouble(ChartID(),object_name,OBJPROP_LEVELVALUE,0,0.0);
  //1 op
  ObjectSetString(ChartID(),object_name,OBJPROP_LEVELTEXT,1,"OpenPrice");
  ObjectSetDouble(ChartID(),object_name,OBJPROP_LEVELVALUE,1,1.0);
  //ObjectSetDouble(ChartID(),object_name,OBJPROP_
  ObjectSetDouble(ChartID(),object_name,OBJPROP_PRICE1,open_price);
  ObjectSetDouble(ChartID(),object_name,OBJPROP_PRICE2,sl_price);
  //...
     double lvl=1.0;
     int reward=0;
     for(int l=0;l<levels;l++){
     reward++;
     lvl+=1.0;
     ObjectSetString(ChartID(),object_name,OBJPROP_LEVELTEXT,l+2,"TP 1:"+IntegerToString(reward));
     ObjectSetDouble(ChartID(),object_name,OBJPROP_LEVELVALUE,l+2,lvl);
     }
  }
}
void OnDeinit(const int reason)
  {
  ObjectsDeleteAll(ChartID(),system_tag); 
  }
void OnTick(){}


 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
 
Deibys marrero:

Hello I have this code that adds a fibonacci configured with risk / reward .. but I need it not to be added when adding the EA to the chart as the code currently does, I need the fibonacci to be added to the chart when I use the buy or sell button so I wanted to know who can help me with this code to pass it to EA .. I am not a programmer.. thanks



You can insert the code to the EA you like, or change this to a script so it can be executed while you run your EA.

Reason: