Hi.. Please help me my EA can't open any trades when I run it in strategy tester. I'm using this EA for Boom and Crash

 
***

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2020, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#include<Trade\Trade.mqh>
CTrade trade;
void OnTick()
  {
   string signal = "";

   double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
   double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);

   double PriceArray[];

   ArraySetAsSeries(PriceArray,true);

   int MacDefinition = iMACD(_Symbol,_Period,12,25,9,PRICE_CLOSE);

   CopyBuffer(MacDefinition,0,0,3,PriceArray);

   double MACD_Value = (PriceArray[0]);
   double LastMACD_Value = (PriceArray[1]);

   if(MACD_Value > 0 && LastMACD_Value < 0)
      signal = "BUY";


   if(MACD_Value < 0 && LastMACD_Value > 0)
      signal = "SELL";


   if(signal == "BUY" && PositionsTotal() < 1)
      trade.Buy(0.2,NULL,Ask,0,(Ask+150 * _Point), NULL);



   if(signal == "SELL" && PositionsTotal() > 1)
      trade.Sell(0.2,NULL,Bid,0,(Bid-150  * _Point), NULL);

   Comment("The Current Signal is", signal);
  }
//+------------------------------------------------------------------+

you have to use "double" not "float"

 
Bobby_kabhuru1 :
***

Use the button to insert the code Code

You can also attach a file using the button Attach file

 
Khuman Bakhramirad:

you have to use "double" not "float"

Hi Khuman.. Thanks for the response. I have changed from float to double but still doesn't open any trades. It prints out the comment when the MACD crosses over it prints either SELL or BUY but does not open a trade..
 
Vladimir Karputov:

Use the button to insert the code

You can also attach a file using the button

Okay Thanks let me attach..

#include<Trade\Trade.mqh>
CTrade trade;
void OnTick()
  {
   string signal = "";
   
   double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
   double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
   
   double PriceArray[];
   
   ArraySetAsSeries(PriceArray,true);
   
   int MacDefinition = iMACD(_Symbol,_Period,12,25,9,PRICE_CLOSE);
   
   CopyBuffer(MacDefinition,0,0,3,PriceArray);
   
   double MACD_Value = (PriceArray[0]);
   double LastMACD_Value = (PriceArray[1]);
   
   if(MACD_Value > 0 && LastMACD_Value < 0)
   signal = "BUY";
   
   
   if(MACD_Value < 0 && LastMACD_Value > 0)
   signal = "SELL";
    
   
  if(signal == "BUY" && PositionsTotal() < 1)
   trade.Buy(0.2,NULL,Ask,0,(Ask+150 * _Point), NULL);
   
   
   
   if(signal == "SELL" && PositionsTotal() > 1)
   trade.Sell(0.2,NULL,Bid,0,(Bid-150  * _Point), NULL);
   
   Comment("The Current Signal is", signal);
  }

 
Bobby_kabhuru1 :

Okay Thanks let me attach..

You make one and the same mistake - you create an indicator handle ON EVERY TICK !!! This is mistake!!!

Transfer the creation of the indicator handle to OnInit ().

 
Vladimir Karputov:

You make one and the same mistake - you create an indicator handle ON EVERY TICK !!! This is mistake!!!

Transfer the creation of the indicator handle to OnInit ().

Hi Vladimir,

Which one is the indicator handle? Please help me,.. I'm a newbie..

Thanks in advance : )

 

Your homework is to study the iMACD Help.

Based on the help it is CORRECT to create an indicator handle.

Documentation on MQL5: Technical Indicators / iMACD
Documentation on MQL5: Technical Indicators / iMACD
  • www.mql5.com
iMACD - Technical Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Vladimir Karputov:

Your homework is to study the iMACD Help.

Based on the help it is CORRECT to create an indicator handle.

Okay. Thanks a lot.
Reason: