DaffyTaffy wrote: Mon Jul 24, 2023 5:49 pm
Hi TradeXtra,
Apologies for the late response. Life gave me some hard lemons but I'm back. Here's my suggestion hopefully it works and I will do my best to keep my English , explanations and logic simple.
Code: Select all
// Define a global variable to track trade status
bool g_tradeOpened = false;
// Function to check entry conditions
bool ShouldEnterTrade()
{
// Implement your entry conditions logic here
// For example, you could use indicators, price patterns, etc.
// Return true when the conditions for entry are met, and false otherwise
return (your_entry_conditions_here);
}
// Function to place a trade
void OpenTrade()
{
// Implement your trade execution code here
// For example, use OrderSend() or any other method you prefer
// Set g_tradeOpened to true to indicate that a trade has been opened
g_tradeOpened = true;
}
// Function to close the trade
void CloseTrade()
{
// Implement your trade closing code here
// For example, use OrderClose() or any other method you prefer
// Set g_tradeOpened to false to indicate that the trade has been closed
g_tradeOpened = false;
}
// The main function where you handle the trading logic
void OnTick()
{
// Check if the trade is already open
if (!g_tradeOpened)
{
// Check the entry conditions
if (ShouldEnterTrade())
{
// Place a trade
OpenTrade();
}
}
}
To make sure the EA places only one entry per signal, regardless of whether the trade was closed manually or by another EA, you need to implement a mechanism to track the status of the trade and avoid another entry when the conditions are still met. One way to achieve this is by using a global variable to keep track of whether a trade was opened based on a signal.
In this code, the g_tradeOpened variable tracks whether a trade was opened based on a signal. When the FNC EA receives an entry signal and the g_tradeOpened flag is false (meaning no trade is currently open based on a signal), it will execute the OpenTrade() function and set g_tradeOpened to true. As long as g_tradeOpened is true, the FNC EA will not open any new trades based on the same signal.
When you manually close the trade or it gets closed by another EA, the CloseTrade() function should be called, and it will set g_tradeOpened to false, allowing the FNC EA to enter new trades again if the entry conditions are met.
Note: This is a very basic outline of how to meet the one trade per entry condition you described. It may need to be customized depending on the entry conditions and trade execution of the FNC Greedy System. I hope this was helpful to you guys. Let me know if you need any more help.
Best wishes,
DaffyTaffy