Replace a previously closed trade
-
Hi FXdreema
After a trade has closed, i would like to be able to place a pending order at the same opening price as the closed trade with the same lot size.
I am using a martingale entry so lot size changes between trades, any one of which may close.I think on trade close would be the best solution with the history but I cannot fathom out how I can get the opening price and lotsize of the closed trade, any advice would be appreciated.
Andy
-
Under "on Trade" get information from the trade that caused the even from "(on trade)...." category that appears in "Condition" and dynamic parameters in blocks. Recently I added a block named "Run blocks" and it can help to execute the block that creates trades.
Otherwise you can always load parameters of the the last closed trade with "For each Closed Trade" (renamed from "Start history trades loop") with 'Not more than "n" trades" parameter set to 1. But now use parameters from "(in loop)..." category.
I think you probably have to define Variable for the lot size and modify it.
-
Thanks for the reply
I am up to the point of using the variables, but for me that's a black art, any pointers would be appreciated,
Cheers.
-
Variables helps to re-use blocks and keep the project with less blocks. But you can always put many blocks.. at least until the browser starts to feel overloaded.
-
Hi FX Dreema
I have tried to add extra lots to a pending order using global variables, however no joy.
I can see using F3 that the lot size is registered in the global variable but for the life of me I cannot see how to adjust
a pending order to the lotsize stored.Do you have an example of something similar?
Andy
-
These global variables are called global variables, and they are really variables and really global, but they are used from MT for all EAs. In fact they are values written somewhere in some file that can be read from all EAs. Otherwise normal global variables works inside the EA.
If you don't need to send variable from one EA to another, don't use these.
-
-
Thanks for the reply.
Using comment on chart I can see the lotsize that i require a pending order to be modified to, is there a way to access that value and modify the pending order?
-
But I don't know what variable you are using

-
Hi Fxdreema
Just getting back to looking at modifying the lotsize.
I have set up a variable Result1 to hold the new lotsize info but cant seem to get a pending order block to read the variable.
Is there anything else that I need to do to get the lotsize modified.
Cheers.
-
If you talk about your project Global Variables, there you have fixed size 0.1 lot for pending order
That formula result is not used. -
Hi
My mistake,it should have been result2.
So basically i need to try and get the information from result2 into the pending order.
Iv'e tried every which way but no joy.
-
"Formula" block creates global variable named "Result1" in your case. This global variable can be used everywhere because it is global.
But in "Buy now" you can use this option "Dynamic value". And in "on Trade" use "(on trade) Trade/Order under on Trade event" instead of "(in loop)...". -
Dynamic value works a treat, thanks for the advice.
Cheers