Don't use a fixed factor for "10.5*P_Point/Time_Frame". Rather use a External Variable for that ratio. That way you can change and optimise the "Range_Ratio" for different periods as Market Conditions change. Also, you do not have to calculate or even set the "Time_Frame" variable. It already exists - it is called "Period()".
Also, do not use constants in your code like in "if(Close[0]-PT_Buffer[0]>=5*Pips_SL)". Use a externally declared variable (like in "Range_Ratio") so that you can change and optimise in testing:
There is still more bugs you need to fix. Keep developing your code and testing it. Make your code readable and understandable. Don't just put everything into one line. That makes it difficult for you to debug. Divide the code up into logical blocks so that you can test and make sure each block is working correctly.
Hello, FMIC
I have rearrange my code again to let it more readable and understandable as you request; but I really can;t find any bug, or maybe do you mean the bugs, such as "Move_Stop = 30; ", I should change "30" by some variable?
the code after rearranged in this attachment. I hope I will not waste you much time.
I have rearrange my code again to let it more readable and understandable as you request; but I really can;t find any bug, or maybe do you mean the bugs, such as "Move_Stop = 30; ", I should change "30" by some variable?
the code after rearranged in this attachment. I hope I will not waste you much time.
always thank you!
There is still several bugs and use of constants:
...
SL_Point = 15// Should be External Variable
TP_Point = 0// Should be External Variable
...
OrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0); // Define Slippage as External Variable
// As you did for StopLoss, also TakeProfit should be corrected for Opening Price and Pips/Points just like the StopLoss
// Make use of a Magic number to differentiate EA orders from other EA's and manual trades
// Always verify the result of the OrderSend() and any resulting errors. Don't assume it will always work.
// Rather wait/sleep if the order fails and not before, because the bid/ask price my change while you wait.
...
// Should use OrderClosePrice() instead of Close[]// MathAbs() will consider a Loss as a Profit ( rather check if order is long or short )
Profit_Point = NormalizeDouble( MathAbs( Close[0] - OrderOpenPrice() )/Pips_SL,0 )
if( MathAbs( Close[0] - OrderStopLoss() ) > Move_Stop*Pips_SL )
...
Move_Stop = 30; // Use External Variable to apply value instead of constant
...
if( Profit_Point > 50 ) Move_Stop = 15; // Both constants should be External Variable
...
Sleep(110); // Consider as External Variable for better control
...
// Consider changing Signal and Uniformity values to be more understandable:// 0 = No change, +1 = Upper/Long/Buy; -1 = Lower/Short/Sellif( Check==true && Uniformity(CNT)==0 ) Signal[0]=1.0int Uniformity(int Bars_Shift)
...
There is still more bugs, but you need to pay more attention to what was written before by me and other posters and follow through on your own, checking the manual and other examples on this site to correct your own bugs and logic of the EA.
We cannot do it all for you. If you want to have our help you need to put more effort into your work and learning of MQL4 and Forex Trading.
There is still more bugs, but you need to pay more attention to what was written before by me and other posters and follow through on your own, checking the manual and other examples on this site to correct your own bugs and logic of the EA.
We cannot do it all for you. If you want to have our help you need to put more effort into your work and learning of MQL4 and Forex Trading
FMIC, thank you very much for all your patience and time.
My modifications are as below(two Parts, Part I is the modification as you request; Part II is the modification by myself ) :
Part I:
SL_Point = 15// Should be External Variable Done
TP_Point = 0// Should be External Variable not as external, because most time I don;t want to close the order by order take profit; I set it just for maybe some special case
i think, and until now I don;t consider well,so just let it as 0, and I know it should be used as stop loss, thank for your reminding.
OrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0); // Define Slippage as External Variable Done
// As you did for StopLoss, also TakeProfit should be corrected for Opening Price and Pips/Points just like the StopLoss Known, Thanks
// Make use of a Magic number to differentiate EA orders from other EA's and manual trades Done
// Always verify the result of the OrderSend() and any resulting errors. Don't assume it will always work. Done
// Rather wait/sleep if the order fails and not before, because the bid/ask price my change while you wait. Done. If fails, I just open again; is there better method?
in addition, is there necessary to do the same for "orderclose()" or "ordermodify()"? and if it is, I don;t know how to do better when they fails;
I find ordermodify() often fails and get error 1, and I think it is because of data.
// Should use OrderClosePrice() instead of Close[] Done for all close[0] of Move_Stop_Loss() in EA, i think it is another story in indicator, so not in Indicator// MathAbs() will consider a Loss as a Profit ( rather check if order is long or short ) Done
Profit_Point = NormalizeDouble( MathAbs( Close[0] - OrderOpenPrice() )/Pips_SL,0 )
if( MathAbs( Close[0] - OrderStopLoss() ) > Move_Stop*Pips_SL )
...
Move_Stop = 30; // Use External Variable to apply value instead of constant Done
...
if( Profit_Point > 50 ) Move_Stop = 15; // Both constants should be External Variable Done
...
Sleep(110); // Consider as External Variable for better control Done
...
// Consider changing Signal and Uniformity values to be more understandable: Done// 0 = No change, +1 = Upper/Long/Buy; -1 = Lower/Short/Sell Done all do some modification on EA caused by modification of these.if( Check==true && Uniformity(CNT)==0 ) Signal[0]=1.0int Uniformity(int Bars_Shift)
...
Part II:
1. int Signal = iCustom(NULL,0,"Test_Ind",Seek_Period_Ind,Bar_Ignore_Ind,Range_Ratio_Ind,Delta_Ratio_Ind,1,0); change constants as extern variables.
2. int counted_bars = IndicatorCounted() ; these code have been changed to avoid always recount 1 bar.
if( counted_bars < 0 ) return(0) ;
else int Limit = Bars-counted_bars-1 ;
3. while( CNT <= Bar_Ign ) changed from "while ( CNT <= 3)" and set "Bar_Ign" as extern variable.
// Make changes suggested even if you do not use TakeProfit. You may need it in the future so prepare code for future. Do not be lazy!// Should be External Variable
TP_Point = 0// As you did for StopLoss, also TakeProfit should be corrected for Opening Price and Pips/Points just like the StopLossOrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0);
// Do it properly. How many times have I said to not use constants! Define Magic as external variable.// You may need to change it in future if conflicting EA's have same magic number.// Make use of a Magic number to differentiate EA orders from other EA's and manual trades OrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0);
// Do it properly, all Order functions OrderSend(), OrderClose(), OrderModify() need to be verified and errors checked and procedures followed.// Don't just repeat in hopes that second time will work. Do proper error follow-up.// Always verify the result of the OrderSend() and any resulting errors. Don't assume it will always work.OrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0);
// NOT DONE. Do it properly!// "IsTradeContextBusy()" and "IsTradeAllowed()" must be monitored asynchronously and not cause any delays or fixed loops!// You only check it once and then assume it will work after the sleep period.// If properly written, you will never need the sleep and not cause delays to your Order processing// Rather wait/sleep if the order fails and not before, because the bid/ask price my change while you wait.OrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0);
// NOT Done. You completely ignored it.// MathAbs() will consider a Loss as a Profit ( rather check if order is long or short )
Profit_Point = NormalizeDouble( MathAbs( Close[0] - OrderOpenPrice() )/Pips_SL,0 )
if( MathAbs( Close[0] - OrderStopLoss() ) > Move_Stop*Pips_SL )
I am going to stop the list here because you still have old bugs which you did not bother to find, bugs which I identified for you which you did not bother to research and fix properly, and now you have even more bugs created with the new changes.
If you want me to do all the work, then fine, we will head over to "jobs" section and we can strike a deal where you PAY ME to do the work and write an EA an Indicator for you!
If you do not want that, then you have to put in more effort to find and fix your own bugs. Do some work by learning, researching and developing your code properly. Don't just put code together any old way. Plan your code, verify the logic, consider errors, consider when things can go wrong, consider future possibilities and properly structure your code accordingly.
I am going to stop the list here because you still have old bugs which you did not bother to find, bugs which I identified for you which you did not bother to research and fix properly, and now you have even more bugs created with the new changes.
If you want me to do all the work, then fine, we will head over to "jobs" section and we can strike a deal where you PAY ME to do the work and write an EA an Indicator for you!
If you do not want that, then you have to put in more effort to find and fix your own bugs. Do some work by learning, researching and developing your code properly. Don't just put code together any old way. Plan your code, verify the logic, consider errors, consider when things can go wrong, consider future possibilities and properly structure your code accordingly.
// Not lazy of course; if I set "takeprofit" as "Ask+TP_Point*Pips_SL" / "Bid - TP_Point*Pips_SL", the order will close at take profit line, which not my purpose; I want to close order
by Move_Stop_Line() or reverse Signal.
// Make changes suggested even if you do not use TakeProfit. You may need it in the future so prepare code for future. Do not be lazy!// Should be External Variable
TP_Point = 0// As you did for StopLoss, also TakeProfit should be corrected for Opening Price and Pips/Points just like the StopLossOrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0);
// while() loop together with function iWait() maybe can resolve these; but I never find anybody use it in these situation.
// Do it properly, all Order functions OrderSend(), OrderClose(), OrderModify() need to be verified and errors checked and procedures followed.// Don't just repeat in hopes that second time will work. Do proper error follow-up.// Always verify the result of the OrderSend() and any resulting errors. Don't assume it will always work.OrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0);
// sorry, I misunderstand your this meaning. in the fact I am not familiar with"IsTradeContextBusy()" and "IsTradeAllowed()" . maybe just "while()" and "IsTradeAllowed()" is ok?
// NOT DONE. Do it properly!
// "IsTradeContextBusy()" and "IsTradeAllowed()" must be monitored asynchronously and not cause any delays or fixed loops!
// You only check it once and then assume it will work after the sleep period.
// If properly written, you will never need the sleep and not cause delays to your Order processin
// Rather wait/sleep if the order fails and not before, because the bid/ask price my change while you wait.OrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0);
// exactly I have done. when you said "// MathAbs() will consider a Loss as a Profit ( rather check if order is long or short )", so I cancel this MathAbs(), and instead, divied into
two part , OP_Sell and OP_Buy, then "if( MathAbs( Close[0] - OrderStopLoss() ) > Move_Stop*Pips_SL )" also should be delete. in addition, MathAbs() of
if( MathAbs( Close[0] - OrderStopLoss() ) > Move_Stop*Pips_SL ) never has chance to consider a loss as profit in this EA.
// NOT Done. You completely ignored it.// MathAbs() will consider a Loss as a Profit ( rather check if order is long or short )
Profit_Point = NormalizeDouble( MathAbs( Close[0] - OrderOpenPrice() )/Pips_SL,0 )
if( MathAbs( Close[0] - OrderStopLoss() ) > Move_Stop*Pips_SL )
Sorry, I offer no more help until you demonstrate an effort into researching the information given here on this thread or the many other threads with useful information. There is plenty of code examples in the CodeBase on this site with good demonstrations on how to properly write the code.
Alternatively, you PAY ME to write the code you want. Head over to the Jobs Section of this site and I will take part in the proceedings. There will be most probably other candidates applying to do the work. You have merely to negotiate prices and durations with candidates and strike a deal with one of them, be that myself or any other candidate you may wish to choose.
Sorry, I offer no more help until you demonstrate an effort into researching the information given here on this thread or the many other threads with useful information. There is plenty of code examples in the CodeBase on this site with good demonstrations on how to properly write the code.
Alternatively, you PAY ME to write the code you want. Head over to the Jobs Section of this site and I will take part in the proceedings. There will be most probably other candidates applying to do the work. You have merely to negotiate prices and durations with candidates and strike a deal with one of them, be that myself or any other candidate you may wish to choose.
Don't use a fixed factor for "10.5*P_Point/Time_Frame". Rather use a External Variable for that ratio. That way you can change and optimise the "Range_Ratio" for different periods as Market Conditions change. Also, you do not have to calculate or even set the "Time_Frame" variable. It already exists - it is called "Period()".
Also, do not use constants in your code like in "if(Close[0]-PT_Buffer[0]>=5*Pips_SL)". Use a externally declared variable (like in "Range_Ratio") so that you can change and optimise in testing:
There is still more bugs you need to fix. Keep developing your code and testing it. Make your code readable and understandable. Don't just put everything into one line. That makes it difficult for you to debug. Divide the code up into logical blocks so that you can test and make sure each block is working correctly.
Hello, FMIC
I have rearrange my code again to let it more readable and understandable as you request; but I really can;t find any bug, or maybe do you mean the bugs, such as "Move_Stop = 30; ", I should change "30" by some variable?
the code after rearranged in this attachment. I hope I will not waste you much time.
always thank you!
Hello, FMIC
I have rearrange my code again to let it more readable and understandable as you request; but I really can;t find any bug, or maybe do you mean the bugs, such as "Move_Stop = 30; ", I should change "30" by some variable?
the code after rearranged in this attachment. I hope I will not waste you much time.
always thank you!
There is still several bugs and use of constants:
There is still more bugs, but you need to pay more attention to what was written before by me and other posters and follow through on your own, checking the manual and other examples on this site to correct your own bugs and logic of the EA.
We cannot do it all for you. If you want to have our help you need to put more effort into your work and learning of MQL4 and Forex Trading.
There is still several bugs and use of constants
There is still more bugs, but you need to pay more attention to what was written before by me and other posters and follow through on your own, checking the manual and other examples on this site to correct your own bugs and logic of the EA.
We cannot do it all for you. If you want to have our help you need to put more effort into your work and learning of MQL4 and Forex Trading
FMIC, thank you very much for all your patience and time.
My modifications are as below(two Parts, Part I is the modification as you request; Part II is the modification by myself ) :
Part I:
i think, and until now I don;t consider well,so just let it as 0, and I know it should be used as stop loss, thank for your reminding.in addition, is there necessary to do the same for "orderclose()" or "ordermodify()"? and if it is, I don;t know how to do better when they fails;I find ordermodify() often fails and get error 1, and I think it is because of data.1. int Signal = iCustom(NULL,0,"Test_Ind",Seek_Period_Ind,Bar_Ignore_Ind,Range_Ratio_Ind,Delta_Ratio_Ind,1,0); change constants as extern variables.2. int counted_bars = IndicatorCounted() ; these code have been changed to avoid always recount 1 bar. if( counted_bars < 0 ) return(0) ; else int Limit = Bars-counted_bars-1 ;3. while( CNT <= Bar_Ign ) changed from "while ( CNT <= 3)" and set "Bar_Ign" as extern variable.Thanks again, I hope there is no other bus.I am going to stop the list here because you still have old bugs which you did not bother to find, bugs which I identified for you which you did not bother to research and fix properly, and now you have even more bugs created with the new changes.
If you want me to do all the work, then fine, we will head over to "jobs" section and we can strike a deal where you PAY ME to do the work and write an EA an Indicator for you!
If you do not want that, then you have to put in more effort to find and fix your own bugs. Do some work by learning, researching and developing your code properly. Don't just put code together any old way. Plan your code, verify the logic, consider errors, consider when things can go wrong, consider future possibilities and properly structure your code accordingly.
I am going to stop the list here because you still have old bugs which you did not bother to find, bugs which I identified for you which you did not bother to research and fix properly, and now you have even more bugs created with the new changes.
If you want me to do all the work, then fine, we will head over to "jobs" section and we can strike a deal where you PAY ME to do the work and write an EA an Indicator for you!
If you do not want that, then you have to put in more effort to find and fix your own bugs. Do some work by learning, researching and developing your code properly. Don't just put code together any old way. Plan your code, verify the logic, consider errors, consider when things can go wrong, consider future possibilities and properly structure your code accordingly.
by Move_Stop_Line() or reverse Signal.// while() loop together with function iWait() maybe can resolve these; but I never find anybody use it in these situation.// Do it properly, all Order functions OrderSend(), OrderClose(), OrderModify() need to be verified and errors checked and procedures followed. // Don't just repeat in hopes that second time will work. Do proper error follow-up. // Always verify the result of the OrderSend() and any resulting errors. Don't assume it will always work. OrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0);// sorry, I misunderstand your this meaning. in the fact I am not familiar with "IsTradeContextBusy()" and "IsTradeAllowed()" . maybe just "while()" and "IsTradeAllowed()" is ok?// NOT DONE. Do it properly! // "IsTradeContextBusy()" and "IsTradeAllowed()" must be monitored asynchronously and not cause any delays or fixed loops! // You only check it once and then assume it will work after the sleep period. // If properly written, you will never need the sleep and not cause delays to your Order processin // Rather wait/sleep if the order fails and not before, because the bid/ask price my change while you wait. OrderSend(Symbol(),OP_BUY,1,Ask,3*Pips_Slip,Ask-SL_Point*Pips_SL,TP_Point,0,0,0,0);if( MathAbs( Close[0] - OrderStopLoss() ) > Move_Stop*Pips_SL ) never has chance to consider a loss as profit in this EA.// NOT Done. You completely ignored it. // MathAbs() will consider a Loss as a Profit ( rather check if order is long or short ) Profit_Point = NormalizeDouble( MathAbs( Close[0] - OrderOpenPrice() )/Pips_SL,0 ) if( MathAbs( Close[0] - OrderStopLoss() ) > Move_Stop*Pips_SL )Sorry, I offer no more help until you demonstrate an effort into researching the information given here on this thread or the many other threads with useful information. There is plenty of code examples in the CodeBase on this site with good demonstrations on how to properly write the code.
Alternatively, you PAY ME to write the code you want. Head over to the Jobs Section of this site and I will take part in the proceedings. There will be most probably other candidates applying to do the work. You have merely to negotiate prices and durations with candidates and strike a deal with one of them, be that myself or any other candidate you may wish to choose.
Regards,
FMIC
Sorry, I offer no more help until you demonstrate an effort into researching the information given here on this thread or the many other threads with useful information. There is plenty of code examples in the CodeBase on this site with good demonstrations on how to properly write the code.
Alternatively, you PAY ME to write the code you want. Head over to the Jobs Section of this site and I will take part in the proceedings. There will be most probably other candidates applying to do the work. You have merely to negotiate prices and durations with candidates and strike a deal with one of them, be that myself or any other candidate you may wish to choose.
Regards,
FMIC
Ok, whatever thank you!