[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 342

 


Thank you very much.Swan
 

Can you please tell me if I open an order

OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, oSL, oTP, "", ExpertID, 0, Red)

If a Stop Loss is triggered, open double lot on next order opening which is done automatically

 
vik-777 >> :

Can you please tell me if I open an order

OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, oSL, oTP, "", ExpertID, 0, Red)

If a Stop Loss is triggered, open a doubled lot at the next order opening which is done automatically


Put these lines in the very beginning of the START function and use the variable _SL[0] to determine the outcome of the previous trade.

if (OrderSelect(Tic,SELECT_BY_TICKET)==true)
{
if (OrderComment()=="[sl]")_SL[0]=-1;
if (OrderComment()=="[tp]")_SL[0]=1;
}

 

Problem.

There is an EA. If the variables Lot, Porog, Otstup, SL, TP are set in the "body" of the program, then the EA works. If these variables are set as "extern" (by setting them via settings), then the EA does not work (in the "body" of the EA, these variables have a value of ZERO).

What can be the problem? Where to look for a solution?

/*
extern double Lot = 0.1;    

extern double Porog = 5.0;  
extern double Otstup = 5.0; 

extern double SL = 5.0; 
extern double TP = 15.0; 
*/

int init()
  {
   return(0);
  }
int deinit()
  {
   return(0);
  }

int start()
  {
  int MagicNumber = 8; 
  int ticket;
  int err;
  int q=0;

double Lot = 0.1;    
double Porog = 5.0;  
double Otstup = 5.0; 
double SL = 5.0; 
double TP = 15.0; 
 

Could you please suggest a function to implement a dialog box where you can specify variable values.

For example, there is a buy script (buy with Sl and Tp set), when you run it, a dialog box is displayed where you can specify e.g. lot size, then press Ok and the order is executed!

Thank you!

 

Dear Professionals, Please advise...

In my indicator I use a text that displays data about the value of the indicator curve on the chart

{ObjectCreate("P"+Time[ ai],OBJ_TEXT,0,Time[ ai],High[ ai]+ Label);
ObjectSetText("P"+Time[ ai]," "+DoubleToStr( HL,2),7,"Arial",Black);}
I have to shift it on the Label parameter to keep the text on the curve. But when we shift to another period or increase/decrease the chart, the chart scale changes and we have to edit again. Can the text shift be set differently, e.g. in screen pixels?
 
kon12 писал(а) >>

Dear Professionals, Please advise...

In my indicator I use a text that displays data about the value of the indicator curve on the chart

To make sure the text does not overlap the curve, we have to shift it by the Label parameter. But when changing to another period or increasing/decreasing the graph, the graph scale changes and you have to edit again. Can the text shift be set differently, e.g. in screen pixels?

You can use

OBJ_LABEL 23 It is a text label. Does not use coordinates. The ObjectSet() function is used to set coordinates set in pixels relative to the reference angle (OBJPROP_CORNER, OBJPROP_XDISTANCE, OBJPROP_YDISTANCE properties). To change the text, function ObjectSetText() is used.

 
I don't quite understand how? I am attaching a picture of the indicator. The point is that the text is linked to specific points in the indicator.
 
kon12 писал(а) >>
I do not quite understand how? I attach a picture of the indicator. The point is that the text is attached to specific points in the indicator.

Then you have to make the Label dynamic. For each timeframe its own. Once in the init and forget about it. But first, you have to select it.

 
kon12 >> :
Can the text shift be set differently, e.g. in screen pixels?

The most correct answer is no.

Reason: