Nazar Jawas:
Hi
How can solve those errors:
First Error:
(('SymbolInfoDouble' - no one of the overloads can be applied to the function
could be one of 2 function(s)
built-in: double SymbolInfoDouble(const string,ENUM_SYMBOL_INFO_DOUBLE)
built-in: bool SymbolInfoDouble(const string,ENUM_SYMBOL_INFO_DOUBLE,double&) ))
Secon Error:
'commentCharArr' - invalid array access
implicit conversion from 'number' to 'string'
Please post your code properly, use the code button.
Second issue: you are applying an uchar array to a string variable.
After posting correctly, get the answer to your first question.
what is the solution? How to fix those errors?
Nazar Jawas #:
what is the solution? How to fix those errors?
what is the solution? How to fix those errors?
Are you on MT4??
Your file shows .mq5
You are using these wrong:
They return a handle and need to go into OnInit.
Then you use CopyBuffer with the handle to get the data from the indicators. - Wondering, you should receive warnings from your compiler....
You need to do some search on the forum about this wrong code (for MQL5):
double RSI_Value = iRSI(Symbol(), 0, RSI_Period, PRICE_CLOSE); double Stoch_K_Value = iStochastic(Symbol(), 0, Stoch_K_Period, Stoch_D_Period, MODE_SMA, 0, 0);
Dominik Egert #:
Are you on MT4??
Your file shows .mq5
You are using these wrong:
They return a handle and need to go into OnInit.
Then you use CopyBuffer with the handle to get the data from the indicators. - Wondering, you should receive warnings from your compiler....
You need to do some search on the forum about this wrong code (for MQL5):
#property copyright "Copyright 2023, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict // Define the input parameters input double lotSize = 0.01; input double targetProfit = 450; input double stopLoss = 300; input int minLots = 2; input int highPricePips = 10; input int rsiPeriod = 7; input int stochKPeriod = 3; input int stochDPeriod = 3; input int rsiThreshold = 90; input int stochThreshold = 90; input int slippage = 13; // Maximum allowed slippage input int magicNumber = 12345; // Magic number for trades double availableBalance; double maxLotSize; double tradeLotSize; int openOrderCount = 0; // Indicator handles int rsiHandle, stochHandle; void OnTick() { double rsiValue[], stochKValue[]; ArrayResize(rsiValue, 1); ArrayResize(stochKValue, 1); // Fetch indicator values if (CopyBuffer(rsiHandle, 0, 0, 1, rsiValue) != -1 && CopyBuffer(stochHandle, 0, 0, 1, stochKValue) != -1) { if (rsiValue[0] <= rsiThreshold && stochKValue[0] <= stochThreshold) { int spread = (int)SymbolInfoInteger(Symbol(), SYMBOL_SPREAD); double askPrice = SymbolInfoDouble(Symbol(), SYMBOL_ASK); double point = SymbolInfoDouble(Symbol(), SYMBOL_POINT); if (spread >= highPricePips * point) { MqlTradeRequest request; MqlTradeResult result; request.action = TRADE_ACTION_DEAL; request.type = ORDER_TYPE_SELL; request.volume = tradeLotSize; request.price = askPrice; request.deviation = slippage; request.magic = magicNumber; string comment = "Order Sell v1"; request.comment = comment; bool res = OrderSend(request, result); if (!res) { Print("Error sending order: ", GetLastError()); // Handle the error here } } } } openOrderCount = OrdersTotal(); } void OnStart() { // Create handles for the indicators rsiHandle = iRSI(NULL, 0, rsiPeriod, PRICE_CLOSE); stochHandle = iStochastic(NULL, 0, stochKPeriod, stochDPeriod, MODE_SMA, 0, 0); availableBalance = AccountInfoDouble(ACCOUNT_BALANCE); double point = SymbolInfoDouble(Symbol(), SYMBOL_POINT); maxLotSize = availableBalance * 0.5 / (stopLoss * point); tradeLotSize = NormalizeDouble(lotSize, 2); }
working code
Discover new MetaTrader 5 opportunities with MQL5 community and services
- 2024.02.18
- www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
The proper handler is OnInit(). Change the OnStart() to OnInit().
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi
How can solve those errors:
First Error:
(('SymbolInfoDouble' - no one of the overloads can be applied to the function
could be one of 2 function(s)
built-in: double SymbolInfoDouble(const string,ENUM_SYMBOL_INFO_DOUBLE)
built-in: bool SymbolInfoDouble(const string,ENUM_SYMBOL_INFO_DOUBLE,double&) ))
Secon Error:
'commentCharArr' - invalid array accessimplicit conversion from 'number' to 'string'