1. Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)
    Dismiss Notice

Suggestion Need a help for making an mt4 script

Discussion in 'Indicators dan Tools' started by thomas123, 11 Jul 2023.

  1. thomas123

    thomas123 New Member

    Equity
    Credit
    Ref Point
    Hi everyone...
    I need an mt4 script that can put one buy stop order and one sell stop order by DISTANCE from the OPEN PRICE of a specified candle. No SL and TP needed.

    For example:
    In the script settings, I set the trading time start at 12:15, distance 10 pips, and lot size 1. When the time comes up (12:15) and it detects the open price of candle 12:15 is 1.12345, so the script immediately put a buy stop at 1.12445 and a sell stop at 1.12245. Can someone help to create or share it if you have one please?

    Thank you [​IMG]
    Best regards, Shakka.
     
  2. Shipr

    Shipr New Member

    Equity
    Credit
    Ref Point
    Check.

    StartHour // hour of placing an order
    StartMin // minute of placing an order

    EndHour // hour of order deletion
    EndMin // minute of order deletion

    Start_Lot // volume

    dist_order // distance from the opening price of the candle

    Magic // magic number for the order
     

    Attached Files:

  3. thomas123

    thomas123 New Member

    Equity
    Credit
    Ref Point
    Thanks shipr for your help :ok:
    I will try it out later, and will inform you if there is any problem.
     
  4. Shipr

    Shipr New Member

    Equity
    Credit
    Ref Point
    Ок.:хорошо:
     
  5. thomas123

    thomas123 New Member

    Equity
    Credit
    Ref Point
    Ok shipr, found a problem here.
    Once after I attached the script into a chart, there was no a setting window appear, instead it placing stop order immediately. I cannot change the inputs setting. Can you fix it?
    Thank you
     
  6. Shipr

    Shipr New Member

    Equity
    Credit
    Ref Point
    ---------------------------------------

    1. open the editor. F4
    2. as in the picture, add this line: #property show_inputs
    3. compile the code. F7

    The settings should appear.
     

    Attached Files:

    • _01.png
      _01.png
      File size:
      52.5 KB
      Views:
      54
  7. sigit sutanto

    sigit sutanto New Member

    Equity
    Credit
    Ref Point

    ##########=========########

    i want to backtest about this system, if ok early give information
     
  8. Shipr

    Shipr New Member

    Equity
    Credit
    Ref Point
    Remade.

    Check.


    Advisor.

    1. drop the Expert into the advisors folder.

    2. The Expert Advisor Places two stop orders at the specified time.

    3. Expert Advisor Deletes the remaining order at the specified time.

    4. The expert itself is unloaded from the chart, with the removal of the last order by it.

    -------------------------------

    ps Delete the script, it's not working.
     

    Attached Files:

    • Like Like x 1
  9. thomas123

    thomas123 New Member

    Equity
    Credit
    Ref Point
    Hello shipr, your help is highly appreciated.
    I have some request.
    For point no 2, can you please modify it to place stop order exactly from open price/open value of chosen candle? Must exactly the open price/value not the running price. As a benchmark, that open price/value can be seen in the data window.
    For point no 3, can be removed, it is not needed.
    For point no 4, the EA can trades every day without needing to be reattached everytime.
    Add an One Cancel Other (OCO) feature, that can be turned ON or OFF. E.g. buy stop get triggered, delete the sell stop, and vice versa.
    Thank you..
    Best regards, Shakka.
     
    Last edited: 13 Jul 2023
  10. Shipr

    Shipr New Member

    Equity
    Credit
    Ref Point
    1. №2 Позицию можно открыть только по цене открытия свечи.
    Ордер не может быть размещен по цене открытия свечи. Минимально допустимое расстояние для каждого брокера разное.
    Установите dist_order = 0; И вы увидите, какова минимальная стоимость пипсов, на которую размещается ордер у вашего брокера.
    Or I misunderstood you.
    ps Для SELL_STOP я не стал добавлять минимальное размещение ордера. Я исправлю это.

    2. №3 можно сделать..
    3. №4 можно сделать..
     
    Last edited: 13 Jul 2023
  11. Shipr

    Shipr New Member

    Equity
    Credit
    Ref Point
    Remade.

    Check.
     

    Attached Files:

  12. Shipr

    Shipr New Member

    Equity
    Credit
    Ref Point
    Explain with an example. What should happen. How orders should be placed. For example:
    1. The time set in the parameters has come.
    2. A new candle has been opened.
    3. Next what?
    4. Where should the BUY_STOP order be placed?
    4.1. At what price?
    4.2. What should happen when the opposite order is triggered?
    5. Where should the SELL_STOP order be placed?
    And so on...

    ps Try to explain point by point, otherwise it is not possible to ask clarifying questions. And also, understanding can leave us, and never return.
     
  13. thomas123

    thomas123 New Member

    Equity
    Credit
    Ref Point
    Hello shipr...
    I found some problems, as follows:
    1. The OCO is not working.
    2. For safety, can it stop placing new order if I delete the position manually?
    3. I noticed that the buy stop order distance was calculated from ask price. Can you make it from bid price instead of ask price?
    4. In the input setting, first and second column is not in English.
    20230714_115405.jpg

    Thank you
     
    Last edited: 14 Jul 2023
  14. Johny Johnson

    Johny Johnson New Member

    Equity
    Credit
    Ref Point
    Sharp did u make this indicator?
     
  15. Shipr

    Shipr New Member

    Equity
    Credit
    Ref Point
    Remade.

    Check.
     

    Attached Files:

  16. thomas123

    thomas123 New Member

    Equity
    Credit
    Ref Point
    Hi shipr, same problem here:
    1. After EA placed stop order, and I deleted it manually, it kept replacing the new stop order. Only after I removed the EA, then no more order were placed.
    2. I noticed that the buy stop order distance was calculated from ask price. Can you make it from bid price instead of ask price?
    Thanks
     
  17. thomas123

    thomas123 New Member

    Equity
    Credit
    Ref Point
    Hi shipr, another question. Can it work everyday at the same time without needing to be reattached?
    Once the above problem solved, can you add this parameter please.
    In the EA setting, there are start hour and start min. Please add start seconds. What is it used for? The following is an example case of why we need it. Hope it explained it clearly.
    E.g. if I set start trading at 18:37:05, it will place stop order 5 seconds after the opening of candle 18:37 (in this case use 1 min timeframe). The open price of candle 18:37 is now become a historical data, can be seen and printed in data window, permanently unchanged. So, there is 5 secs delay, can be used for the EA to notice that open price. By this way, when the trading time has come which is 18:37:05, it will make the EA accurately place stop order X pips away calculated from that open price. Does it make sense and possible to be coded?
    Thank you[​IMG]
     
  18. Shipr

    Shipr New Member

    Equity
    Credit
    Ref Point
    1. At the specified time, the adviser places 2 opposite orders.

    2. If one placed order works, then the second one is deleted.


    3. If the distance from the open candle turns out to be unacceptable,
    the expert will calculate the placement of the order,
    based on the current price.


    4. Time of placing orders, entered in the input field, red.
    If the time is set correctly, the input field will change color from red to blue.

    Change the time in the input field, on the chart with a mouse click and keyboard and press Enter.

    The rest of the settings can be found in the Expert Options.

    --------------------------------------------------------------------------------

    _01.png _02.png _03.png _04.png _05.png
     

    Attached Files:

  19. thomas123

    thomas123 New Member

    Equity
    Credit
    Ref Point
    Hi shipr, nice improvement, thank you...
    But, there are something need to be fixed:
    1. For simplicity, you may remove the tp and sl, since I dont use it.
    2. Place buy stop order should be following bid price, not ask price.
    3. EA should be strictly place stop order based on open price of a candle, not current running price. Placing accurately, not even 0.01 pips difference.

    Below is an example of inaccurate execution of the EA. I set the distance 10 pips away.
    20230720_113512.jpg
    Open price candle 05:29 is 0.68289
    - It place buy stop at 0.68396❌ (it should be at 0.68389✔)
    - It place sell stop at 0.68184 ❌ (it should be at 0.68189✔)

    Kind regards,
    Shakka
     
    Last edited: 20 Jul 2023
  20. Shipr

    Shipr New Member

    Equity
    Credit
    Ref Point
    3. It is not possible to simultaneously place two opposite pending orders at the opening price of a new bar.

    I don't understand where you want to put pending orders.

    Show in the picture where you want to put them?
     

    Attached Files:

    • _01.png
      _01.png
      File size:
      8 KB
      Views:
      34

Share This Page