marko001 Posted February 20 Share Posted February 20 Hi all. I have a 2^8 conditions to check in order to sharpen result. TO "simplify it I used this method: First I created a function that, based on which checkbox is select returns the "IF" string Func _GenerateConditions($mode) Local $condition = "Number($array_assets[$n][14]) = 1" If $mode = 1 Then ; long If GUICtrlRead($CB_A_Ichi) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][4]) >= Number($long_greenred) AND Number($array_assets[$n][5]) > Number($long_TKvsKJ)" If GUICtrlRead($CB_A_MACD) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][6]) = Number($long_MACD) AND Number($array_assets[$n][7]) = Number($long_Histo)" If GUICtrlRead($CB_A_RSI) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][11]) >= Number($RSI)" If GUICtrlRead($CB_A_MA) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][8]) = Number($MA)" If GUICtrlRead($CB_A_EMA) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][9]) = Number($EMA)" If GUICtrlRead($CB_A_Mom) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][10]) = Number($Momentum)" If GUICtrlRead($CB_A_Cross) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][13]) = Number($Crossover)" If GUICtrlRead($CB_A_BB) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][12]) = Number($BollingerBands)" Else ; short If GUICtrlRead($CB_A_Ichi) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][4]) <= Number($short_greenred) AND Number($array_assets[$n][5]) < Number($short_TKvsKJ)" If GUICtrlRead($CB_A_MACD) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][6]) = Number($short_MACD) AND Number($array_assets[$n][7]) = Number($short_Histo)" If GUICtrlRead($CB_A_RSI) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][7]) >= Number($short_RSI)" If GUICtrlRead($CB_A_MA) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][8]) = Number($short_MA)" If GUICtrlRead($CB_A_EMA) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][9]) = Number($short_EMA)" If GUICtrlRead($CB_A_Mom) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][10]) = Number($short_Mom)" If GUICtrlRead($CB_A_Cross) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][13]) = Number($short_Crossover)" If GUICtrlRead($CB_A_BB) = $GUI_CHECKED Then $condition &= " AND Number($array_assets[$n][12]) = Number($short_Bollinger)" EndIf Return $condition EndFunc Then I call it in my loop: $sConditions = _GenerateConditions($iTradeWallet) __CW($sConditions) For $n = 0 To UBound($array_assets) - 1 If Eval($sConditions) Then _send($array_assets[$n][3] & " good to be added!", $green) _ArrayAdd($aRemoteAssets, $array_assets[$n][3]) EndIf Next when I write to console $conditions it properly shows the condition itself but using EVAL() seems not passing it to IF cycle so I never can enter the IF Just to clarify: $array_asset is a 2D array containing: ; x,0 = id ; x,1 = Exchange ; x,2 = Currency ; x,3 = Asset ; x,4 = GreenRedStreaks ; x,5 = TKRatio ; x,6 = MACDTrend ; x,7 = HistoTren ; x,8 = MA ; x,9 = EMA ; x,10 = Mom ; x,11 = RSI ; x,12 = Bollinger ; x,13 = Crossover ; x,14 = Volume ; x,15 = MarginEnabled ; x,16 = LastUpdate Any suggestion to avoid a 2^8 If...then Marco Link to comment Share on other sites More sharing options...
mistersquirrle Posted February 21 Share Posted February 21 I think that Eval is not what you want, from the helpfile: Return the value of the variable defined by a string. You are not passing a variable to Eval, so it fails with 0, and your If check fails I think what you want is Execute: https://www.autoitscript.com/autoit3/docs/functions/Execute.htm Give Execute a read and try, and see if that works. We ought not to misbehave, but we should look as though we could. Link to comment Share on other sites More sharing options...
marko001 Posted February 21 Author Share Posted February 21 Perfect! Exactly what I needed!!! Thanks @mistersquirrle! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now