Created a BuyStop button with predefine button

 

Can you guys help me out check if there any problem 
if i add a BuyStop and SellStop together or shall it be separate 

#include<Trade\Trade.mqh>

  CTrade trade;

  double Ask,Bid;

void OnTick()

{

Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);

Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);

ObjectCreate(_Symbol,"BuyButton",OBJ_BUTTON,0,0,0);



ObjectSetInteger(_Symbol,"BuyButton",OBJPROP_XDISTANCE,200);

ObjectSetInteger(_Symbol,"BuyButton",OBJPROP_XSIZE,200);

ObjectSetInteger(_Symbol,"BuyButton",OBJPROP_YDISTANCE,200);

ObjectSetInteger(_Symbol,"BuyButton",OBJPROP_YSIZE,50);

ObjectSetInteger(_Symbol,"BuyButton",OBJPROP_CORNER,2);

ObjectSetString(_Symbol,"BuyButton",OBJPROP_TEXT,"BUY");



}



 void OnChartEvent

 (const int id,const long &lparam,const double &dparam,const string &sparam)

 {

 

  if(id==CHARTEVENT_OBJECT_CLICK)

  {

   if(sparam=="BuyButton")

   {

    Comment(sparam+" was pressed");

trade.BuyStop(0.10,Ask+120*_Point,Ask-150*_Point,0,ORDER_TIME_GTC,0,0);

trade.SellStop(0.10,Ask-100*_Point,Ask+150*_Point,0,ORDER_TIME_GTC,0,0); 
  }
 }
}
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Forum on trading, automated trading systems and testing trading strategies


When you post code please use the CODE button (Alt-S)!

Use the CODE button


Reason: