Unsupported filling mode/Strategy Tester doesn't run...

 

Sorry to burden you guys, i've been trying to test a strategy for a while and i'm trying to test the code.

Sometimes it runs but when it tries to buy or sell it says "unsupported filling mode" other time it makes a strange noise and doesn't run at all....Maybe cos i'm running on a Mac? I'm with XM(who do you suggest btw-this is the only one i could find with cryptos(which i was able to find))!

Here's my code:-  

#include <Trade\Trade.mqh>
CTrade trade;

void OnTick()
  {

   double prices_b = SymbolInfoDouble(_Symbol, SYMBOL_BID);

   double prices_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 

   Sleep(1000);
   double previous1tk_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 
   double previous1tk_b = SymbolInfoDouble(_Symbol, SYMBOL_BID); 
   //Sleep(1000);
   //float previous2tk_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 
   //float previous2tk_b = SymbolInfoDouble(_Symbol, SYMBOL_BID); 
   
   

   if(SymbolInfoDouble(_Symbol, SYMBOL_ASK)>previous1tk_a){
      int FillingMode=(int)SymbolInfoInteger(_Symbol,SYMBOL_FILLING_MODE);
      trade.Buy(0.01,NULL,SymbolInfoDouble(_Symbol, SYMBOL_ASK),0,(SymbolInfoDouble(_Symbol, SYMBOL_ASK)+100*_Point),NULL);
   }
   
   if(SymbolInfoDouble(_Symbol, SYMBOL_BID)> previous1tk_b){
      int FillingMode=(int)SymbolInfoInteger(_Symbol,SYMBOL_FILLING_MODE);
      trade.Sell(0.01,NULL,SymbolInfoDouble(_Symbol, SYMBOL_BID),0,(SymbolInfoDouble(_Symbol, SYMBOL_BID)+100*_Point),NULL);
   }  
  }

This is my first post, sorry if i dont follow all the formalitiesss.
 
xoxrumblelorexox:
...

This is my first post, sorry if i dont follow all the formalitiesss.

Good, now you can try your first research.

 
Alain Verleyen:

Good, now you can try your first research.

I'm still researching still no luck with my error...

For a simple CTrade this error shouldn't come up..

So i'm stumped.

I've tried making a copy the trade file and modifying it so that it has 'ORDER_FILLING_IOC' instead but it didnt seem to work.(thats what seemed to have worked for XM previously-from other posts)

If you can help i'll be glad thanks 

 

CTrade is problematic with Crypto.

Have you tried using conventional way's ?

Example of the TRADE_ACTION_DEAL trade operation for opening a Buy position:

#define EXPERT_MAGIC 123456   // MagicNumber of the expert
//+------------------------------------------------------------------+
//| Opening Buy position                                             |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- declare and initialize the trade request and result of trade request
   MqlTradeRequest request={0};
   MqlTradeResult  result={0};
//--- parameters of request
   request.action   =TRADE_ACTION_DEAL;                     // type of trade operation
   request.symbol   =Symbol();                              // symbol
   request.volume   =0.1;                                   // volume of 0.1 lot
   request.type     =ORDER_TYPE_BUY;                        // order type
   request.price    =SymbolInfoDouble(Symbol(),SYMBOL_ASK); // price for opening
   request.deviation=5;                                     // allowed deviation from the price
   request.magic    =EXPERT_MAGIC;                          // MagicNumber of the order
//--- send the request
   if(!OrderSend(request,result))
      PrintFormat("OrderSend error %d",GetLastError());     // if unable to send the request, output the error code
//--- information about the operation
   PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);
  }
//+------------------------------------------------------------------+

 
Example of the TRADE_ACTION_DEAL trade operation for opening a Sell position:

#define EXPERT_MAGIC 123456   // MagicNumber of the expert
//+------------------------------------------------------------------+
//| Opening Sell position                                            |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- declare and initialize the trade request and result of trade request
   MqlTradeRequest request={0};
   MqlTradeResult  result={0};
//--- parameters of request
   request.action   =TRADE_ACTION_DEAL;                     // type of trade operation
   request.symbol   =Symbol();                              // symbol
   request.volume   =0.2;                                   // volume of 0.2 lot
   request.type     =ORDER_TYPE_SELL;                       // order type
   request.price    =SymbolInfoDouble(Symbol(),SYMBOL_BID); // price for opening
   request.deviation=5;                                     // allowed deviation from the price
   request.magic    =EXPERT_MAGIC;                          // MagicNumber of the order
//--- send the request
   if(!OrderSend(request,result))
      PrintFormat("OrderSend error %d",GetLastError());     // if unable to send the request, output the error code
//--- information about the operation
   PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);
  }
//+------------------------------------------------------------------+

 
xoxrumblelorexox:

I'm still researching still no luck with my error...

For a simple CTrade this error shouldn't come up..

So i'm stumped.

I've tried making a copy the trade file and modifying it so that it has 'ORDER_FILLING_IOC' instead but it didnt seem to work.(thats what seemed to have worked for XM previously-from other posts)

If you can help i'll be glad thanks 

ÿþES  0     10:04:53.167       Terminal       update C:\Program Files\XM UK MT5\MQL5 folder started

HH   2     10:04:53.470       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\Lognormal.mqh update failed [3]

GD   2     10:04:53.472       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\Math.mqh update failed [3]

ER   2     10:04:53.472       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\NegativeBinomial.mqh update failed [3]

JM   2     10:04:53.473       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\NoncentralBeta.mqh update failed [3]

NQ   2     10:04:53.474       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\NoncentralChiSquare.mqh update failed [3]

QP   2     10:04:53.474       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\NoncentralF.mqh update failed [3]

PG   2     10:04:53.475       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\NoncentralT.mqh update failed [3]

II   2     10:04:53.475       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\Normal.mqh update failed [3]

RH   2     10:04:53.476       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\Poisson.mqh update failed [3]

ED   2     10:04:53.476       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\Stat.mqh update failed [3]

EO   2     10:04:53.476       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\T.mqh update failed [3]

JQ   2     10:04:53.477       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\Uniform.mqh update failed [3]

JD   2     10:04:53.477       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Math\Stat\Weibull.mqh update failed [3]

MJ   2     10:04:53.478       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\MovingAverages.mqh update failed [3]

LF   2     10:04:53.478       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Object.mqh update failed [3]

JL   2     10:04:53.479       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\OpenCL\OpenCL.mqh update failed [3]

MP   2     10:04:53.479       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\StdLibErr.mqh update failed [3]

MJ   2     10:04:53.480       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Strings\String.mqh update failed [3]

DJ   2     10:04:53.480       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Tools\DateTime.mqh update failed [3]

PJ   2     10:04:53.481       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Trade\AccountInfo.mqh update failed [3]

KQ   2     10:04:53.481       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Trade\DealInfo.mqh update failed [3]

MP   2     10:04:53.481       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Trade\HistoryOrderInfo.mqh update failed [3]

PR   2     10:04:53.482       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Trade\OrderInfo.mqh update failed [3]

IO   2     10:04:53.482       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Trade\PositionInfo.mqh update failed [3]

FK   2     10:04:53.482       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Trade\SymbolInfo.mqh update failed [3]

ME   2     10:04:53.483       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Trade\TerminalInfo.mqh update failed [3]

OJ   2     10:04:53.483       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\Trade\Trade.mqh update failed [3]

QL   2     10:04:53.484       Terminal       C:\Program Files\XM UK MT5\MQL5\Include\VirtualKeys.mqh update failed [3]

OM   2     10:04:53.484       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Accelerator.mq5 update failed [3]

NR   2     10:04:53.485       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\AD.mq5 update failed [3]

PJ   2     10:04:53.485       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ADX.mq5 update failed [3]

QH   2     10:04:53.485       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ADXW.mq5 update failed [3]

QF   2     10:04:53.486       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Alligator.mq5 update failed [3]

GP   2     10:04:53.486       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\AMA.mq5 update failed [3]

JL   2     10:04:53.487       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ASI.mq5 update failed [3]

JN   2     10:04:53.487       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ATR.mq5 update failed [3]

EE   2     10:04:53.487       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Awesome_Oscillator.mq5 update failed [3]

HG   2     10:04:53.488       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\BB.mq5 update failed [3]

CD   2     10:04:53.488       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Bears.mq5 update failed [3]

NQ   2     10:04:53.488       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Bulls.mq5 update failed [3]

IS   2     10:04:53.489       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\BW-ZoneTrade.mq5 update failed [3]

JN   2     10:04:53.489       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Canvas\FlameChart.mq5 update failed [3]

HL   2     10:04:53.489       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\CCI.mq5 update failed [3]

GI   2     10:04:53.490       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\CHO.mq5 update failed [3]

DJ   2     10:04:53.490       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\CHV.mq5 update failed [3]

JG   2     10:04:53.490       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ColorBars.mq5 update failed [3]

QG   2     10:04:53.490       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ColorCandlesDaily.mq5 update failed [3]

MR   2     10:04:53.491       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ColorLine.mq5 update failed [3]

PS   2     10:04:53.491       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Custom Moving Average.mq5 update failed [3]

ON   2     10:04:53.491       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\DEMA.mq5 update failed [3]

RP   2     10:04:53.492       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\DeMarker.mq5 update failed [3]

HO   2     10:04:53.492       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\DPO.mq5 update failed [3]

JJ   2     10:04:53.492       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Envelopes.mq5 update failed [3]

ID   2     10:04:53.492       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Force_Index.mq5 update failed [3]

NH   2     10:04:53.493       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Fractals.mq5 update failed [3]

CR   2     10:04:53.493       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\FrAMA.mq5 update failed [3]

QR   2     10:04:53.493       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Gator.mq5 update failed [3]

OR   2     10:04:53.494       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Gator_2.mq5 update failed [3]

EN   2     10:04:53.494       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Heiken_Ashi.mq5 update failed [3]

KG   2     10:04:53.495       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Ichimoku.mq5 update failed [3]

HF   2     10:04:53.496       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\MACD.mq5 update failed [3]

NF   2     10:04:53.496       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\MarketFacilitationIndex.mq5 update failed [3]

RG   2     10:04:53.497       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\MFI.mq5 update failed [3]

HL   2     10:04:53.497       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\MI.mq5 update failed [3]

RS   2     10:04:53.497       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Momentum.mq5 update failed [3]

HN   2     10:04:53.498       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\OBV.mq5 update failed [3]

MG   2     10:04:53.498       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\OsMA.mq5 update failed [3]

GD   2     10:04:53.499       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Panels\ChartPanel\ChartPanel.mq5 update failed [3]

FG   2     10:04:53.499       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Panels\ChartPanel\PanelDialog.mqh update failed [3]

KH   2     10:04:53.500       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Panels\SimplePanel\PanelDialog.mqh update failed [3]

PE   2     10:04:53.500       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Panels\SimplePanel\SimplePanel.mq5 update failed [3]

ND   2     10:04:53.500       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ParabolicSAR.mq5 update failed [3]

LK   2     10:04:53.500       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Price_Channel.mq5 update failed [3]

FD   2     10:04:53.501       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\PVT.mq5 update failed [3]

FG   2     10:04:53.501       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ROC.mq5 update failed [3]

DS   2     10:04:53.501       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\RSI.mq5 update failed [3]

NM   2     10:04:53.502       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\RVI.mq5 update failed [3]

IS   2     10:04:53.502       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\StdDev.mq5 update failed [3]

JE   2     10:04:53.502       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Stochastic.mq5 update failed [3]

NG   2     10:04:53.502       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\TEMA.mq5 update failed [3]

IJ   2     10:04:53.503       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\TRIX.mq5 update failed [3]

FQ   2     10:04:53.503       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Ultimate_Oscillator.mq5 update failed [3]

GP   2     10:04:53.503       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\VIDYA.mq5 update failed [3]

FL   2     10:04:53.504       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\Volumes.mq5 update failed [3]

OS   2     10:04:53.504       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\VROC.mq5 update failed [3]

RI   2     10:04:53.504       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\WPR.mq5 update failed [3]

EI   2     10:04:53.505       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\W_AD.mq5 update failed [3]

PK   2     10:04:53.505       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ZigZag.mq5 update failed [3]

MS   2     10:04:53.505       Terminal       C:\Program Files\XM UK MT5\MQL5\Indicators\Examples\ZigzagColor.mq5 update failed [3]

HN   2     10:04:53.507       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\AccountInfo\AccountInfoSample.mq5 update failed [3]

GP   2     10:04:53.507       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\AccountInfo\AccountInfoSampleInit.mqh update failed [3]

IN   2     10:04:53.508       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\ArrayDouble\ArrayDoubleSample.mq5 update failed [3]

KM   2     10:04:53.508       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\Canvas\CanvasSample.mq5 update failed [3]

CR   2     10:04:53.509       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\Canvas\Charts\HistogramChartSample.mq5 update failed [3]

ML   2     10:04:53.509       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\Canvas\Charts\LineChartSample.mq5 update failed [3]

QS   2     10:04:53.509       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\Canvas\Charts\PieChartSample.mq5 update failed [3]

RS   2     10:04:53.510       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\ObjectChart\ChartSampleInit.mqh update failed [3]

LQ   2     10:04:53.510       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\ObjectChart\ObjChartSample.mq5 update failed [3]

KR   2     10:04:53.511       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\ObjectSphere\Sphere.mqh update failed [3]

DL   2     10:04:53.511       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\ObjectSphere\SphereSample.mq5 update failed [3]

JQ   2     10:04:53.512       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Double\BitonicSort.mq5 update failed [3]

MR   2     10:04:53.513       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Double\FFT.mq5 update failed [3]

KS   2     10:04:53.513       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Double\Kernels\bitonicsort.cl update failed [3]

MR   2     10:04:53.513       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Double\Kernels\fft.cl update failed [3]

ML   2     10:04:53.514       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Double\Kernels\matrixmult.cl update failed [3]

FR   2     10:04:53.514       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Double\Kernels\wavelet.cl update failed [3]

EO   2     10:04:53.514       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Double\MatrixMult.mq5 update failed [3]

KS   2     10:04:53.515       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Double\Wavelet.mq5 update failed [3]

LM   2     10:04:53.515       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Float\BitonicSort.mq5 update failed [3]

NO   2     10:04:53.515       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Float\FFT.mq5 update failed [3]

KH   2     10:04:53.516       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Float\Kernels\bitonicsort.cl update failed [3]

KI   2     10:04:53.516       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Float\Kernels\fft.cl update failed [3]

DF   2     10:04:53.516       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Float\Kernels\matrixmult.cl update failed [3]

RI   2     10:04:53.517       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Float\Kernels\wavelet.cl update failed [3]

OD   2     10:04:53.517       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Float\MatrixMult.mq5 update failed [3]

LI   2     10:04:53.517       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OpenCL\Float\Wavelet.mq5 update failed [3]

RF   2     10:04:53.518       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OrderInfo\OrderInfoSample.mq5 update failed [3]

QH   2     10:04:53.518       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\OrderInfo\OrderInfoSampleInit.mqh update failed [3]

MF   2     10:04:53.519       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\PositionInfo\PositionInfoSample.mq5 update failed [3]

JH   2     10:04:53.519       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\PositionInfo\PositionInfoSampleInit.mqh update failed [3]

QE   2     10:04:53.519       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\SymbolInfo\SymbolInfoSample.mq5 update failed [3]

DK   2     10:04:53.520       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\Examples\SymbolInfo\SymbolInfoSampleInit.mqh update failed [3]

HF   2     10:04:53.520       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Alglib\TestClasses.mq5 update failed [3]

RH   2     10:04:53.525       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Alglib\TestClasses.mqh update failed [3]

EJ   2     10:04:53.525       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Alglib\TestInterfaces.mq5 update failed [3]

DH   2     10:04:53.527       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Alglib\TestInterfaces.mqh update failed [3]

FE   2     10:04:53.527       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Fuzzy\TestFuzzy.mq5 update failed [3]

QD   2     10:04:53.528       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Generic\TestArrayList.mq5 update failed [3]

JD   2     10:04:53.528       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Generic\TestHashMap.mq5 update failed [3]

KR   2     10:04:53.529       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Generic\TestHashSet.mq5 update failed [3]

NL   2     10:04:53.529       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Generic\TestLinkedList.mq5 update failed [3]

FQ   2     10:04:53.529       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Generic\TestQueue.mq5 update failed [3]

GM   2     10:04:53.530       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Generic\TestRedBlackTree.mq5 update failed [3]

NP   2     10:04:53.530       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Generic\TestSortedMap.mq5 update failed [3]

LN   2     10:04:53.530       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Generic\TestSortedSet.mq5 update failed [3]

ML   2     10:04:53.530       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Generic\TestStack.mq5 update failed [3]

FN   2     10:04:53.532       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Stat\TestStat.mq5 update failed [3]

CE   2     10:04:53.532       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Stat\TestStatBenchmark.mq5 update failed [3]

NE   2     10:04:53.532       Terminal       C:\Program Files\XM UK MT5\MQL5\Scripts\UnitTests\Stat\TestStatPrecision.mq5 update failed [3]

PJ   0     10:04:53.532       Terminal       update C:\Program Files\XM UK MT5\MQL5 folder finished

RI   0     10:04:53.743       Terminal       MetaTrader 5 build 1816 started (MetaQuotes Software Corp.)

JP   0     10:04:53.743       Terminal       Windows 7 Service Pack 1 (build 7601) on Wine 1.8.3, IE 9, Intel Pentium 4  2.40GHz, Memory: 11556 / 16384 Mb, Disk: 0 / 0 Gb, GMT+2

PD   0     10:04:53.743       Terminal       C:\Program Files\XM UK MT5

EE   3     10:04:53.744       Compiler       Please update your MetaEditor to the latest version

CH   3     10:04:53.745       Spreads file creation error [Path not found. (3)]

OS   3     10:04:53.745       Spreads config file open error [C:\Program Files\XM UK MT5\bases\Default\symbols\spreads-0.dat][Path not found. (3)]

PP   3     10:04:53.745       Spreads config file open error [Path not found. (3)]

MJ   3     10:04:53.745       Spreads file creation error [Path not found. (3)]

EN   3     10:04:53.745       Spreads config file open error [C:\Program Files\XM UK MT5\bases\Default\symbols\spreads-0.dat][Path not found. (3)]

FO   3     10:04:53.745       Spreads config file open error [Path not found. (3)]

NE   3     10:04:53.802       Terminal       You are using 32-bit version of the program, please switch to 64-bit for best performance

MD   3     10:04:56.768       Spreads file creation error [Path not found. (3)]

IL   3     10:04:56.768       Spreads config file open error [C:\Program Files\XM UK MT5\bases\Default\symbols\spreads-10605165.dat][Path not found. (3)]

HM   3     10:04:56.768       Spreads config file open error [Path not found. (3)]

EQ   3     10:04:56.768       Spreads file creation error [Path not found. (3)]

QH   3     10:04:56.768       Spreads config file open error [C:\Program Files\XM UK MT5\bases\Default\symbols\spreads-10605165.dat][Path not found. (3)]

PI   3     10:04:56.768       Spreads config file open error [Path not found. (3)]

EN   0     10:04:56.769       Network demo account '10605165' was allocated on MetaQuotes-Demo

JH   0     10:04:56.909       LiveUpdate   new version build 1816 (IDE: 1816, Tester: 1816) is available

HK   3     10:04:56.987       Spreads file creation error [Path not found. (3)]

KN   3     10:04:56.987       Spreads config file open error [C:\Program Files\XM UK MT5\bases\MetaQuotes-Demo\symbols\spreads-10605165.dat][Path not found. (3)]

MO   3     10:04:56.987       Spreads config file open error [Path not found. (3)]

PG   3     10:04:56.987       Spreads file creation error [Path not found. (3)]

CS   3     10:04:56.987       Spreads config file open error [C:\Program Files\XM UK MT5\bases\MetaQuotes-Demo\symbols\spreads-10605165.dat][Path not found. (3)]

EH   3     10:04:56.987       Spreads config file open error [Path not found. (3)]

LO   2     10:04:56.988       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

IK   0     10:04:57.026       Network '10605165': authorized on MetaQuotes-Demo

ME   0     10:04:57.026       Network '10605165': previous successful authorization performed from 213.7.196.42 on 2018.05.24 10:04:56

CM   2     10:04:57.283       LiveUpdate   failed to save 'mt5clwide.1816' [3]

CN   2     10:04:57.283       LiveUpdate   failed to read update container

QP   3     10:04:57.442       Symbols base file write error

MI   2     10:04:57.445       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

MF   0     10:04:57.445       Network '10605165': terminal synchronized with MetaQuotes Software Corp.

DP   0     10:04:57.445       Network '10605165': trading has been enabled - hedging mode

GJ   3     10:04:57.446       SelectedSymbols base file writing error

ER   0     10:04:57.782       Network '10605165': scanning network for access points

GL   2     10:04:57.782       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

EG   2     10:04:58.138       LiveUpdate   failed to save 'mt5clwide.1816' [3]

MS   2     10:04:58.138       LiveUpdate   failed to read update container

QI   2     10:05:00.178       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

EF   3     10:05:02.554       TradeDeals   initialization of month base by time failed

RR   3     10:05:02.554       TradeAccount       deals synchronization failed

KD   1     10:05:02.555       Network '10605165': connection to MetaQuotes-Demo lost

NM   0     10:05:02.930       LiveUpdate   new version build 1816 (IDE: 1816, Tester: 1816) is available

EK   2     10:05:03.005       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

PI   0     10:05:03.043       Network '10605165': authorized on MetaQuotes-Demo through Access Point EU 1

FR   0     10:05:03.043       Network '10605165': previous successful authorization performed from 213.7.196.42 on 2018.05.24 10:04:56

CM   2     10:05:03.131       LiveUpdate   failed to save 'mt5clwide.1816' [3]

CI   2     10:05:03.131       LiveUpdate   failed to read update container

MS   2     10:05:03.159       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

MP   0     10:05:03.159       Network '10605165': terminal synchronized with MetaQuotes Software Corp.

DI   0     10:05:03.159       Network '10605165': trading has been enabled - hedging mode

PD   3     10:05:03.160       SelectedSymbols base file writing error

IO   3     10:05:03.247       TradeDeals   initialization of month base by time failed

NK   3     10:05:03.247       TradeAccount       deals synchronization failed

FO   1     10:05:03.249       Network '10605165': connection to MetaQuotes-Demo lost

FD   0     10:05:03.461       LiveUpdate   new version build 1816 (IDE: 1816, Tester: 1816) is available

LR   2     10:05:03.538       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

PN   0     10:05:03.575       Network '10605165': authorized on MetaQuotes-Demo through Access Point EU 1

FK   0     10:05:03.575       Network '10605165': previous successful authorization performed from 213.7.196.42 on 2018.05.24 10:05:02

DJ   2     10:05:03.723       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

DG   0     10:05:03.723       Network '10605165': terminal synchronized with MetaQuotes Software Corp.

MP   0     10:05:03.723       Network '10605165': trading has been enabled - hedging mode

OM   3     10:05:03.723       SelectedSymbols base file writing error

NP   3     10:05:03.792       TradeDeals   initialization of month base by time failed

IP   3     10:05:03.792       TradeAccount       deals synchronization failed

DF   1     10:05:03.793       Network '10605165': connection to MetaQuotes-Demo lost

OO   0     10:05:03.927       LiveUpdate   new version build 1816 (IDE: 1816, Tester: 1816) is available

DI   2     10:05:03.996       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

NG   0     10:05:04.035       Network '10605165': authorized on MetaQuotes-Demo through Access Point EU 1

GP   0     10:05:04.035       Network '10605165': previous successful authorization performed from 213.7.196.42 on 2018.05.24 10:05:03

EQ   2     10:05:04.112       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

EN   0     10:05:04.112       Network '10605165': terminal synchronized with MetaQuotes Software Corp.

LK   0     10:05:04.112       Network '10605165': trading has been enabled - hedging mode

RR   3     10:05:04.112       SelectedSymbols base file writing error

RI   3     10:05:04.179       TradeDeals   initialization of month base by time failed

EI   3     10:05:04.179       TradeAccount       deals synchronization failed

EI   1     10:05:04.180       Network '10605165': connection to MetaQuotes-Demo lost

CF   0     10:05:04.465       LiveUpdate   new version build 1816 (IDE: 1816, Tester: 1816) is available

CP   2     10:05:04.550       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

DL   0     10:05:04.590       Network '10605165': authorized on MetaQuotes-Demo through Access Point EU 1

QI   0     10:05:04.590       Network '10605165': previous successful authorization performed from 213.7.196.42 on 2018.05.24 10:05:03

RH   2     10:05:04.870       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

RE   0     10:05:04.870       Network '10605165': terminal synchronized with MetaQuotes Software Corp.

GR   0     10:05:04.870       Network '10605165': trading has been enabled - hedging mode

EK   3     10:05:04.870       SelectedSymbols base file writing error

ER   3     10:05:04.938       TradeDeals   initialization of month base by time failed

RF   3     10:05:04.938       TradeAccount       deals synchronization failed

LP   1     10:05:04.938       Network '10605165': connection to MetaQuotes-Demo lost

CI   0     10:05:05.457       LiveUpdate   new version build 1816 (IDE: 1816, Tester: 1816) is available

CG   2     10:05:05.526       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

JE   0     10:05:05.568       Network '10605165': authorized on MetaQuotes-Demo through Access Point EU 1

RN   0     10:05:05.568       Network '10605165': previous successful authorization performed from 213.7.196.42 on 2018.05.24 10:05:04

DO   2     10:05:05.660       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

DL   0     10:05:05.660       Network '10605165': terminal synchronized with MetaQuotes Software Corp.

ME   0     10:05:05.660       Network '10605165': trading has been enabled - hedging mode

OP   3     10:05:05.660       SelectedSymbols base file writing error

FK   3     10:05:05.736       TradeDeals   initialization of month base by time failed

QO   3     10:05:05.736       TradeAccount       deals synchronization failed

LK   1     10:05:05.737       Network '10605165': connection to MetaQuotes-Demo lost

FP   0     10:05:05.984       LiveUpdate   new version build 1816 (IDE: 1816, Tester: 1816) is available

JN   2     10:05:06.072       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

OE   3     10:05:06.106       BookBars       base file write error

CP   3     10:05:06.107       OptionsBars base file write error

GJ   3     10:05:06.109       Favourites   base file write error

KO   0     10:05:06.111       Network '10605165': authorized on MetaQuotes-Demo through Access Point EU 1

PK   0     10:05:06.111       Network '10605165': previous successful authorization performed from 213.7.196.42 on 2018.05.24 10:05:05

GI   2     10:05:06.185       Accounts       open file error, path C:\Program Files\XM UK MT5\config\accounts.dat (3)

KF   0     10:05:06.185       Network '10605165': terminal synchronized with MetaQuotes Software Corp.

FS   0     10:05:06.185       Network '10605165': trading has been enabled - hedging mode

LJ   3     10:05:06.185       SelectedSymbols base file writing error

RN   3     10:05:06.197       Favourites   base file write error

KD   3     10:05:06.198       Favourites   base file write error

JM   3     10:05:06.205       Favourites   base file write error

IE   0     10:05:06.219       Terminal       exit initiated

KP   3     10:05:06.222       Agents   base file write error

NQ   2     10:05:06.222       MQL5.community   failed to start thread

OH   0     10:05:06.222       Network '10605165': disconnected from MetaQuotes-Demo

QQ   2     10:05:06.223       MQL5.community   failed to start thread

OJ   2     10:05:06.223       MQL5.community   failed to start thread

NQ   3     10:05:06.309       SelectedSymbols base file writing error

RD   2     10:05:06.521       MQL5.community   authorization failed

IO   0     10:05:06.525       Terminal       stopped


 
Marco vd Heijden:

CTrade is problematic with Crypto.

Have you tried using conventional way's ?

I have sir, and i am so close to making a functioning EA... I will post code below. So do you suggest using the traditional methods to initialize trades for crypto?


Thanks for getting back so soon all!


Hopefully i can solve this problem.


The problem i get with the trad. way is that it says this ---

"'return' - 'void' function returns a value"

---- solved the error now!!!!

Sorry! Thanks!

I've searched up multiples posts regarding this and to no avail


Thanks beforehand!!!!



//+------------------------------------------------------------------+
//|                                               BuyLowSellHigh.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+

//Input


//Array
double prices_bid[1000];
double prices_ask[1000];
double prices[];
//
int OnInit()
  {
//---
   Print("Hello World!");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
   Comment("");
   
  }



 

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---


   double prices_b = SymbolInfoDouble(_Symbol, SYMBOL_BID);

   double prices_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 

   Sleep(1000);
   double previous1tk_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 
   double previous1tk_b = SymbolInfoDouble(_Symbol, SYMBOL_BID); 
   Sleep(1000);
   double previous2tk_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 
   double previous2tk_b = SymbolInfoDouble(_Symbol, SYMBOL_BID); 
   
   
   //--- Define some MQL5 Structures we will use for our trade
   MqlTick latest_price;     // To be used for getting recent/latest price quotes
   MqlTradeRequest mrequest;  // To be used for sending our trade requests
   MqlTradeResult mresult;    // To be used to get our trade results
   ZeroMemory(mrequest);     // Initialization of mrequest structure
   ZeroMemory (mresult);
   
   if(SymbolInfoDouble(_Symbol, SYMBOL_ASK)>previous1tk_a){


   

         mrequest.action = TRADE_ACTION_DEAL;                                // immediate order execution
         //mrequest.price = NormalizeDouble(latest_price.ask,_Digits);          // latest ask price
         mrequest.sl = 0; // Stop Loss
         mrequest.tp = 0; // Take Profit
         mrequest.symbol = _Symbol;                                         // currency pair
         mrequest.volume = 0.1;                                            // number of lots to trade
         mrequest.magic = 12345;                                        // Order Magic Number
         mrequest.type = ORDER_TYPE_BUY;                                     // Buy Order
         mrequest.type_filling = ORDER_FILLING_IOC;                         // Order execution type
         mrequest.deviation=10;                                            // Deviation from current price
         //--- send order
         return(OrderSend(mrequest,mresult));
         
   
   
     
   
   }
   
   
   if(SymbolInfoDouble(_Symbol, SYMBOL_BID)> previous1tk_b){
   
   
   
   
   
            mrequest.action = TRADE_ACTION_DEAL;                                 // immediate order execution
            //mrequest.price = NormalizeDouble(latest_price.bid,_Digits);          // latest Bid price
            mrequest.sl = 0; // Stop Loss
            mrequest.tp = 0; // Take Profit
            mrequest.symbol = _Symbol;                                         // currency pair
            mrequest.volume = 0.1;                                            // number of lots to trade
            mrequest.magic = 12345;                                        // Order Magic Number
            mrequest.type= ORDER_TYPE_SELL;                                     // Sell Order
            mrequest.type_filling = ORDER_FILLING_IOC;                          // Order execution type
            mrequest.deviation=10;                                           // Deviation from current price
            //--- send order
            return(OrderSend(mrequest,mresult));
   
     
   }
   
   
   //Print("2TAA=",previous2tk_a," ","2TAB="," ",previous2tk_b," ","1TA=",previous1tk_a," ","1TB=",previous1tk_b," ","a=",prices_a," ","b=",prices_b);

   Comment("Functioning");
  }
//+------------------------------------------------------------------+
// Info of the last tick.
//-----------------------
   

 

It's because the two times you want to ordersend it returns the outcome while the ontick() is a void function.

so you could get rid of that:

//+------------------------------------------------------------------+
//|                                               BuyLowSellHigh.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+

//Input


//Array
double prices_bid[1000];
double prices_ask[1000];
double prices[];
//
int OnInit()
  {
//---
   Print("Hello World!");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
   Comment("");
   
  }



 

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---


   double prices_b = SymbolInfoDouble(_Symbol, SYMBOL_BID);

   double prices_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 

   Sleep(1000);
   double previous1tk_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 
   double previous1tk_b = SymbolInfoDouble(_Symbol, SYMBOL_BID); 
   Sleep(1000);
   double previous2tk_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 
   double previous2tk_b = SymbolInfoDouble(_Symbol, SYMBOL_BID); 
   
   
   //--- Define some MQL5 Structures we will use for our trade
   MqlTick latest_price;     // To be used for getting recent/latest price quotes
   MqlTradeRequest mrequest;  // To be used for sending our trade requests
   MqlTradeResult mresult;    // To be used to get our trade results
   ZeroMemory(mrequest);     // Initialization of mrequest structure
   ZeroMemory (mresult);
   
   if(SymbolInfoDouble(_Symbol, SYMBOL_ASK)>previous1tk_a){


   

         mrequest.action = TRADE_ACTION_DEAL;                                // immediate order execution
         //mrequest.price = NormalizeDouble(latest_price.ask,_Digits);          // latest ask price
         mrequest.sl = 0; // Stop Loss
         mrequest.tp = 0; // Take Profit
         mrequest.symbol = _Symbol;                                         // currency pair
         mrequest.volume = 0.1;                                            // number of lots to trade
         mrequest.magic = 12345;                                        // Order Magic Number
         mrequest.type = ORDER_TYPE_BUY;                                     // Buy Order
         mrequest.type_filling = ORDER_FILLING_IOC;                         // Order execution type
         mrequest.deviation=10;                                            // Deviation from current price
         //--- send order
          
         OrderSend(mrequest,mresult);
         
   
   
     
   
   }
   
   
   if(SymbolInfoDouble(_Symbol, SYMBOL_BID)> previous1tk_b){
   
   
   
   
   
            mrequest.action = TRADE_ACTION_DEAL;                                 // immediate order execution
            //mrequest.price = NormalizeDouble(latest_price.bid,_Digits);          // latest Bid price
            mrequest.sl = 0; // Stop Loss
            mrequest.tp = 0; // Take Profit
            mrequest.symbol = _Symbol;                                         // currency pair
            mrequest.volume = 0.1;                                            // number of lots to trade
            mrequest.magic = 12345;                                        // Order Magic Number
            mrequest.type= ORDER_TYPE_SELL;                                     // Sell Order
            mrequest.type_filling = ORDER_FILLING_IOC;                          // Order execution type
            mrequest.deviation=10;                                           // Deviation from current price
            //--- send order
            
            OrderSend(mrequest,mresult);
   
     
   }
   
   
   //Print("2TAA=",previous2tk_a," ","2TAB="," ",previous2tk_b," ","1TA=",previous1tk_a," ","1TB=",previous1tk_b," ","a=",prices_a," ","b=",prices_b);

   Comment("Functioning");
  }
//+------------------------------------------------------------------+
// Info of the last tick.
//-----------------------
 

But it's a lot easier if you create a few stand alone functions that you can just drop in whenever you need them like this:

//+------------------------------------------------------------------+
//|                                               BuyLowSellHigh.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

int EXPERT_MAGIC=374634;   // MagicNumber of the expert
                           //Input
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
//Array
//double prices_bid[1000];
//double prices_ask[1000];
//double prices[];
//
int OnInit()
  {
//---
   Print("Hello World!");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   Comment("");
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

   double prices_b=SymbolInfoDouble(_Symbol,SYMBOL_BID);
   double prices_a=SymbolInfoDouble(_Symbol,SYMBOL_ASK);

   Sleep(1000);
   double previous1tk_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double previous1tk_b = SymbolInfoDouble(_Symbol, SYMBOL_BID);
   Sleep(1000);
   double previous2tk_a = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double previous2tk_b = SymbolInfoDouble(_Symbol, SYMBOL_BID);

   if(SymbolInfoDouble(_Symbol,SYMBOL_ASK)>previous1tk_a)
     {
      Buy(_Symbol,0.1);
     }

   if(SymbolInfoDouble(_Symbol,SYMBOL_BID)>previous1tk_b)
     {
      Sell(_Symbol,0.1);
     }
   Comment("Functioning");
  }
//+------------------------------------------------------------------+
//| Opening Buy position                                             |
//+------------------------------------------------------------------+
void Buy(string symbol,double lots)
  {
//--- declare and initialize the trade request and result of trade request
   MqlTradeRequest request={0};
   MqlTradeResult  result={0};
//--- parameters of request
   request.action   =TRADE_ACTION_DEAL;                     // type of trade operation
   request.symbol   =Symbol();                              // symbol
   request.volume   =lots;                                  // volume
   request.type     =ORDER_TYPE_BUY;                        // order type
   request.price    =SymbolInfoDouble(Symbol(),SYMBOL_ASK); // price for opening
   request.deviation=5;                                     // allowed deviation from the price
   request.magic    =EXPERT_MAGIC;                          // MagicNumber of the order
//--- send the request
   if(!OrderSend(request,result))
      PrintFormat("OrderSend error %d",GetLastError());     // if unable to send the request, output the error code
//--- information about the operation
   PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);
  }
//+------------------------------------------------------------------+
//| Opening Sell position                                            |
//+------------------------------------------------------------------+
void Sell(string symbol,double lots)
  {
//--- declare and initialize the trade request and result of trade request
   MqlTradeRequest request={0};
   MqlTradeResult  result={0};
//--- parameters of request
   request.action   =TRADE_ACTION_DEAL;                     // type of trade operation
   request.symbol   =Symbol();                              // symbol
   request.volume   =lots;                                  // volume  
   request.type     =ORDER_TYPE_SELL;                       // order type
   request.price    =SymbolInfoDouble(Symbol(),SYMBOL_BID); // price for opening
   request.deviation=5;                                     // allowed deviation from the price
   request.magic    =EXPERT_MAGIC;                          // MagicNumber of the order
//--- send the request
   if(!OrderSend(request,result))
      PrintFormat("OrderSend error %d",GetLastError());     // if unable to send the request, output the error code
//--- information about the operation
   PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);
  }
//+------------------------------------------------------------------+

There are still some problems but it's a start.

 
Marco vd Heijden:

But it's a lot easier if you create a few stand alone functions that you can just drop in whenever you need them like this:

There are still some problems but it's a start.

Everything compiles alright but i noticed that every time i run the strategy tester it just makes a noise and doesnt do anything any idea why this might be? 


Thanks a lot btw!

 

It should print something to the log because:

   if(!OrderSend(request,result))
      PrintFormat("OrderSend error %d",GetLastError());     // if unable to send the request, output the error code

So you look for the error code and once you found that look it up here: 

https://www.mql5.com/en/docs/constants/errorswarnings/errorcodes

Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Runtime Errors
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Runtime Errors
  • www.mql5.com
The name of the custom symbol is invalid. The symbol name can only contain Latin letters without punctuation, spaces or special characters (may only contain ".", "_", "&" and "#"). It is not recommended to use characters , :, ", /,\, |, ?, *. The path of...
Reason: