please edit your post -
When you post code please use the CODE button (Alt-S)!
-
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
Messages Editor
Forum rules and recommendations - General - MQL5 programming forum (2023) - ayvaniniyisi: I get 27 errors. Can someone help me please?d
Help you with what? You haven't stated a single problem. Fix one, recompile, repeat.
#include <Trade\Trade.mqh> input int stopLoss = 100; // Stop Loss in points input int takeProfit = 200; // Take Profit in points CTrade trade; // Create an instance of the CTrade class #define POSITION_PRICE 1 // Define POSITION_PRICE constant //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { static double prevHigh = 0; static double prevLow = 0; static double prevClose = 0; double currentHigh = iHigh(Symbol(), 0, 1); double currentLow = iLow(Symbol(), 0, 1); double currentClose = iClose(Symbol(), 0, 1); double point = SymbolInfoDouble(Symbol(), SYMBOL_POINT); double positionPrice = trade.PositionGetDouble(POSITION_PRICE); if (currentHigh > prevHigh) { // Buy signal if (trade.Buy(0.1)) { trade.PositionModify(positionPrice - stopLoss *point, positionPrice + takeProfit* point); } } else if (currentLow < prevLow) { // Sell signal if (trade.Sell(0.1)) { trade.PositionModify(positionPrice + stopLoss *point, positionPrice - takeProfit* point); } } else if (currentClose > prevClose) { // Buy signal if (trade.Buy(0.1)) { trade.PositionModify(positionPrice - stopLoss *point, positionPrice + takeProfit* point); } } else if (currentClose < prevClose) { // Sell signal if (trade.Sell(0.1)) { trade.PositionModify(positionPrice + stopLoss *point, positionPrice - takeProfit* point); } } prevHigh = currentHigh; prevLow = currentLow; prevClose = currentClose; } //+------------------------------------------------------------------+
Errors:
'PositionModify' - no one of the overloads can be applied to the function call My Strategy.mq5 48 19
could be one of 2 function(s) My Strategy.mq5 48 19
bool CTrade::PositionModify(const string,const double,const double) Trade.mqh 99 22
bool CTrade::PositionModify(const ulong,const double,const double) Trade.mqh 100 22
Ok- I have only 2 errors left.
(Note: I have created this with two different AI's.)
Errors:
'ORDER_BUY' - undeclared identifier My Strategy.mq5 43 28
possible loss of data due to type conversion from 'double' to 'ulong' My Strategy.mq5 47 31
'ORDER_SELL' - undeclared identifier My Strategy.mq5 69 28
possible loss of data due to type conversion from 'double' to 'ulong' My Strategy.mq5 73 31
#include <Trade\Trade.mqh> input int stopLoss = 100; // Stop Loss in points input int takeProfit = 200; // Take Profit in points CTrade trade; // Create an instance of the CTrade class //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { static double prevHigh = 0; static double prevLow = 0; static double prevClose = 0; double currentHigh = iHigh(Symbol(), 0, 1); double currentLow = iLow(Symbol(), 0, 1); double currentClose = iClose(Symbol(), 0, 1); double point = SymbolInfoDouble(Symbol(), SYMBOL_POINT); double slippage = 3; MqlTradeRequest request = {}; MqlTradeResult result = {}; // Buy Order Request if (currentHigh > prevHigh) { if (PositionSelect(Symbol()) == false) // Check if there's no open position { request.action = TRADE_ACTION_DEAL; request.symbol = Symbol(); request.volume = 0.1; request.type = ORDER_BUY; request.price = SymbolInfoDouble(Symbol(), SYMBOL_BID); request.sl = request.price - stopLoss * point; request.tp = request.price + takeProfit * point; request.deviation = slippage; request.type_filling = ORDER_FILLING_FOK; request.type_time = ORDER_TIME_GTC; if (OrderSend(request, result)) { Print("Buy order placed successfully."); } else { Print("Buy order failed. Error: ", GetLastError()); } } } // Sell Order Request else if (currentLow < prevLow) { if (PositionSelect(Symbol()) == false) // Check if there's no open position { request.action = TRADE_ACTION_DEAL; request.symbol = Symbol(); request.volume = 0.1; request.type = ORDER_SELL; request.price = SymbolInfoDouble(Symbol(), SYMBOL_ASK); request.sl = request.price + stopLoss * point; request.tp = request.price - takeProfit * point; request.deviation = slippage; request.type_filling = ORDER_FILLING_FOK; request.type_time = ORDER_TIME_GTC; if (OrderSend(request, result)) { Print("Sell order placed successfully."); } else { Print("Sell order failed. Error: ", GetLastError()); } } } prevHigh = currentHigh; prevLow = currentLow; prevClose = currentClose; }
'ORDER_BUY' - undeclared identifier My Strategy.mq5 43 28
'ORDER_SELL' - undeclared identifier My Strategy.mq5 69 28
Stop using ChatGPT/Copilot.
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 |
|
bot builder | Creating two OnInit() functions. * |
EA builder | |
EATree | Uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.) |
ForexEAdvisor |
|
FX EA Builder |
|
Stop using ChatGPT/Copilot.
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 |
|
bot builder | Creating two OnInit() functions. * |
EA builder | |
EATree | Uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.) |
ForexEAdvisor |
|
FX EA Builder |
|
You are absolutely right. After I made my post, that is exactly what was going through my head.
But I don't know exactly where to start learning MQL5. And just thinking about it is overwhelming. That doesn't mean that I am not willing to learn. I am certainly open to learning new things. As I said, I don't really know where to start.
Should I learn small blocks of code first? I don't know what all the OnInit etc. mean. ://
Also, if you gave me the corrected parts of the code, it would always hurt me because I don't know what it means and how to really deal with it. (The hurt comes from the fact that I am inquisitive and curious, and in this case I don't know what I'm dealing with.)
Thank you for your detailed answer earlier.
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.
I need HEEEELP, please, it's URGENT...really ! - General - MQL5 programming forum (2017)
You are absolutely right. After I made my post, that is exactly what was going through my head.
But I don't know exactly where to start learning MQL5. And just thinking about it is overwhelming. That doesn't mean that I am not willing to learn. I am certainly open to learning new things. As I said, I don't really know where to start.
Should I learn small blocks of code first? I don't know what all the OnInit etc. mean. ://
Also, if you gave me the corrected parts of the code, it would always hurt me because I don't know what it means and how to really deal with it. (The hurt comes from the fact that I am inquisitive and curious, and in this case I don't know what I'm dealing with.)
Thank you for your detailed answer earlier.
There are good articles here. I learned things by going through the codebase, but going through an article sounds like the most reasonable approach to learning.
https://www.mql5.com/en/articles/15299
What AI is giving you is the non streamlined headache way of creating what you want to create. The article I just linked discusses the streamlined way of making buy and sell positions without the need to use the Request structure.
- www.mql5.com
There are good articles here. I learned things by going through the codebase, but going through an article sounds like the most reasonable approach to learning.
https://www.mql5.com/en/articles/15299
What AI is giving you is the non streamlined headache way of creating what you want to create. The article I just linked discusses the streamlined way of making buy and sell positions without the need to use the Request structure.
thank you.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
P. S. I m a beginner.
I get 27 errors. Can someone help me please?