Reply

Horizontal Lines for TP and SL

9 replies

beniko

Subscriber, bbp_participant, community, 31 replies.

Visit profile

7 years ago #116349

Hello,

 

I am trying to develop a semi-automatic EA that includes Horizontal lines, which when moved, the price of a double variable is updated.

 

To be more specific, when I place the EA on a chart, 3 lines shall appear. One for Stop loss, one for resistance and one for support. The user shall be able to move the lines and when done so, the price of a variable shall be updated. This variable will be used in conditions or order placement.

 

I tried yesterday to copy the code from an indicator that uses lines but due to my limited programming experience was unsuccessful.

 

I believe it would be a useful special feature to be able to link the price of a Horizontal line to a double variable.

 

Ben

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

7 years ago #141619

Hello,

 

I will check what can be done here. It might be possible to do it using custom function code

0

beniko

Subscriber, bbp_participant, community, 31 replies.

Visit profile

7 years ago #141652

Hello,

 

I will check what can be done here. It might be possible to do it using custom function code

Thank you, this would be very helpful!

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

7 years ago #141723

Hello,

 

can those lines be drawn by your EA? They could be then modified by hand in MetaTrader on chart. The problem is that manually created lines have its own name generated which I do not know in advance so I cannot select the line 

0

beniko

Subscriber, bbp_participant, community, 31 replies.

Visit profile

7 years ago #141731

Hello,

 

can those lines be drawn by your EA? They could be then modified by hand in MetaTrader on chart. The problem is that manually created lines have its own name generated which I do not know in advance so I cannot select the line 

Yes they should be drawn by the EA itself. Not new lines that are added manually.

 

I got inspired by tools like “Money Manager Graphic Tool – indicator for MetaTrader 4” found here https://www.mql5.com/en/code/13804. There are many others like it.

 

But all I need are a few simple lines that are drawn by the EA once it is placed on the chart and then the user can move these lines. When moved the price of certain variables shall be updated accordingly (or the price of the variables could be updated with each new tick as well). These variables can then be used in decision making and placing orders.

0

beniko

Subscriber, bbp_participant, community, 31 replies.

Visit profile

7 years ago #142014

any luck?

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

7 years ago #142028

Hello,

 

I have made an example on this. EA enters a trade + draws TP and SL lines, which when modified set the new price for SL and TP orders

 

You need to add this code into CustomFunctions.mq4 file

void drawHorizotalLine(string lineName = "hLine", double priceLevel = 0) {

   ObjectCreate(lineName, OBJ_HLINE, 0, Time[0], priceLevel); 

} 

double getProfitLinePrice() {

   double targetLine = ObjectGet("targetLine", OBJPROP_PRICE1) ;
   return targetLine;

} 

double getStopLinePrice() {

   double stopLine = ObjectGet("stopLine", OBJPROP_PRICE1) ;
   return stopLine;

}

And use it as shown in the project

0

beniko

Subscriber, bbp_participant, community, 31 replies.

Visit profile

7 years ago #142136

I didn’t know about the CustomFunctions.mq4. It will come in handy for other functions as well!

 

You brought me a lot closer to creating exactly the EA I have in mind.

 

Thank you very much. 

0

MimmoDS

Subscriber, bbp_participant, community, 14 replies.

Visit profile

6 years ago #197740

Simple support-resistance trading system tutorial for EA Wizard

I follwed the tutorial on the blog and then compiled the EA with the editor without error but it does not generates any trade and does not draw any line……….

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

6 years ago #197763

Viewing 9 replies - 1 through 9 (of 9 total)