Ichimoku MA EA

 


Hey pips i have been trying to code an EA which uses both a MA and the Ichimoku and its not going very well.Was no able to input the closeOrder function let alone making it optimum.Metaquotes seems to be on another level as compared to the other languages. i have tried using the documentation but something is still off with my code please help me out here 

 
   //wondering where to input the close order since its to be in global scope



      

 

Forum on trading, automated trading systems and testing trading strategies


When you post code please use the CODE button (Alt-S)!

Use the CODE button

 
//+------------------------------------------------------------------+
//|                                                        Begin.mq4 |
//|                                                         Peter M. |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Peter M."
#property link      ""
#property version   "1.00"
#property strict

extern double takeProfitPips=60.;
extern double stopLossPips=20.;
extern double lotSize=0.01;
extern double pipValue=50;
extern double e1=4;
extern double e2=21;
extern double fPeriod=50;

double getPipValue(){
      if( _Digits >= 4  ){
      
         return 0.0001;
      
      }
      
      
      else
         return 0.01;}
void start (){
   
   
   
  double fastMovingAverage=iMA(Symbol(),0,fPeriod,0,MODE_SMA,PRICE_CLOSE,0);
  double previousPriceClose=Close[1];
  double stopLossPriceBuy=(Ask-stopLossPips*_Digits);
  double stopLossPriceSell=(Bid+stopLossPips*_Digits);
  double typicalPrice=(High[0]+Low[0]+Close[0])/3;
  double diff1=MathRound(typicalPrice-fastMovingAverage)/Point;
  double diff2=MathRound(fastMovingAverage-typicalPrice)/Point;
  double e1MovingAverage=iMA(Symbol(),0,e1,0,MODE_SMA,PRICE_CLOSE,0);
  double e2MovingAverage=iMA(Symbol(),0,e2,0,MODE_SMA,PRICE_CLOSE,0);
  double takeProfitBuy=(Ask+takeProfitPips*getPipValue());
  double takeProfitSell=(Bid+takeProfitPips*getPipValue());
  
  
  double tenkanSen=iIchimoku(Symbol(),0,9,26,52,MODE_TENKANSEN,1);
  double kijunSen=iIchimoku(Symbol(),0,9,26,52,MODE_KIJUNSEN,1);
  double chikouSpan=iIchimoku(Symbol(),0,9,26,52,MODE_CHIKOUSPAN,1);
  double senkouSpanA=iIchimoku(Symbol(),0,9,26,52,MODE_SENKOUSPANA,1);  
  double senkouSpanB=iIchimoku(Symbol(),0,9,26,52,MODE_SENKOUSPANB,1);
  
   static datetime bar_time=0;
   if ( bar_time!=Time[0]){
   bar_time=Time[0];
    if ( OrdersTotal()==0 ){
      if( previousPriceClose>fastMovingAverage && (e1MovingAverage > e2MovingAverage) && ((previousPriceClose > senkouSpanA && senkouSpanB) || tenkanSen > kijunSen || previousPriceClose > kijunSen)){
          
        
         int ticket= OrderSend(Symbol(),OP_BUY,lotSize,Ask,0,stopLossPriceBuy,takeProfitBuy,NULL,0,0,clrNONE );
       
         
         }
         
         }
  
      if( previousPriceClose < fastMovingAverage && (e1MovingAverage < e2MovingAverage) && ((previousPriceClose < senkouSpanA && senkouSpanB) || tenkanSen < kijunSen || previousPriceClose < kijunSen) ){
      
      
            int ticket= OrderSend(Symbol(),OP_SELL,lotSize,Bid,0,stopLossPriceSell,takeProfitSell,NULL,0,0,clrNONE);
      
            }
      }
  
   }
      
 
In future please post in the correct section
I will move your topic to the MQL4 and Metatrader 4 section.
 

i actually need help you took me to the wrong section

 
Petess:

i actually need help you took me to the wrong section

Your code is MQL4? Correct?

This is the correct section.