Support Board
Date/Time: Fri, 14 Mar 2025 12:29:12 +0000
[Programming Help] - Quickly testing multiple conditions for acsil trading custom studies
View Count: 213
[2025-02-04 20:51:03] |
User887126 - Posts: 84 |
Hi SC team and the community I have one trading account and one main custom studies with various trading logics condition for triggering long or short order. I want to see what is the best way to test the performance of algo with slightly variable trading parameters. For example, i have 5 conditions for my trading logic for buy order. One condition can be simple fast MA crossover from bottom to slow MA, another condition could be that current candle close is higher than previous candle close. I want to be able to test and turn on/off different combination of these conditions quickly. Lets say, for my first test, only condition 1 and 2 would be on. how would i quickly turn off the requirement that condition 3, 4 and 5 also need to be met to trigger the buy order? for now, i am just manually changing the code and testing with different charts but this is very tedious. please advise on this. any other tips on back testing trading algo is also welcomed. |
[2025-02-05 00:03:49] |
User719512 - Posts: 301 |
If I am understanding correctly, you should be able to add 1 or more Inputs into your study to select the "algo" to use, or turn individual conditions on/off. Then have your custom code handle each and calculate accordingly. |
[2025-02-05 14:41:29] |
User887126 - Posts: 84 |
Hi, Yes. i thought about it but the way i wrote the trading logic is to take a buy order trade only if cond 1, 2 , 3, 4 and 5 all meet the specified parameter. How would i write a study so that i can just easily turn it off ? For example, lets say condition 2 is that current price is higher than moving average for last 10 candle, how do i remove this from trade logic? Is there a specific function i need to use? The only thing i can change in the input is how many candle to look back on to calculate moving average. unless i remove it from trade logic, it will not take any trade. I am new to programming and was wondering if there is an easier way to do this. |
[2025-02-05 16:18:13] |
ondafringe - Posts: 315 |
Yes, it's fairly easy to implement. Read up on Boolean variables, logical operators, and algebraic parenthetical expressions. And then use that in conjunction with what User719512 recommended. Date Time Of Last Edit: 2025-02-05 16:30:52
|
[2025-02-05 19:23:41] |
User719512 - Posts: 301 |
ChatGPT might be beneficial to you as well User887126. Will help with learning as well as refactoring or updating your code to make it more modular to support this logic. bool allConditionsMet = true; // Assume true, will check conditions if (Input1.GetYesNo() && !IsMovingAverageCrossover(sc)) allConditionsMet = false; if (Input2.GetYesNo() && !IsCloseHigherThanPrevious(sc)) allConditionsMet = false; if (Input3.GetYesNo() && !IsVolumeAboveMovingAverage(sc)) allConditionsMet = false; if (Input4.GetYesNo() && !IsBullishCandle(sc)) allConditionsMet = false; if (Input5.GetYesNo() && !IsRSIAbove50(sc)) allConditionsMet = false; sc.Subgraph[0][sc.Index] = allConditionsMet ? 1.0f : 0.0f; |
To post a message in this thread, you need to log in with your Sierra Chart account: