problem with m_trade

 

Hi guys

Can someone  tell me how to fix this problem??? Thank you!

'm_Trade' - undeclared identifier

#include <Trade\PositionInfo.mqh>

#include <Trade\Trade.mqh>

#include <Trade\SymbolInfo.mqh>  

#include <Trade\OrderInfo.mqh>

#include <Expert\Trailing\TrailingNone.mqh>

#include <Expert\Money\MoneyNone.mqh>

CPositionInfo  m_position;                   // trade position object

CTrade         m_trade;                      // trading object

CSymbolInfo    m_symbol;                     // symbol info object

COrderInfo     m_order;                      // pending orders object deletes all pending orders"



input double StopLoss=230;

input double TakeProfit=670;

input double TradeSizeOptimized=0.1;

input int slippage=10;







//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

int bar=0;



void OnTick()

  {

//---

if (bar==Bars) 

{

return;

}

bar= Bars;



if((iRSI(NULL,0,14,PRICE_CLOSE)<20)&&iRSI(NULL,PERIOD_H1,14,PRICE_CLOSE)<45)

    {    

    m_trade.OrderOpen(_Symbol,Signal,TradeSizeOptimized(),SymbolInfoDouble(_Symbol,Signal==ORDER_TYPE_SELL?SYMBOL_BID:SYMBOL_ASK),

    m_symbol.Bid()-StopLoss*Point,m_symbol.Ask()+TakeProfit*Point);

    m_trade.PositionClose (POSITION_TICKET,slippage);

    return;

    }

if((iRSI(NULL,0,14,PRICE_CLOSE)>80)&&iRSI(NULL,PERIOD_H1,14,PRICE_CLOSE)>55)

    {

        m_trade.PositionOpen(_Symbol,Signal,TradeSizeOptimized(),SymbolInfoDouble(_Symbol,Signal==ORDER_TYPE_SELL?SYMBOL_BID:SYMBOL_ASK),

    m_symbol.Ask()+StopLoss*Point,m_symbol.Bid()+TakeProfit*Point);

    m_trade.PositionClose (POSITION_TICKET,slippage);

        return;   

    }

    }
通过MQL5社区和服务探索MetaTrader 5的新机遇
通过MQL5社区和服务探索MetaTrader 5的新机遇
  • www.mql5.com
MQL5:MetaTrader 5客户端内置的交易策略语言。语言允许编写您自己的自动交易系统,技术指标,脚本和函数程序库
 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


 
All identifiers are case sensitive.
You declared the variable all lowercase "m_trade" and you tried to use it with an uppercase T "m_Trade".
For MQL:

// Are different variables.
m_trade
m_Trade
 

Alexandre Borela #:

All identifiers are case sensitive.
You declared the variable all lowercase "m_trade" and you tried to use it with an uppercase T "m_Trade".
For MQL:


I changed m_Trade to m_trade,but still can't fix this problem.How to use it with lowercase?

 
Aaron Hu # :


In general, what language do you write an advisor in: MQL5 ?

 
Vladimir Karputov #:

In general, what language do you write an advisor in: MQL5 ?

Yes,it's MQL5
 
Aaron Hu #:

I changed m_Trade to m_trade,but still can't fix this problem.How to use it with lowercase?

You have multiple places where you put the wrong name, double click at the error message and it will show you the line with the error.
 
Aaron Hu # :
Yes,it's MQL5

You are not working correctly with indicators.

See example: 

An example of get values from the iRSI indicator

How to start with MQL5
How to start with MQL5
  • 2020.07.05
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
 
Vladimir Karputov #:

You are not working correctly with indicators.

See example: 

An example of get values from the iRSI indicator

I don't know how to use it.can you modify my codes?
 
Aaron Hu # :
I don't know how to use it.can you modify my codes?

What exactly is not clear to you? You have a global misunderstanding of the MQL5 style: according to the MQL5 style, the indicator handle MUST be created ONCE and you MUST do it in OnInit. I gave you an example - learn an example, learn how to work correctly with indicators in MQL5.

Reason: