Minor Errors When Compiling. Cannot figure them out - page 3

 
whroeder1:
  1. You can't close them
  2. Don't open another that is double posting

Don't double post


Ah ok i see. I slightly changed my original question and took a bit of it out so that is why i thought it might be a good idea to do a new one?

Do you recommend I just post that question straight under here? I think maybe my original question was confused coming from my end.

Thanks

 

Sorry for the double posting, ill keep everything on this thread.

Essentially, I think the issue is that I am trying to use PriceDataTable in the MathAbs calculation and in order for the query to work, PriceDataTable must be defined as a double and not the MQLRates?? But then i need MQLRates to be able to query the price points in comparison to the MA line? 

Am i correct in my thinking? How can I make this work so that I can still query the PriceDataTable candles for entry?

- I have put in bold the areas for the PriceDataTable (MqlRates) areas and then the MathAbs area near the bottom

Thanking you all in advance!


//+------------------------------------------------------------------+
//|                        Mariah 1.2.mq5                            |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017"
#property link      ""
#property version   "1.00"


#include <Trade\Trade.mqh>


//----- My input variables ------------

input double   lot = 0.1;
input int      movingAveragePeriod = 20;
input bool     useStopLoss = true;
input double   stopLoss = 20;
input bool     useTakeProfit = true; 
input double   takeProfit = 40;
input bool useTrailingStop=true;
input double trailingStopPips=40;

CTrade tradingControlPanel;
MqlRates PriceDataTable[];   
double mAData[]; 
int controlPanel, pricePoints, numberOfmAData, numberOfPriceDataPoints, P;
double currentBid, currentAsk;
double stopLossPipsFinal, takeProfitPipsFinal, stopLevelPips;
double stopLossLevel, takeProfitLevel;
double newStopLossPips;
double newTrailingStopPrice;



//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
ArraySetAsSeries (mAData, true);
controlPanel = iMA(_Symbol, _Period, 20, 0, MODE_SMA, PRICE_CLOSE);

ArraySetAsSeries (PriceDataTable, true); 
   if(_Digits == 5 || _Digits == 3 || _Digits == 1) P = 10;else P = 1; // To account for 5 digit brokers
   
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  
currentBid = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Get latest Bid Price
currentAsk = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // Get latest Ask Price
   

numberOfmAData = CopyBuffer(controlPanel, 0, 0, 20, mAData); 
int maDataFill = CopyBuffer(controlPanel, 0, 0, 20, mAData);

numberOfPriceDataPoints = CopyRates(_Symbol,0,0,10,PriceDataTable);
pricePoints = CopyRates(_Symbol,0,0,10,PriceDataTable);             

stopLevelPips = (double) (SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL) + SymbolInfoInteger(_Symbol, SYMBOL_SPREAD)) / P; // Defining minimum StopLevel

   if (stopLoss < stopLevelPips) 
      {
      stopLossPipsFinal = stopLevelPips;
      } 
   else
      {
      stopLossPipsFinal = stopLoss;
      } 
      
   if (takeProfit < stopLevelPips) 
      {
      takeProfitPipsFinal = stopLevelPips;
      }
   else
      {
      takeProfitPipsFinal = takeProfit;
      }




// -------------------- EXITS --------------------
   
   if(PositionSelect(_Symbol) == true) // If We have an open position
      {
      
      if (false) // ..and this condition is met (System based stop, But using hard stop and target)
         {
               
      if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) // ..and If it is Buy position
            { 
               
            tradingControlPanel.PositionClose(_Symbol); // Closes position related to this symbol
            
            if(tradingControlPanel.ResultRetcode()==10008 || tradingControlPanel.ResultRetcode()==10009) //Request is completed or order placed
               {
               Print("Exit rules: A close order has been successfully placed with Ticket#: ",tradingControlPanel.ResultOrder());
               }
            else
               {
               Print("Exit rules: The close order request could not be completed.Error: ",GetLastError());
               ResetLastError();
               return;
               }
               
            }
            
            
       else if (false) // /else if this condition is met 
           {
          
            if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) // and If it is a Sell position
            { 
            
            tradingControlPanel.PositionClose(_Symbol); // Closes position related to this symbol (_Symbol = the current pair)
            
            if(tradingControlPanel.ResultRetcode()==10008 || tradingControlPanel.ResultRetcode()==10009) //Request is completed or order placed
               {
               Print("Exit rules: A close order has been successfully placed with Ticket#: ", tradingControlPanel.ResultOrder());
               }
            else
               {
               Print("Exit rules: The close order request could not be completed. Error: ", GetLastError());
               ResetLastError();
               return;
               }
            }
            }
         }   
}

// Trailing Stops Area ==========================================

if (useTrailingStop == true)
   {
      if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
      {
         newTrailingStopPrice = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID) - trailingStopPips*(_Point*P),_Digits);
         if(newTrailingStopPrice > PositionGetDouble(POSITION_PRICE_OPEN))
         {
         if(newTrailingStopPrice > PositionGetDouble (POSITION_SL))
         {
         tradingControlPanel.PositionModify (_Symbol, newTrailingStopPrice, PositionGetDouble(POSITION_TP));
         Print ("Trailing Stop has moved to: ", newTrailingStopPrice);
         }
         }
      }
      
      if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
      {
         newTrailingStopPrice = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK) + trailingStopPips*(_Point*P),_Digits);
         if(newTrailingStopPrice < PositionGetDouble(POSITION_PRICE_OPEN))
         {
         if(newTrailingStopPrice < PositionGetDouble (POSITION_SL) || PositionGetDouble(POSITION_SL) == 0)
         {
         tradingControlPanel.PositionModify (_Symbol, newTrailingStopPrice, PositionGetDouble(POSITION_TP));
         Print ("Trailing Stop has moved to: ", newTrailingStopPrice);
         }
         }
      }
   }
   
   // End of Trailing stops area =======================================================
   
   
   
// -------------------- ENTRIES --------------------  
         
   if(PositionSelect(_Symbol) == false) // We have no open position
      { 
      
      if(MathAbs(PriceDataTable[1] - mAData[1]) < 10 * P) 
            {
 
         // ..and these Buy Conditions are met
      if (PriceDataTable[1].high > mAData[1] && PriceDataTable[1].close > PriceDataTable[2].close)
       
        //Open a Buy Trade
        {
         
         if (useStopLoss) stopLossLevel = currentAsk - stopLossPipsFinal * _Point * P; else stopLossLevel = 0.0;
         if (useTakeProfit) takeProfitLevel = currentAsk + takeProfitPipsFinal * _Point * P; else takeProfitLevel = 0.0;
        
         
            
         tradingControlPanel.PositionOpen(_Symbol, ORDER_TYPE_BUY, lot, currentAsk, stopLossLevel, takeProfitLevel, "Buy Trade. Magic Number #" + (string) tradingControlPanel.RequestMagic()); // Open a Buy position
         
         if(tradingControlPanel.ResultRetcode()==10008 || tradingControlPanel.ResultRetcode()==10009) //Request is completed or order placed
            {
            Print("Entry rules: A Buy order has been successfully placed with Ticket#: ", tradingControlPanel.ResultOrder());
            }
         else
            {
            Print("Entry rules: The Buy order request could not be completed. Error: ", GetLastError());
            ResetLastError();
            return;
             }
            }
         }
        
         
         // If no Buy Conditions, also look for Sell Condtions..
         
       else if (PriceDataTable[1].close < PriceDataTable[2].close && 
      PriceDataTable[2].high > mAData[2])
       {
       
       
    
         if (useStopLoss) stopLossLevel = currentBid + stopLossPipsFinal * _Point * P; else stopLossLevel = 0.0;
         if (useTakeProfit) takeProfitLevel = currentBid - takeProfitPipsFinal * _Point * P; else takeProfitLevel = 0.0;

         tradingControlPanel.PositionOpen(_Symbol, ORDER_TYPE_SELL, lot, currentBid, stopLossLevel, takeProfitLevel, "Sell Trade. Magic Number #" + (string) tradingControlPanel.RequestMagic()); // Open a Sell position
         
         if(tradingControlPanel.ResultRetcode()==10008 || tradingControlPanel.ResultRetcode()==10009) //Request is completed or order placed
            {
            Print("Entry rules: A Sell order has been successfully placed with Ticket#: ", tradingControlPanel.ResultOrder());
            }
         else
            {
            Print("Entry rules: The Sell order request could not be completed.Error: ", GetLastError());
            ResetLastError();
            return;
            }
         
         }
         
         
   } 
}
 

Wondering if anyone had any ideas on this?

 
Anything? Because my queation was confused before if you already gave an answer, i didnt understand it. Can someone help me pleaseeee???
 

The problem being that you did not post the errors.

Reason: