| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Script https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=366 |
Page 1 of 1 |
| Author: | forex.rapheal [ Tue Feb 21, 2012 2:05 am ] |
| Post subject: | Script |
Dear Steve and all experts, Currently I am using a EA to trade range. However I need to close my Long OR Short trade individually. Is there any script to close all trades for Long OR Short only?(including an option to close "Profit for Long" or "Profit for Loss") Once I find the market breaks out, I want to close all my Long or Short trades and leave others floating. (e.g. i have 2 long 2 short open trades, when it breaks out, I close 2 long and leave 2 short trades alone, my EA will continue to close 2 short, however it may continue to open another long. How do I stop EA to continue opening long trades but keeps it on to close my short? Regards, RC |
|
| Author: | gaheitman [ Tue Feb 21, 2012 2:47 am ] |
| Post subject: | Re: Script |
If your EA is likely to open more trades in the direction you don't want, you really need to put all the logic in the EA to both close trades you don't want and to prevent it from opening new ones. Do you have the source to your EA? George |
|
| Author: | SteveHopwood [ Tue Feb 21, 2012 11:40 pm ] |
| Post subject: | Re: Script |
You are trying to use an EA for a purpose for which it is not designed. EA's do what they are programmed to do, not what a user wishes them to do. From your description, your EA is coded to trade a range, so that is what it does. It is not coded to recognise the breakout from the range. |
|
| Author: | forex.rapheal [ Wed Feb 22, 2012 6:00 am ] |
| Post subject: | Re: Script |
Hi Steve and George, Yes you are right as I am the one who decide the direction. I guess the only way is to close all and start it again. Thanks for the advice. |
|
| Author: | thlmobile [ Tue Dec 11, 2012 3:53 am ] |
| Post subject: | Re: Script |
It is not coded to recognise the breakout from the range. ________________________________________________ Thl ThL Smart Phone |
|
| Author: | dietcoke [ Tue Dec 11, 2012 1:22 pm ] |
| Post subject: | Re: Script |
Try using global variables. Create two GV's called TRADE_LONG and TRADE_SHORT give them value of 1 (true) In your EA. in the code which decides whether to trade, run the following check(pseudocode alert) if ( Buy condition met && GlobalVariableGet(TRADE_LONG) == 1) BUY else Dont buy if ( Sell condition met && GlobalVariableGet(TRADE_SHORT) == 1) SELL else Dont Sell Create the GV in your init function (using GlobalVariableSet) and then in your code when you close trades , you can update the GV eg void closeorders() if(close Long trades) Globalvariableset(TRADE_LONG,0); if(close short orders) Globalvariableset(TRADE_SHORT,0); When you close out a poition completely, you will then need to reset the GV's back to 1. the beauty of this is that you can manually change the values in the Globals while the EA is running if you want to. |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|