Coding help - page 783

 
grap me:
Hello,
I am just beginner in learning of mql4. I am trying to create a basic supertrend indicator.
I need some expert's help regarding alerts code.


Current Alert Code:
Alert(Symbol() + " (" + Period() + "M) --> " + LSignal + CPri);

Output coming like this:
Symbol Name (15M) --> Buy at 524.55

But, I need stoploss and targets also in the alert based on following simple calculation.

Assume our buy entry at 524.55.

Stoploss : Entry - 1.5% of the stock entry price (524.55 - 7.85 = 516.70)
Target 1 : Entry + 2.5% of the stock entry price (524.55 + 13.10 = 537.65)
Target 2 : Entry + 5% of the stock price (524.55 + 26.20 = 550.75)

(Note: Tick size is 0.05. So if stoploss or target calculation is comes an odd number, need to be rounded to nearest tick size. And if LSignal is a sell signal, need reverse calculation.


Finally I need following output:
Symbol Name (15M) --> Buy at 524.55, SL: 516.70, Target 1: 537.65, Target 2: 550.75


Can somebody please rewrite the code for my requirement?

TY in adv.
    //Open Price 
      double OP   =524.55;
      double SL_p =1.5;  //Stop Loss % 
      double TP1_p=2.5;  //Take Profit 1 %
      double TP2_p=5;    //Take Profit 2 %
      int d=Digits();    //assumed its the native symbol
      double ts=Point(); //tick size ,assumed its the native symbol
      double SL_size=(OP/100)*SL_p;//open price / 100 , times % ,but thats floaty so ...
      //find how many "points" are in it ,and that must have no decimal points ,so integer
      int how_many_tick_sizes=(int)(SL_size/ts);
      //and then multiply the tick sizes with the points
      SL_size=((double)how_many_tick_sizes)*ts;
      //and then normalize it to have the same digits as the Symbol
      SL_size=NormalizeDouble(SL_size,d);
      //or in short 
      SL_size=NormalizeDouble(((int)(((OP/100)*SL_p)/ts))*ts,d);
      //tp1 in short 
      double TP1_size=NormalizeDouble(((int)(((OP/100)*TP1_p)/ts))*ts,d);
      //tp2 in short 
      double TP2_size=NormalizeDouble(((int)(((OP/100)*TP2_p)/ts))*ts,d);
      //you can add or remove these according to the order type 

Heres a calculation example 

 

Hello all

Could any kind soul write this simple indicator for me?

I need an indicator that draws only 2 horizontal lines, one x ticks above and other x ticks below the current previous bar close price. 

I would be eternally grateful

 
I am trying to upload my product but every time these erorrs are come. But in strategy testor no errors and also mql editor no errors . EA is working good in strategy testor.
Files:
Capture.JPG  82 kb
Trend_taker.mq4  13 kb
 

It's error 130.

ERR_INVALID_STOPS 130 Invalid stops.
 

I want to develop very simple EA.

1) All pending order is automatically open with 30 pips interval.

2) 50 pips tp must be on all orders.

3) For each closed order, a new order must be opened at the previous opening level.


I am not programmer , i need codes.

Please help me.

Thank you

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
Requests to execute trade operations are formalized as orders. Each order has a variety of properties for reading. Information on them can be obtained using functions Position identifier that is set to an order as soon as it is executed. Each executed order results in a deal that opens or modifies an already existing position. The identifier of...
 

what do i do next, i want my robot to buy when indicator> 0 and sell when <0

 
  1. Don't post pictures of code, they are too hard to read.

    Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2. Phương Tú Long: what do i do next, i want my robot to buy when indicator> 0 and sell when <0

    Help you with what? You haven't stated a problem, you stated a want.
         How To Ask Questions The Smart Way. 2004
              Prune pointless queries.

    You have only four choices:

    1. Search for it. Do you expect us to do your research for you?

    2. Beg at:

    3. MT4: Learn to code it.
      MT5: Begin learning to code it.

      If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

    4. or pay (Freelance) someone to code it. Top of every page is the link Code Base.
                Hiring to write script - General - MQL5 programming forum 2019.08.21

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
              No free help 2017.04.21

 
can any one help me to Add ALERT when a candle breakout on a Zigzag channel Indicator please.
Files:
 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
 

Hi everyone. I'm looking for a simple (adjustable) Keltner channel or bands indicator where I can get an alert any time price crosses either the upper or lower band - doesn't even need to close over/under, just cross that band/channel.

I promise I've looked EVERYWHERE on the internet to see if it already exists - tried one with an alert but didn't work because the alert was on the center/middle line.

If anyone can point me in the right direction, much appreciation to you!

Reason: