Tester (EA) in Visual Mode breaks synchronisation between Candles and horizontal time scale on chart, when changing resolution (magnifier +/-). Screen shot attached. 0900h candle shows on scale at 0745h.
Hello, I got a problem when written and tested the following code that all of sudden all of my expert advisors execute buy and sell
order at the same time in every expert advisor despite the signal, I didnt have this problem until I coded following advisor.
Then I sent this code to my friend and he got same problem, could you give us some advice how to fix it? Thank you a lot.
// import trade.mqh#include<Trade\Trade.mqh>
// Create an instance of CTrade
CTrade trade;
inputint SmallMovingAverage=20;
inputint MiddleMovingAverage=50;
inputint BigMovingAverage=100;
inputint a1=100;//SL BUYinputint b1=100;//TP BUYinputint a2=100;//SL SELLinputint b2=100;//TP SELLvoidOnTick()
{
// Get the Ask pricedouble Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
// Get the Bid pricedouble Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
//create a string for the signalstring signal=" ";
//create an Array for several pricesdouble SmallMovingAverageArray[],MiddleMovingAverageArray[],BigMovingAverageArray[];
//define the properties of the Moving Averageint SmallMovingAverageDefinition = iMA (_Symbol,_Period,SmallMovingAverage,0,MODE_EMA,PRICE_CLOSE);
//define the properties of the Moving Averageint MiddleMovingAverageDefinition = iMA (_Symbol,_Period,MiddleMovingAverage,0,MODE_EMA,PRICE_CLOSE);
//define the properties of the Moving Averageint BigMovingAverageDefinition = iMA (_Symbol,_Period,BigMovingAverage,0,MODE_EMA,PRICE_CLOSE);
// Defined EA, one line, from candle 0,for 3 candles, store resultCopyBuffer(SmallMovingAverageDefinition,0,0,3,SmallMovingAverageArray);
// Defined EA, one line, from candle 0,for 3 candles, store resultCopyBuffer(MiddleMovingAverageDefinition,0,0,3,MiddleMovingAverageArray);
// Defined EA, one line, from candle 0,for 3 candles, store resultCopyBuffer(BigMovingAverageDefinition,0,0,3,BigMovingAverageArray);
//and was below the SMA beforeif (SmallMovingAverageArray[1] < MiddleMovingAverageArray[1]&& MiddleMovingAverageArray[1]<BigMovingAverageArray[1])
{
signal="buy";
}
//and was below the SMA beforeif (SmallMovingAverageArray[1] > MiddleMovingAverageArray[1]&& MiddleMovingAverageArray[1]>BigMovingAverageArray[1])
{
signal="sell";
}
//buyif (signal =="buy" && PositionsTotal()<1)
trade.Buy(1.00,NULL,Ask,Ask-a1*_Point,Ask+b1*_Point,NULL);
//sellif (signal =="sell" && PositionsTotal()<1)
trade.Sell(1.00,NULL,Bid,Bid+a2*_Point,Bid-b2*_Point,NULL);
//chart outputComment ("The signal is now: ",signal);
}
Hello, I got a problem when written and tested the following code that all of sudden all of my expert advisors execute buy and sell
order at the same time in every expert advisor despite the signal, I didnt have this problem until I coded following
advisor. Then I sent this code to my friend and he got same problem, could you give us some advice how to fix it? Thank you a lot.
Categorically it is NOT possible to receive an indicator handle AT EVERY TICK! An indicator handle must be created ONCE in OnInit ().
Now, now I have corrected your code. The EA checks the signal ONLY AT THE TIME OF THE NEW BAR BIRTH (it makes no sense to work inside the bar on every tick).
Bug reported and confirmed by ServiceDesk :
Is OnChartEvent() actually called during a "Stratagy Tester - Visual Testing" mode session?
Win 10 latest build, MT5 V5 build 1966, UHD 4K screen
Tester (EA) in Visual Mode breaks synchronisation between Candles and horizontal time scale on chart, when changing resolution (magnifier +/-). Screen shot attached. 0900h candle shows on scale at 0745h.
Reported in parallel to Service Desk, now.
Hello, I got a problem when written and tested the following code that all of sudden all of my expert advisors execute buy and sell order at the same time in every expert advisor despite the signal, I didnt have this problem until I coded following advisor. Then I sent this code to my friend and he got same problem, could you give us some advice how to fix it? Thank you a lot.
Hello, I got a problem when written and tested the following code that all of sudden all of my expert advisors execute buy and sell order at the same time in every expert advisor despite the signal, I didnt have this problem until I coded following advisor. Then I sent this code to my friend and he got same problem, could you give us some advice how to fix it? Thank you a lot.
Categorically it is NOT possible to receive an indicator handle AT EVERY TICK! An indicator handle must be created ONCE in OnInit ().
Example:
Creating an iMA indicator handle, getting indicator values
Now, now I have corrected your code. The EA checks the signal ONLY AT THE TIME OF THE NEW BAR BIRTH (it makes no sense to work inside the bar on every tick).