Support Board
Date/Time: Mon, 24 Feb 2025 21:19:28 +0000
Post From: Conditions and filters - when order executing a signal but want to add a filter
[2021-03-18 09:38:49] |
User61576 - Posts: 445 |
I have a signal which is based on 3 different calculations (conditions 1-3) and a simple filter (minBarSize) which applies to all situations. it also has an "or" to enter a position if the signal was in bar -1 or in bar -2 I would like to add additional conditions (condition 4 & condition 5), which will be based on the user interface decision to use (yes/no). my problem is that I don't know how to make sure that the condition 4 will work together both if the user decided to used condition 4 (a simple situation which is attached) and when the user doesn't want to use condition 4. I don't want to use "if conditions" as when the user selects 4 on and 5 off or 4 off and 5 on, it get complicated to a level that is very hard to track. the example code: if
( ( (Condition 1[cur - 1]) && (Condition 2[cur - 1]) && (Condition 3[cur - 1]) && (sc.BaseDataIn[SC_HIGH][cur - 1] - sc.BaseDataIn[SC_LOW][cur - 1]) > minBarSize.GetFloat() && (Condition 4[cur - 1]) && (Condition 4[cur - 1]) ) or ( (Condition 1[cur - 2]) && (Condition 2[cur - 2]) && (Condition 3[cur - 2]) && (sc.BaseDataIn[SC_HIGH][cur - 2] - sc.BaseDataIn[SC_LOW][cur - 2]) > minBarSize.GetFloat() && (Condition 4[cur - 2]) && (Condition 5[cur - 2]) ) ) { //check if we holding a position if (inTrade == 0) { //conditions of time is met (and we allowed to trade) if ((BarTime >= StartTime.GetTime() && BarTime < EndTime.GetTime())) { TradingAllowed = true; } //if we don't have a position and allowed to trade if (TradingAllowed) { inTrade = 1; // send the inital long buy entry market order s_SCNewOrder mktOrderBuy; } } } I hope I managed to explain my question well enough thanks for the help! much appreciated! |