| / | Forum |
|
tintin92
2006.09.21 12:12
Hello,
Is it possible to use a trendline to set a alert ? With something like that : If close > trendline then Alert("Resistance breaked"); Regards, Tintin92 |
|
Protect Yourselves, Developers! Protection of intellectual property is still a big problem. This article describes the basic principles of MQL4-programs protection. Using these principles you can ensure that results of your developments are not stolen by a thief, or at least to complicate his "work" so much that he will just refuse to do it. |
|
rfiche
2006.09.21 15:23
Tintin,
Everything is possible with MQL4. See the following code: // 1. Define the coordinates datetime time1 = CurTime()-(Period()*60*30); double price1 = High[10]; datetime time2 = CurTime(); double price2 = High[1]; // 2. Create Trend Line using the 2 coordinates above ObjectCreate("BuyStop", OBJ_TREND, 0, time1, price1, time2, price2); // 3. Setting Trend Line style ObjectSet("BuyStop", 6, LimeGreen); ObjectSet("BuyStop", 7, STYLE_DOT); ObjectSet("BuyStop", 10, 0); ObjectSetText("BuyStop", "BuyStop"); // 4. Checking buy signal... double trendLineCurrent = ObjectGetValueByShift("BuyStop", 1); double trendLinePrevious = ObjectGetValueByShift("BuyStop", 2); if (Close[1] > trendLineCurrent && Close[2] <= trendLinePrevious) { Alert("Buy Signal"); } See more details: http://docs.mql4.com/objects Regards, |
|
tintin92
2006.09.22 02:20
Hello rfiche,
Thanks for your answer. Steps 1 to 3 have to be in a script, and step 4 have to be in a Expert Advisors, right ? Tintin92. |
|
rfiche
2006.09.22 07:11
tintin92 wrote: Hello rfiche, Thanks for your answer. Steps 1 to 3 have to be in a script, and step 4 have to be in a Expert Advisors, right ? Tintin92. Tintin, you can put the steps 1 to 3 on init() and the step 4 on start() function. Read about init(), deinit() and start() MQL4 functions. I think it is very important to understand the execution flow of experts, indicators and scripts. |
|
jianweikang
2006.09.22 14:16
Hello rfiche: thanks, weikang |
|
rfiche
2006.09.22 19:52
jianweikang wrote: Hello rfiche: thanks, weikang Sure. I am here to help you all.
double macdValues[10]; // create a temporary Array // fill array with MACD values for (int i = 0; i < 10; i++) { macdValues[i] = iMACD("GBPUSD", ... , i); } // get max. and min. values double maxMACD = ArrayMaximum(macdValues); double minMACD = ArrayMinimum(macdValues); Regards, Renato. |
|
jianweikang
2006.09.23 19:02
Hello rfiche:
Thanks for your help. I have understood that must array function, but still a little question: Could it used to the following code: if(High[0] > High[Highest(NULL,0,MODE_HIGH,10,0) && MACD[0] < maxMACD) // Deviation ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid...... or indicates on chart_window I am not successful to have a try. Can you help me? Thanks, weikang |
|
oldman
2006.09.26 23:37
I think somewhre above was how to get the high of a macd line during 10 periods
on a chart:
this is how I would do it, using your imacd... ie the highest close: double mac,highest; for(int a=0; a<10; a++) mac=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,a); if(highest<mac) {highest=mac;} } Print(highest); (this would include the current period. Change the 0 to a 1 if current period is not wanted) |
|
jianweikang
2006.09.30 18:30
oldman wrote: All have tried, but the result was wrong so have got the correct value. I think somewhre above was how to get the high of a macd line during 10 periods on a chart: this is how I would do it, using your imacd... ie the highest close: double mac,highest; for(int a=0; a<10; a++) mac=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,a); if(highest<mac) {highest=mac;} } Print(highest); (this would include the current period. Change the 0 to a 1 if current period is not wanted) My idea is : if(High[i]>=High[Highest(NULL,0,MODE_HIGH, 10, i+1)] && Macd[i]<maxMACD && Macd[i]>0) OR if(Low[i]<=Low[Lowest(NULL,0,MODE_LOW,10, i+1)] && Macd[i]>minMACDL && Macd[i]<0) " maxMACD OR minMACD " are within 10 period back from i . can you write all codes and successful? and on chart_window display indicating Thanks, weikang |