Can somebody help me? MT4

 

Hello I would like to know if someone could give me a hand .. I am not a programmer but sometimes I like to play with codes .. to the subject .. I have a script that its function is: when adding it to the graph it adds a fibonacci retracement but modified with risk reward .. I would like to know if you can make an EA that when taking an order this case "sell" add this fibonacci automatically I leave the code .. who can help me I appreciate it very much!

//+------------------------------------------------------------------+
//|                                      Draw_Fib EP SL TP Lines.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""


int start()
{
   if(ObjectFind("FibNode#1") != -1)
      ObjectDelete ("FibNode#1");
      ObjectDelete ("FibNode#14");
      
   datetime drop_time=WindowTimeOnDropped();
   double drop_price=WindowPriceOnDropped();
   
   if (drop_time>0)
   {} else {drop_time=TimeCurrent(); drop_price=Bid;}
   
      
   ObjectCreate("FibNode#1",OBJ_FIBO,0,drop_time,drop_price,drop_time+5000,drop_price+(Point*300));
   ObjectSet("FibNode#1",OBJPROP_LEVELCOLOR,Yellow);
   //ObjectSet("FibNode#1",OBJPROP_LEVELSTYLE,STYLE_SOLID);
   ObjectSet("FibNode#1",OBJPROP_LEVELWIDTH,1);
   ObjectSet("FibNode#1",OBJPROP_COLOR,Yellow);
   ObjectSet("FibNode#1",OBJPROP_RAY,False);
   
   ObjectSet("FibNode#1",OBJPROP_FIBOLEVELS,6);
   
   
   ObjectSet("FibNode#1",OBJPROP_FIRSTLEVEL+0,1); // entry price ... 1
   ObjectSet("FibNode#1",OBJPROP_FIRSTLEVEL+1,0); // SL R ... 0
   ObjectSet("FibNode#1",OBJPROP_FIRSTLEVEL+2,2.0); // TP 0.5R ...  -0.5
   ObjectSet("FibNode#1",OBJPROP_FIRSTLEVEL+3,3.0); // TP 1.0R ... -1.0
   ObjectSet("FibNode#1",OBJPROP_FIRSTLEVEL+4,4.0); // TP 1.5R ... -2.0
   ObjectSet("FibNode#1",OBJPROP_FIRSTLEVEL+5,5.0); // TP 1.5R ... -2.0
   
   
   ObjectSetFiboDescription( "FibNode#1", 0,"BREAK EVEN       ");
   ObjectSetFiboDescription( "FibNode#1", 1,"STOP LOSS        ");
   ObjectSetFiboDescription( "FibNode#1", 2,"TP1 1.1          ");
   ObjectSetFiboDescription( "FibNode#1", 3,"TP2 2.1          ");
   ObjectSetFiboDescription( "FibNode#1", 4,"TP3 3.1          ");
   ObjectSetFiboDescription( "FibNode#1", 5,"TP4 4.1          ");
      
   return(0);
}

 
Deibys marrero:

Hello I would like to know if someone could give me a hand .. I am not a programmer but sometimes I like to play with codes .. to the subject .. I have a script that its function is: when adding it to the graph it adds a fibonacci retracement but modified with risk reward .. I would like to know if you can make an EA that when taking an order this case "sell" add this fibonacci automatically I leave the code .. who can help me I appreciate it very much!

When an order is taken a fibonacci is dropped with the TP parameter as the (+300 points)? 

 
Lorentzos Roussos:

When an order is taken a fibonacci is dropped with the TP parameter as the (+300 points)? 

it is correct when adding the script take the stop loss 30 pips "300 point" then 1: 1 = 30 pips, 2: 1 = 60pips  and so on until  4: 1 my intention is that when pressing the sell button the EA draws the fibonacci as the script does.


Example if I were taking a "sell" the EA place the fibonacci like this

images : https://ibb.co/BjsX3qq


 
Deibys marrero:

it is correct when adding the script take the stop loss 30 pips "300 point" then 1: 1 = 30 pips, 2: 1 = 60pips  and so on until  4: 1 my intention is that when pressing the sell button the EA draws the fibonacci as the script does.


Example if I were taking a "sell" the EA place the fibonacci like this

images : https://ibb.co/BjsX3qq


Aha . Try this 

#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(){}
 
Lorentzos Roussos:

Aha . Try this 

Thank you very much for your help, but it still does not do what I need .. it's ok to add the EA add the fibonacci ... but I would like you to add it only when taking an order,
I really appreciate your help

 
Deibys marrero:

Thank you very much for your help, but it still does not do what I need .. it's ok to add the EA add the fibonacci ... but I would like you to add it only when taking an order,
I really appreciate your help

You can call the function in your EA when an order is sent and it will draw it . 

 
Lorentzos Roussos:

You can call the function in your EA when an order is sent and it will draw it . 

I don't understand much .. I'm not a programmer :(

 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
 
Deibys marrero:

I don't understand much .. I'm not a programmer :(

I thought you had an EA to which you wanted to add this when it placed trades.

 
Lorentzos Roussos:

I thought you had an EA to which you wanted to add this when it placed trades.

Not the code that I put is a script so I wanted to pass it to EA .. I don't have EA :(

 
Deibys marrero:

Not the code that I put is a script so I wanted to pass it to EA .. I don't have EA :(

And how would the EA trade though?