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
- www.mql5.com
- OnTick critical error
- ticks counter
- don't put order buy in Mql5 and give error (10030)
//+------------------------------------------------------------------+ //| 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"
Use the button to insert the code
You can also attach a file using the button
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); }
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 ().
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.
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use