ICHIMOKU STRATEGY - page 4

 

Is there a way of setting extern double TakeProfit = as tenkan-sen<kijun-sen

Setting it to 0 results in t/p with no price change.

Trying the code below gives me: ')' - wrong parameters count C:\Program Files (x86)\MetaTrader 4\experts\ICHIMOKU_F1.mq4 (26, 77) on the OrderTakeProfit line.

//+------------------------------------------------------------------+
//|                                              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;
//----

int start()
   {
   double tenkan_sen=iIchimoku(NULL, 0, 9, 26, 52, MODE_TENKANSEN, 1);
   double kijun_sen=iIchimoku(NULL, 0, 9, 26, 52, MODE_KIJUNSEN, 1);
   int ticket,total,order_id;
// BUY
      total=OrdersTotal();
   if(total<1 && tenkan_sen>kijun_sen)
         {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,"ichimoku",16384,0,Green);
         } 
// SELL 
   if(tenkan_sen<kijun_sen)   
         {
         ticket=OrderTakeProfit(Symbol(),OP_SELL,Lots,Bid,3,0,"ichimoku",16384,0,Red);
         return(0);
         }     
  return(0);                     
   }    
 

You need to get into the habit of reading the documentation when you don't know the correct syntax for a function . . . . OrderTakeProfit returns the take profit value for the currently selected order. Yoo probably want OrderClose instead.

Is there a way of setting extern double TakeProfit = as tenkan-sen<kijun-sen ? No.

 

Shouldn't OrderClose :

{
OrderClose(order_id,1,Ask,3,Red);
return(0);

}

say Bid instead of Ask

 
ToBa:

Shouldn't OrderClose :

{
OrderClose(order_id,1,Ask,3,Red);
return(0);

}

say Bid instead of Ask

Depends on what type of Order it is . . . Buy at Ask Sell at Bid . . . a Buy is closed by Selling (at Bid) a Sell is closed by Buying (at Ask)
 
Ok last thing - the buy order (OrderSend) does not work without Ask+"number"*Point
 
ToBa:
Ok last thing - the buy order (OrderSend) does not work without Ask+"number"*Point

Of course it does . . . . you use 0 instead. So . . .

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,  0,  "ichimoku",16384,0,Green);

You need all the parameters, the ones that have = in them are optional.

intOrderSend(
string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0,datetime expiration=0, color arrow_color=CLR_NONE)
 

Hi, I'm also trying to write an expert advisor based on the Ichimoku Indicator. But when it's compiled, there are 14 warnings. Can someone please help me compile it better?

//+------------------------------------------------------------------+
//| Caroline's Ichimoku Kinko Hyo.mq4 |
//| Copyright 2013, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

extern double Lots = 0.1; // Amount of lots to trade with
extern double TakeProfit = 0; // The requested close price that determines the maximum profit for the given trade
extern double TrailingStop = 0; // Min number of pips in profit for the trailing stop to start
extern double StopLoss = 0; // The requested close price that determines the maximum loss allowed for the given trade
extern double TenkanSen = 9; // Tenkan-sen (highest high + lowest low)/2 for the last 9 periods
extern double KijunSen = 26; // Kijun-sen (highest high + lowest low)/2 for the past 26 periods
extern double SenkouSpan = 52; // Senkou span A (tenkan-sen + kijun-sen)/2 plotted 26 periods ahead. Senkou span B (highest high + lowest low)/2 calculated over the past 52 time periods and plotted 26 periods ahead

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
Alert ("Function init() triggered at start"); // Alert Initialization
//----
//----
return(0); // Exit Initialization
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double TenkanSen;
double KijunSen;
int cnt, ticket, total;
TenkanSen=iIchimoku(NULL, 0, 9, 26, 52, MODE_TENKANSEN, 0);
KijunSen=iIchimoku(NULL, 0, 9, 26, 52, MODE_KIJUNSEN, 0);
total= OrdersTotal();
//----
if(total<1 && TenkanSen>KijunSen)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,NULL,0,0,Green);
}
if(total<1 && TenkanSen<KijunSen)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,NULL,0,0,Red);
}
//----
if(total>0 && TenkanSen=KijunSen && OrderType==OP_BUY)
{
ticket=OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue);
}
if(total>0 && TenkanSen=KijunSen && OrderType==OP_SELL)
{
ticket=OrderClose(OrderTicket(),OrderLots(),Ask,3,Blue);
}
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
Alert ("Function deinit() triggered at exit"); // Alert Deinitialization
//----
//----
return(0); // Exit Deinitialization
}
//+------------------------------------------------------------------+
 
caroline1289:

Hi, I'm also trying to write an expert advisor based on the Ichimoku Indicator. But when it's compiled, there are 14 warnings. Can someone please help me compile it better?


Please do not double post . . . you created a thread so use that thread and . . .

Please read some other posts before posting . . .

Please edit your post . . . please use the SRC button to post code: How to use the SRC button.

 

I wish to include ICHIMOKU strategy in my trading. How or where  do I download the strategy and how do I implement it on my trading platform ?

Appreciate your answers.

Thanks


Suresh

Reason: