ICHIMOKU STRATEGY - page 2

 

I've "simplified" the coding a little and began strategy testing.

//+------------------------------------------------------------------+
//|                                              ICHIMOKU_SIMPLE.mq4 |
//|                      Copyright © 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

extern double Lots = 1.0;
extern double Tenkan = 9;
extern double Kijun = 26;   
//----
int start()
   {
   double tenkan_sen;
   double kijun_sen;
   int ticket;
  
// check for long position (BUY) possibility
      if(tenkan_sen>kijun_sen)
         {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+Point,"ichimoku",16384,0,Green);
         if(ticket>0)
            {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
            }
         else Print("Error opening BUY order : ",GetLastError()); 
         return(0); 
         
         }   //  added by RaptorUK
            
   // SELL 
     {
      OrderSelect(SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL && // check for opened position 
         OrderSymbol()==Symbol()) // check for symbol
         {
         if(OrderType()==OP_BUY) // long position is opened
            {
            // should it be closed?
            if(tenkan_sen<kijun_sen)   //  removed surplus (  RaptorUK
               {
               OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
               return(0); // exit
               }
            }
         }
      }
  return(0);
   }

The strategy test shows that the modelling quality is 90% and there are no errors in the journal.

The journal says: 2012.01.18 20:29:44 ICHIMOKU_F1 GBPCHF,H1: loaded successfully
2012.01.18 20:29:47 ICHIMOKU_F1 inputs: Lots=1; Tenkan=9; Kijun=26;

However no trades were undertaken and therefore there were no results.

Could there be a problem with the code?

 
RaptorUK:

You initialize these variables but don't give them any values . . .

. . . so the test will always be false. This EA will never place an Order.

Did you miss my earlier post ?
 
I guess so, my apologies. But isn't it a bit unusual, in this case, as the tenkan-sen and kijun-sen will have different values at every order opened. So surely this would mean that values can't be given. The only property that would be the same for each order opened is the value of tenkan-sen being higher than the value of kijun-sen.
 
ToBa:
I guess so, my apologies. But isn't it a bit unusual, in this case, as the tenkan-sen and kijun-sen will have different values at every order opened.

But you aren't getting the values that change with each new bar . . . you declare the variables and you never set them . . . so they never change, did you expect them to change by magic ?

 
ToBa:

I've "simplified" the coding a little and began strategy testing.

The strategy test shows that the modelling quality is 90% and there are no errors in the journal.

The journal says: 2012.01.18 20:29:44 ICHIMOKU_F1 GBPCHF,H1: loaded successfully
2012.01.18 20:29:47 ICHIMOKU_F1 inputs: Lots=1; Tenkan=9; Kijun=26;

However no trades were undertaken and therefore there were no results.

Could there be a problem with the code?


"simplified" Why this way....

If you have given tenkan-sen and kijun-sen the right coding to get its value and you put it in this

then you will get every tick tenkan_sen>kijun_sen a new trade

How many trades do you wanna get open ???

 
deVries:


"simplified" Why this way....

If you have given tenkan-sen and kijun-sen the right coding to get its value and you put it in this

then you will get every tick tenkan_sen>kijun_sen a new trade

How many trades do you wanna get open ???


The aim is to place a single open order (1.0 lot) as soon as the tenkan-sen is greater than the kijun-sen and hold the position until the tenkan-sen is less than the kijun-sen.
 
ToBa:

The aim is to place a single open order (1.0 lot) as soon as the tenkan-sen is greater than the kijun-sen and hold the position until the tenkan-sen is less than the kijun-sen.
Where do you get these values from ?
 
RaptorUK:
Where do you get these values from ?
I'm not exactly sure what you mean. From the MACD example, it looked to be ok to use: if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious &&

MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious) and no values are given.

 
Ok, I finally see what you mean. Although, I don't have a clue how to retrieve the values.
 
ToBa:
Ok, I finally see what you mean. Although, I don't have a clue how to retrieve the values.
Good, that is progress :-)