Hi pipPod, the varaible is datetime declared within the OnTick{} block (so I guess local) and is not static. I am a bit confused about the 'static' in the fact that..., does it Scenario A. - retain the value assigned to it during the 'lifetime' of the EA, in other words until removed from the chart?, or does it Scenario B. - retain the value all the way through the whole code until it reaches the bottom and then can get a new value once a new tick comes along?
I will try your suggestion changing the code to static, but the reason I asked the question above is because I need this variable ready to get a new value once the actual candle it is working on completes and a new 'Bar' opens, opening the readiness of the variable to get a new value.
It retains the value until a new value is assigned to it when the order is sent( UBand01_OOT=Time[0];). If it's declared locally or non-static, every time a new tick comes in, the variable will be equal to zero. So Time[0] will always be bigger than UBand01_OOT.
The following will only open an order once per bar for each condition, iow maximum 2 orders per bar.
staticdatetime UBand01_OOT,UBand02_OOT;
if((Close[0]>Cls0_ULevelValue_01) && (Close[0]<Cls0_ULevelValue_02)) // Tests whether the Close[0] is within pre-determined level 1 and 2if((Time[0]>UBand01_OOT) && (TIME0vsTIME1_Drctn==1)) // It tests whether there has already an order placed after the Current Bar Opening Time.
{
UBand01_OrdSend=OrderSend(Symbol(),OP_SELL,SzSell_01,Bid,0,0,0,NULL,00,0,clrRed);
UBand01_OOT=Time[0];
}
//--------------------------------------------------------------------------------------------- if((Close[0]>Cls0_ULevelValue_02) && (Close[0]<Cls0_ULevelValue_03)) // Tests whether the Close[0] is within pre-determined level 2 and 3if((Time[0]>UBand02_OOT) && (TIME0vsTIME1_Drctn==1))
{
UBand02_OrdSend=OrderSend(Symbol(),OP_SELL,SzSell_02,Bid,0,0,0,NULL,00,0,clrRed);
UBand02_OOT=Time[0];
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi pipPod, the varaible is datetime declared within the OnTick{} block (so I guess local) and is not static. I am a bit confused about the 'static' in the fact that..., does it Scenario A. - retain the value assigned to it during the 'lifetime' of the EA, in other words until removed from the chart?, or does it Scenario B. - retain the value all the way through the whole code until it reaches the bottom and then can get a new value once a new tick comes along?
I will try your suggestion changing the code to static, but the reason I asked the question above is because I need this variable ready to get a new value once the actual candle it is working on completes and a new 'Bar' opens, opening the readiness of the variable to get a new value.
It retains the value until a new value is assigned to it when the order is sent( UBand01_OOT=Time[0];). If it's declared locally or non-static, every time a new tick comes in, the variable will be equal to zero. So Time[0] will always be bigger than UBand01_OOT.
The following will only open an order once per bar for each condition, iow maximum 2 orders per bar.
I mean a simple 1 Minute delay between orders.
If you need less then use a simple counter.