I have been trying to build an MA crossover EA using FxPro Quant and have had some issues.
I would like the strategy to buy (or close a sell trade) when the 5 period ema crosses above the 8 period ema and sell (or close a buy trade) when the 5 period ema crosses below the 8 period ema. This trade should happen only at the close of a price bar (to avoid crossing and uncrossing of the emas); however on the system that I have programmed it opens or closes a trade at seemingly random points.
I have tried to program it; however it opens multiple positions one after the other. (I have if no orders set to True on both the Buy & Sell Side).
Please ensure that the Buy and Sell nodes have different Magic Index numbers.
E.g. ‘Buy’ and ‘Close Buy Trade’ should have 1, ‘Sell’ and ‘Close Sell Trade’ should have 2.
Kind regards,
FxPro Team
Trading CFDs involves significant risk of loss.
I Want to program an EA with a function: When a fast MA cross the slow MA in upward direction, AND some other conditions are fulfiled, the EA opens a long position, but only one. No other long positions will be opened (even when all the conditions are fulfiled again), UNTIL the fast MA cross the slow MA in upward direction AGAIN.
So (as I think) I need some kind of “true/false register”, wich turns to false when the first position (in the direction) opened, AND remain false after the first position closed, until the MA’s crosses again. Set condition is the opened position, re-set condition is the MA cross.
I try the true/false variable, but I can’t connect separate set and re-set conditions.
Would You be so kind to tell me a solution fro the problem?
Usually strategies like this require using variables to store some values between ticks.
However, in this particular case you can avoid it. Your strategy can be implemented with the following rules:
MA Fast [2] < MA Slow [2]
MA Fast [1] >= MA Slow [1]
New bar
In square brackets candle index is shown. 0 - means current candle, 1 - previous candle, etc.
This way your position will be opened only when crossover happened on the first tick of the next candle. And new position will be opened only when Fast MA return below Slow and cross it upward again.
Hi, sorry for the poor translation but I do not speak English well. I try to be brief. I want to know how to set limits on income and losses, apart from the “Stop Loss” and “Take Profit” established in the modules to buy and sell. That is, reach close operation when certain Pips gain or loss, a kind of Stop Loss and Take Profit hidden. Thank you very much.
hi! how to make so that after closing the order did not open a new one in the same direction and waited for an opposite signal? and no matter how he is closed to stop or manually
If you are using the same magic index for Buy and Sell positions, you can save the last open time for Buy and for Sell orders. You will have 3 possible situations:
Thnak you for the answer ! I have been trying to implement it for days, but it is still not working. Here is the screenshot: Please let me know what is wrong
hello I can’t figure out to to make this help me please
I’m trying to make better take profit stop loss system I want to make the ea close the position when profit reach 1 or 2% gain or 3% floating equities loss.
I don’t want to use pips system I want the equities gain loss % by percentage help me out please !
You may use the Account Node, found under the ‘Info’ section. Selecting ‘Profit’ will return Profit and Loss in opened position, while selecting ‘Equity’ will return currency account equity.
This can also be calculated via the single order profit, for which you may use the Order Data Node with parameters set to Profit.
Another question is, how can we do to avoid open operations during certain days of the week, for example from Friday at 20:30 until Monday at 01:30 and every week?
Please use Ask - Bid to see the current spread value. Then, you may transform points to a whole number and compare it to the desired value. This comparison should be added to the AND node as one of the conditions to open a position.
This can be done by checking date and time components like Day of Week, Hour and Minutes individually and combining them into one logical expression. See example on screenshot.