Can you fix this code!

 
Hi,

I used following code/idea to apply 1 trade/day. last 20days it was worked. but since today not working. may be my logic will be wrong.

I assign the int value 0 to nday

and process orders if nday!=Day()

once prcess done i change the value for nday=Day()

is this ok. but not working now.

{
    if (nday != Day())
    {
    #define  ZEROAM 00
    #define THREEAM 03
    threeAM=0; while( TimeHour(Time[threeAM]) != THREEAM ) threeAM++;
    High0To3 = High[iHighest(NULL,0,MODE_HIGH, THREEAM-ZEROAM+1,threeAM)];
    Low0To3 = Low[iLowest(NULL,0,MODE_LOW, THREEAM-ZEROAM+1,threeAM)];
    HLdiff=High0To3-Low0To3;
        
    }
}

nday=Day()
 
Backtest works fine.when i do forward test not working.
 
sheriffonline:
Backtest works fine.when i do forward test not working.


Instead of Day() try TimeDay(TimeCurrent())

Is nday static ?

 
RaptorUK:


Instead of Day() try TimeDay(TimeCurrent())

Is nday static ?


not static. i declared global


int nday=0;

 
sheriffonline:

not static. i declared global


int nday=0;

OK, global scope == static
 
RaptorUK:
OK, global scope == static


I wonder that i didnt do anything, but now works fine!...
 
sheriffonline:

I wonder that i didnt do anything, but now works fine!...

Obviously not, if you changed nothing and it didn't work before it is not working correctly now . . . it may for some time but won't be correct.


Did you try "Instead of Day() try TimeDay(TimeCurrent())" ?

 
RaptorUK:

Obviously not, if you changed nothing and it didn't work before it is not working correctly now . . . it may for some time but won't be correct.


Did you try "Instead of Day() try TimeDay(TimeCurrent())" ?


Thank you for your support. i try following code as per your advice.

Is this correct what i am trying?

int nday=0;

if nday!=TimeDay(TimeCurrent());

return(true);

<--Code-->

nday=TimeDay(TimeCurrent());
 
sheriffonline:

Thank you for your support. i try following code as per your advice.

Is this correct what i am trying?


You don't have return(true); in the code you posted earlier . . . just replace Day() with TimeDay(TimeCurrent()) . . . nothing else, one change at a time, then test . . .
 
RaptorUK:
You don't have return(true); in the code you posted earlier . . . just replace Day() with TimeDay(TimeCurrent()) . . . nothing else, one change at a time, then test . . .


Here it is. is this correct one i am using!


{
    if (nday != TimeDay(TimeCurrent()))
    {
        Details();
        
    }
}

void Details()
{
    some_time=iTime(NULL, PERIOD_D1, 0);
    shift=iBarShift(NULL,0,some_time);
    Hval=iHigh(NULL,0,shift);
    Lval=iLow(NULL,0,shift);
    Cval=iClose(NULL,0,shift);
    HLdiff=Hval-Lval;
    Percent=HLdiff*0.25;
    BuyNow=Cval+Percent;
    SellNow=Cval-Percent;
    bTP=BuyNow+Percent;
    sTP=SellNow-Percent;
    bSL=SellNow+0.10;
    sSL=BuyNow-0.10;
    
    Comment("High: ",Hval,"Low: ",Lval,"Close: ",Cval,"Diff: ",HLdiff,"Percent: ",Percent,"Buy: ",BuyNow,"Sell: ",SellNow,"BuyTP: ",bTP,"SellTP: ",sTP,"BuySL: ",bSL,"SellSL: ",sSL,"Day: ",nday);
    
}
 
sheriffonline:

Here it is. is this correct one i am using!

So why did you ask for help with the first code if it isn't what you are using ? are you deliberately trying to waste people's time ?
Reason: