Download MetaTrader 5

Coding Tenkansen/Kinjunsen cross

To add comments, please log in or register
prweza
270
prweza  

 I'm using iCustom ichimoku 

double tenKansen =iIchimoku(NULL,0,9,26,52,MODE_TENKANSEN,1);

double kinjusen =iIchimoku(NULL,0,9,26,52,MODE_KIJUNSEN,1);

I want to tell the programme to buy when the lines cross. I've tried to use something like 

buy when  tenkansen = Kinjunsen but this doesn't seem to work. Please help with a simple code as   I'm new to mql4.

Thanks.

prweza
270
prweza  
Please i'll appreciate your help!!
whroeder1
16058
whroeder1  
prweza: I want to tell the programme to buy when the lines cross. I've tried to use something like  buy when  tenkansen = Kinjunsen but this doesn't seem to work.
  1. Of course it doesn't. Doubles are rarely equal. The == operand. - MQL4 forum
  2. Do exactly what you said - look for a cross.
    double aPrev = ..., aCurr = ...,
           bPrev = ..., bCurr = ...;
    bool   wasUp = aPrev > bPrev,
            isUp = aCurr > bCurr,
           isCross = isUp != wasUp;
To add comments, please log in or register