Coding help - page 54

 

Need help with Sleep funtion

Hi mladen

My requirement is if previous trade hit stoploss then EA should sleep for 24hours. Could you please help me to code it

 
mladen:
annbeea As of first part of your post : yes, that version will repaint (it is due how T3 calculation is done and it has an error in it, that is why I told that it is better to use the other one)

hi mladen, besides use the other one you mentioned, could you recode that part of the indicator attached as i prefer its crossing style, so that it will not repaint past and with the correct alert code?

Many thanks for help

Files:
 

Trading marks on the chart, how can I clear them

I get these Red dots on my charts ever time it places an order. how can I turn that off or clear them. I do not know what is causing them.

Files:
dots.jpg  71 kb
 

You can use a function like this :

bool lastOrderStopLossHit(int magicNumber, string symbol, datetime& lastTime)

{

double lastClosePrice = -1;

double lastStopLoss = -1;

//

//

// reset the time of the last order

//

//

lastTime = -1;

//

//

// find the last order

//

//

for (int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) continue;

if (OrderMagicNumber()!=magicNumber) continue;

if (OrderSymbol() !=symbol) continue;

if (OrderCloseTime()>lastTime)

{

lastTime = OrderCloseTime();

lastClosePrice = OrderClosePrice();

lastStopLoss = OrderStopLoss();

}

}

int digits = MarketInfo(symbol,MODE_DIGITS);

return (lastTime!=-1 && NormalizeDouble(lastClosePrice,digits)==NormalizeDouble(lastStopLoss,digits));

}[/PHP]

and then at the beginning of the start procedure place a code that could look like this :

[PHP] datetime lastClosedTime;

if (lastOrderStopLossHit(1,Symbol(),lastClosedTime) && (lastClosedTime+24*60*60)>TimeCurrent()) return(0);

If you wish a pause different than 1 day, change the "24*60*60" to what you wish

PS: I used "1" for the magic number in the call. Replace it with your real magic number

uk_kara:
Hi mladen My requirement is if previous trade hit stoploss then EA should sleep for 24hours. Could you please help me to code it
 

Hi mladen,

could you help me to amend the code inside, so that it can (normalize) to have vertical scale : minimum as zero, maximum as 100, mid point at 50 instead of zero now, but still maintain the same signals as before? Many thanks for help.

Files:
 

annbeea

You can not do that. Normalization of any kind will change the signals (they can not stay exactly the same - especially since you have 3 values there, there is even less chance to keep the signals at the same places)

annbeea:
Hi mladen, could you help me to amend the code inside, so that it can (normalize) to have vertical scale : minimum as zero, maximum as 100, mid point at 50 instead of zero now, but still maintain the same signals as before? Many thanks for help.
 
mladen:
You can use a function like this :

.............................

If you wish a pause different than 1 day, change the "24*60*60" to what you wish

PS: I used "1" for the magic number in the call. Replace it with your real magic number

Thanks Mladen. I will check it out

 
mladen:
annbeea You can not do that. Normalization of any kind will change the signals (they can not stay exactly the same - especially since you have 3 values there, there is even less chance to keep the signals at the same places)

hi mladen

may be i misuse or misunderstand the word "normalize", is it possible to scale the osc trial test as commonly appear scale, min 0, max 100, mid 50 ?

Btw, is it possible to let my previous rsi trial test to amend to non repaint? can i know is it the t3 or the rsi components repaint or both repaint? Many thanks for help.

 

annbeea

We are talking about the same thing : converting values to have minimum and maximum is always going to "deform" original values. We can call it normalization or standardization or whatever we want but the price we pay is a loss of original values correlation. And when they are "deformed" signals will happen on completely different places

As of rsi trial indicator : the t3 part will repaint. It is due to how previous steps of t3 calculation are treated. The first time it is calculated (when you place it on chart, change time frame or symbol, ...) it will calculate OK. but on the next tick, variables e1 through e6 are going to have values of the current (zero-th) bar when you calculate on next tick and they should have at least the values of the 1st bar (depending on the "limit" variable). It is an error how next tick calculation inherits previous step calculation values which will cause bigger and bigger error on each new tick, and that is why I recommended you to use that other indicator as a basis since in that one those problems are solved

annbeea:
hi mladen

may be i misuse or misunderstand the word "normalize", is it possible to scale the osc trial test as commonly appear scale, min 0, max 100, mid 50 ?

Btw, is it possible to let my previous rsi trial test to amend to non repaint? can i know is it the t3 or the rsi components repaint or both repaint? Many thanks for help.
 
uk_kara:
Thanks Mladen. I will check it out

Works like a charm as always , Thanks Mladen, you are a star

Reason: