BUY ORDER AND SELL ORDER WITH TP AND SL WITH PENDING ORDERS

 

Any body know the code for this strategy

When I Click The EA the following steps i want its possible?

Step 1 : Buy Order TP-20 pips SL-24 Pips

Step 2 : Sell Order TP-20 pips SL-24 Pips

Step 3 : Pending Order Sell Stop Price (First Step Buy Order SL) with TP-30 Pips SL-24 Pips

Step 4 : Pending Order Buy Stop Price (First Step Sell Order SL) with TP-30 Pips SL-24 Pips


Thank You

 
999220056:
i want its possible?
Of course it possible: learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
 

hi there, im not well versed in coding so i used chatgpt to help me code this. im down to 1 error and 1 warning. everytime i ask to fix the error after i compile them gives the same error 

this is the error

cannot convert 0 to enum 'ENUM_TRADE_REQUEST_ACTIONS' Buy with SL and TP.mq5 67 40

implicit enum conversion Buy with SL and TP.mq5 71 28


and this is generated the script, 

//+------------------------------------------------------------------+
//|                                            Buy Sell with SL and TP    |
//|                                            Copyright © 2024, |
//|                                                        |
//+------------------------------------------------------------------+
#property script_show_inputs

extern int    NumberOfOrders;
extern bool   UseActualSlTp;
extern double StopLossPrice;
extern double TakeProfitPrice;
extern string Note;
extern double Entry;
extern bool   MicroOrdersAllowed;
extern bool   MiniOrdersAllowed;

extern bool   UseMoneyMgmt;
extern double RiskPercent;
extern double Lots;
extern double StopLoss;
extern double TakeProfit;

extern string Comments;

//+------------------------------------------------------------------+
//| Script program start function                                   |
//+------------------------------------------------------------------+
void OnStart()
{ 
    double Risk = RiskPercent / 100;
    int OrdersizeAllowed = 0;
    int Mode = ORDER_TYPE_BUY_STOP;
    
    if (SymbolInfoDouble(_Symbol, SYMBOL_ASK) > Entry && Entry > 0) 
        Mode = ORDER_TYPE_BUY_LIMIT; 
    if (Entry == 0)  
    {
        Entry = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 
        Mode = ORDER_TYPE_BUY;
    }
    double SLB = Entry - StopLoss * _Point;
    double TPB = Entry + TakeProfit * _Point;

    if (UseActualSlTp)
    {
        StopLoss = (Entry - StopLossPrice) / _Point;
        SLB = StopLossPrice;
        TPB = TakeProfitPrice;    
    }
    if (MiniOrdersAllowed) 
        OrdersizeAllowed = 1;
    if (MicroOrdersAllowed) 
        OrdersizeAllowed = 2;        

    if (UseMoneyMgmt)  
        Lots = NormalizeDouble(AccountInfoDouble(ACCOUNT_BALANCE) * Risk / StopLoss / (SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE)), OrdersizeAllowed);       

    if ((Lots < 0.01 && MicroOrdersAllowed) || (Lots < 0.1 && MiniOrdersAllowed && !MicroOrdersAllowed))
    {
        Print("YOUR LOTS SIZE IS TOO SMALL TO PLACE!");
    } 

    if (Lots > 0)
    {
        for (int i = 0; i < NumberOfOrders; i++)
        {
            MqlTradeRequest request = {0};
            MqlTradeResult result = {0};

            request.symbol = _Symbol;
            request.type = Mode;
            request.volume = Lots;
            request.price = Entry;
            request.sl = SLB;
            request.tp = TPB;
            request.comment = Comments;
            request.action = TRADE_ACTION_DEAL; // Buy action

            if (OrderSend(request, result))
            {
                Print("Order placed successfully!");
            }
            else
            {
                Print("Failed to place order! Error code:", GetLastError());
            }
        }
    }
}

 
Thad Mangulabnan #:
hi there, im not well versed in coding so i used chatgpt to help me code this

Chatgpt generates absolute nonsense on MQL. Therefore, programmers will not even look at your generated code. Not because the programmers are bad, but because the chatgpt generates absolute nonsense.

Either learn programming or write a technical specification and hire a programmer.

 
Vladislav Boyko #:

Chatgpt generates absolute nonsense on MQL. Therefore, programmers will not even look at your generated code. Not because the programmers are bad, but because the chatgpt generates absolute nonsense.

Either learn programming or write a technical specification and hire a programmer.

i see thanks
 
Vladislav Boyko #:
learn programming

In that case, you might get some help here (if you try to write and understand the code rather than generate it).

 
Thad Mangulabnan #: , im not well versed in coding so i used chatgpt

Stop using ChatGPT.
          Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum #2 (2023)

ChatGPT (the worst), “Bots Builder”, “EA builder”, “EA Builder Pro”, EATree, “Etasoft forex generator”, “Forex Strategy Builder”, ForexEAdvisor (aka. ForexEAdvisor STRATEGY BUILDER, and Online Forex Expert Advisor Generator), ForexRobotAcademy.com, forexsb, “FX EA Builder”, fxDreema, Forex Generator, FxPro, “LP-MOBI”, Molanis, “Octa-FX Meta Editor”, Strategy Builder FX, “Strategy Quant”, “Visual Trader Studio”, “MQL5 Wizard”, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.

Since you haven't learned MQL4/5, therefor 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 yours.

We are willing to HELP you when you post your attempt (using Code button) and state the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

ChatGPT
  1. Even it says do not use it for coding. * 
  2. Mixing MT4 and MT5 code together.
  3. Creating multiple OnCalculate/OnTick functions.
  4. OnCalculate returning a double.
  5. Filling buffers with zero in OnInit (they have no size yet). Setting buffer elements to zero but not setting Empty Value to correspond.
  6. Calling undefined functions.
  7. Calling MT4 functions in MT5 code.
  8. Sometimes, not using strict (MT4 code).
  9. Code that will not compile.
  10. Creating code outside of functions. * 
  11. Creating incomplete code. * 
  12. Initialization of Global variables with non-constants. * 
  13. Assigning a MT5 handle to a double or missing the buffer and bar indexes in a MT4 call. * 
  14. Useing MT4 Trade Functions without first selecting an order. * 
  15. Uses NULL in OrderSend. * 
bot builder Creating two OnInit() functions. * 
EA builder
  1. Counting up while closing multiple orders.
  2. Not useing time in new bar detection.
  3. Not adjusting for 4/5 digit brokers, TP/SL and slippage. * 
  4. Not checking return codes.
EATree Uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)
ForexEAdvisor
  1. Non-updateing global variables.
  2. Compilation errors.
  3. Not checking return codes.
  4. Not reporting errors.
FX EA Builder
  1. Not checking return codes.
  2. Loosing open tickets on terminal restart. No recovery (crash/power failure.)
  3. Not adjusting stops for the spread. * 
  4. Using OrdersTotal directly.
  5. Using the old event handlers.
Reason: