Thanks Charlton ! I can now use more intuitive values for the global variables.
OK - so now we have an indicator #TT_MTL_CYCLE. This indicator should be put on the 60/30/10/5/6/1 and should be a replacement of your current MACCi indicator as it will plot the cycle on the chart as well as set the global variables.
Code:// This indicator will return a value based on analyzing the 60 minute $INDU (or other index) // Inputs : OBThreshold(100), OSThreshold(-100),CycleLength(6), Smoothing(5), AlertLevelOB(80), AlertLevelOS(-80); Arrays : CycleHistory[20](0); Vars : LoopCount(0), Zone(""), Direction(""), RTNVal(0); // re-arrange the array so that we store the last 30 values of the indicator in case we get more sophisticated // in figuring direction For LoopCount = 2 to 20 Begin CycleHistory[LoopCount -1] = CycleHistory[LoopCount]; End; CycleHistory[20] = TTCycle(CycleLength,Smoothing); // Now that we have cycle history - we should call another function (TTDirection) that should tell us which way // The indicator is going - we'll pass in the array & that function will tell us up, down, flat, etc // That function can be improved over time // Direction - Indicates direction // + moving up // - moving down // F flat (should not indicate that it is perfecly flat but within a tolerance - say less than 10% angle) // Insert Function Call to set direction here !! // What follows is not final - just a simplification If CycleHistory[20] > CycleHistory[19] then Direction = "+" else if CycleHistory[20] < CycleHistory[19] then Direction = "-" else Direction = "F"; // Now that we have direction, we can look to see if we are OB, OS (based on inputs above) as well as direction // and set 2 global variables for the 60 macci as follows : // Zone - Indicates where it is // OB In the Overbrought zone // OS In the Oversold zone // MID Between OB & OS If CycleHistory[20] >= OBThreshold then Zone = "OB" // Overbrought else if CycleHistory[20] <= OSThreshold then Zone = "OS" // Oversold else Zone = "MID"; // Between overbrought & oversold // Now - set the global variables depending on the interval // I haven't used global variables before but it appears you can only do numerics ! // Bugger - out go my OB, OS, MID setting ideas... Switch(BarInterval) Begin Case 60: RTNVal = GVSetNamedString("Zone60", Zone); RTNVal = GVSetNamedString("Direction60", Direction); Case 30: RTNVal = GVSetNamedString("Zone30", Zone); RTNVal = GVSetNamedString("Direction30", Direction); Case 10: RTNVal = GVSetNamedString("Zone10", Zone); RTNVal = GVSetNamedString("Direction10", Direction); Case 5: RTNVal = GVSetNamedString("Zone5", Zone); RTNVal = GVSetNamedString("Direction5", Direction); Case 3: RTNVal = GVSetNamedString("Zone3", Zone); RTNVal = GVSetNamedString("Direction3", Direction); Case 1: RTNVal = GVSetNamedString("Zone1", Zone); RTNVal = GVSetNamedString("Direction1", Direction); End; Plot1(CycleHistory[20], "Cycle"); Plot2(OBThreshold,"OverBought"); Plot3(OSThreshold,"Oversold"); plot4(0,"Zero"); Plot5(AlertLevelOB,"Alert"); Plot6(AlertLevelOS,"Alert");
Then the next one goes on the 1 minute chart. It's a show me. It's called #TT_ENTRYPOINT.
It will get the global variables & plot entry points.
Code:vars : Zone60(""),Zone30(""), Zone10(""), Zone5(""), Zone3(""), Zone1(""), Direction60(""), Direction30(""), Direction10(""), Direction5(""), Direction3(""), Direction1(""), Bias(" "), Trigger(" "); // Reset the trigger every bar Trigger = " "; // Get the global variables Zone60 = GVGetNamedString("Zone60"," "); Direction60 = GVGetNamedString("Direction60"," "); Zone30 = GVGetNamedString("Zone30"," "); Direction30 = GVGetNamedString("Direction30"," "); Zone10 = GVGetNamedString("Zone10"," "); Direction10 = GVGetNamedString("Direction10"," "); Zone5 = GVGetNamedString("Zone5"," "); Direction5 = GVGetNamedString("Direction5"," "); Zone3 = GVGetNamedString("Zone3"," "); Direction3 = GVGetNamedString("Direction3"," "); Zone1 = GVGetNamedString("Zone1"," "); Direction1 = GVGetNamedString("Direction1"," "); // if higher timeframes(60,30,10) are OB or pointing down - short bias // if higher timeframes(60,30,10) are OS or pointing up - long bias if (Zone60 = "OB" or Direction60 = "-") and (Zone30 = "OB" or Direction30 = "-") and (Zone10 = "OB" or Direction10 = "-") then Bias = "Short" else if (Zone60 = "OS" or Direction60 = "+") and (Zone30 = "OS" or Direction30 = "+") and (Zone10 = "OS" or Direction10 = "+") then Bias = "Long" else Bias = "None"; // Look for entry points on lower timeframes // OS/OB in either 5/3 + 1 is OK if bias = "Short" and (Zone5 = "OB" or Zone3 = "OB") and Zone1 = "OB" then Trigger = "SellShort"; if bias = "Long" and (Zone5 = "OS" or Zone3 = "OS") and Zone1 = "OS" then Trigger = "Buy"; if Trigger = "SellShort" then begin Plot1(Low); Alert; end; if Trigger = "Buy" then begin Plot2(High); Alert ; end ;
Issues
1 - I am not sure if the strategy itself is correct - I think it may be too strict. I hope you guys can follow the code and make suggestions. I hope the comments in the code help the non-coders.
2 - I haven't had time to test it as I'm in LA on business & it's really hectic at the moment it does compile & it does paint the cycle correctly (at the moment the cycle it paints is MACCi).
3 - We can do a much better job of direction than just comparing the past 2 values but I just haven't had the time to look into this.
This is the baseline for entry point code - we all need to get involved now to tweak the entry rules. For instance, am I expecting too much for the 5/3 and 1 to be over 100 or under 100 ?
Both ESLs and the function are in the attached .ELD
Hi my friends
you guys are way ahead of me in coding.... this weekend I'll try to go though your code and try to come up with some suggestions to add to you value added research... all you guys posting are working very hard... And I can see that and appreciatte the effort..
its almost at an obsessive level which is good :clap: