15 min chart strategy not working

 

Hi,

What is wrong with my code ?

I have strange values for lot size  cadjpy, cadchf,audchf pairs for some unknown reasons

void OnTick()
  {
      double spread  = MarketInfo(Symbol(), MODE_SPREAD);
      double adx1 = iADX(NULL,PERIOD_M15,10,PRICE_CLOSE,MODE_MAIN,0);     
         if(Volume[0]==1)
         {             
             double macdV1 = iMACD(Symbol(),PERIOD_M15,12,26,1,PRICE_CLOSE,MODE_MAIN,1);
             double ma6 = iMA(Symbol(),PERIOD_M15,6,0,MODE_EMA,PRICE_CLOSE,1);
             double ma4 = iMA(Symbol(),PERIOD_M15,4,0,MODE_EMA,PRICE_CLOSE,1);
             double ma4_2 = iMA(Symbol(),PERIOD_M15,4,0,MODE_EMA,PRICE_CLOSE,2);
             double ma6_2 = iMA(Symbol(),PERIOD_M15,6,0,MODE_EMA,PRICE_CLOSE,2);
             double sto = iStochastic(Symbol(),PERIOD_M15,14,3,3,MODE_EMA,STO_LOWHIGH,0,0);
             if(AccountProfit() > (-1)*AccountBalance()/2)
             {                    
                    double stopLosslevel = calculateStopLoss("min");
                    double tp = Bid +  (Bid - stopLosslevel) + spread *Point;
                    double factor = AccountBalance() * 0.2 / 100.0;
                    double lot = (factor/tp /(SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE)));
                    lot = NormalizeDouble(lot,2);
                    Print("Factor=" + factor);
                    Print("BUY StopLoslevel" + stopLosslevel);
                    Print("Diff" + (Bid - stopLosslevel));
                    Print ("BUY TPLevel" + tp);
                    Print("Buy lot" + lot);
                    Print("ma4 =" + ma4);
                    Print("ma4_2 =" + ma4_2);
                    Print("ma6=" + ma6);
                    Print("ma6_2=" + ma6_2);
                    Print("MACD=" + macdV1);
                    Print("Stoch =" + sto);
                    if((ma4 > ma6) && (ma4_2 < ma6_2))
                      Print("MATCHbuy!");                    
               if((ma4 > ma6) && (ma4_2 < ma6_2) && (macdV1 > 0) && (sto > 50) && (sto < 80))
                {                  
                    double stopLosslevel = calculateStopLoss("min");
                    double tp = Bid +  (Bid - stopLosslevel) + spread* Point;
                    double factor = AccountBalance() * 0.2 / 100.0;
                    double lot = (factor/tp /(SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE)));
                    lot = NormalizeDouble(lot,2);
                    Print("BUY StopLoslevel" + stopLosslevel);                   
                    Print ("BUY TPLevel" + tp);
                    Print("Buy lot" + lot);
                    OrderSend(Symbol(),OP_BUY,lot,Ask,0,stopLosslevel,tp);        
                }
                if((ma4 < ma6) && (ma4_2 > ma6_2))
                      Print("MATCHsEll!");
                if((ma4 < ma6) && (ma4_2 > ma6_2) && (macdV1 < 0) && (sto < 50) && (sto > 20))
                {
                 
                    double stopLosslevel = calculateStopLoss("max");
                    double tp = Bid - stopLosslevel;
                    double factor = AccountBalance() * 0.5 / 100;
                    double lot = (factor/tp /(SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE)));
                    lot = NormalizeDouble(lot,2);                    
                    OrderSend(Symbol(),OP_SELL,lot,Ask,0,stopLosslevel,tp);
                }             
             }             
         }                  
      //}
  }
  double calculateStopLoss(string val)
  {           
     if(val == "min")
         return iLow(Symbol(),PERIOD_M15,iLowest(Symbol(),PERIOD_M15,MODE_LOW,10,1));
     else
         return iHigh(Symbol(),PERIOD_M15,iHighest(Symbol(),PERIOD_M15,MODE_LOW,10,1));         
  }

I'm planning to risk only 0.2% of total amount per transaction.

The stop loss / take profit would be the min / max of last 10 candles in a 15 minutes chart

Can anybody help me ?


Also , would you recommend me some better strategies to try for 15 min chart ?

Thanks,

 
Iulian Astalus:

Hi,

What is wrong with my code ?

I have strange values for lot size  cadjpy, cadchf,audchf pairs for some unknown reasons

I'm planning to risk only 0.2% of total amount per transaction.

The stop loss / take profit would be the min / max of last 10 candles in a 15 minutes chart

Can anybody help me ?


Also , would you recommend me some better strategies to try for 15 min chart ?

Thanks,

Buy low sell high