Am having trouble with coding so that in order for a trade to be valid certain conditions of independent indies must be met in sequence. Am able to get the indicators individually to work correctly, but need help in finding a way to establish something like the following:
1. Indie "A" has a set of parameters and specified conditions that have been met;
2. The EA then looks at indie "B". If the specified setting is not met, then no trade. If the specified setting is met then the trade is valid and it is taken, EXCEPT
3. If the specified setting is not met for indie "B" within "X" numberr of bars or in a settable period of time then the trade is not valid and the EA must then wait until a new sequence starts with indie "A" meeting the specified conditions again to restart the sequence.
I hope my problem is clearly identified and that someone can help. Can provide specific indies and settings if that would help.
Thanks for any assistance.
Help In Establishing Sequence of Events
-
johnsund
- Trader
- Posts: 19
- Joined: Tue Nov 15, 2011 10:23 pm
- gaheitman
- Trader
- Posts: 655
- Joined: Tue Nov 15, 2011 10:55 pm
- Location: Richmond, VA, US
Re: Help In Establishing Sequence of Events
For two phase tests like this, I generally use two boolean variables LookingForBuy and LookingForSell. In the code that checks Indi A, have it set these as appropriate. Then when checking indi B, your code would be something like:johnsund wrote:Am having trouble with coding so that in order for a trade to be valid certain conditions of independent indies must be met in sequence. Am able to get the indicators individually to work correctly, but need help in finding a way to establish something like the following:
1. Indie "A" has a set of parameters and specified conditions that have been met;
2. The EA then looks at indie "B". If the specified setting is not met, then no trade. If the specified setting is met then the trade is valid and it is taken, EXCEPT
3. If the specified setting is not met for indie "B" within "X" numberr of bars or in a settable period of time then the trade is not valid and the EA must then wait until a new sequence starts with indie "A" meeting the specified conditions again to restart the sequence.
I hope my problem is clearly identified and that someone can help. Can provide specific indies and settings if that would help.
Thanks for any assistance.
Code: Select all
If (LookingForBuy)
CheckBIndicator for Buy
{ trade stuff}
if (LookingForSell)
CheckBIndicator for Sell
{trade stuff}
Code: Select all
//indi a said to buy
LookingForBuy = true;
SignalExpires = iTime(NULL,PERIOD_M1,0)+600; //get the start of this minute and add 10 minutes to it
//later
if (iTime(NULL,PERIOD_M1,0) >= SignalExpires) {
LookingForBuy = false;
LookingForSell = false;
}George
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Re: Help In Establishing Sequence of Events
I have adopted this construct:
TradeLong = true;
TradeShort = true;
if IndieA Long conditions fail, then TradeLong = false;
if IndieB Long conditions fail, then TradeLong = false;
if IndieA Short conditions fail, then TradeShort = false;
if IndieB Short conditions fail, then TradeShort = false;
if TradeLong = true, then send a long trade with whatever else is involved
if TradeShort = true, then send a short trade with whatever else is involved
From this, you can see that a trade will trigger unless any of the requirements fail. This is working well for me at the moment.
Good to see you getting involved in actual coding John. Sing out when you need more help.

TradeLong = true;
TradeShort = true;
if IndieA Long conditions fail, then TradeLong = false;
if IndieB Long conditions fail, then TradeLong = false;
if IndieA Short conditions fail, then TradeShort = false;
if IndieB Short conditions fail, then TradeShort = false;
if TradeLong = true, then send a long trade with whatever else is involved
if TradeShort = true, then send a short trade with whatever else is involved
From this, you can see that a trade will trigger unless any of the requirements fail. This is working well for me at the moment.
Good to see you getting involved in actual coding John. Sing out when you need more help.
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.