Menu
Brokers
MT4 Forex Brokers
MT5 Forex brokers
PayPal Brokers
Skrill Brokers
Oil Trading Brokers
Gold Trading Brokers
Web Browser Platform
Brokers with CFD Trading
ECN Brokers
Bitcoin FX Brokers
PAMM Forex Brokers
With Cent Accounts
With High Leverage
Cryptocurrency Brokers
Forums
All threads
New threads
New posts
Trending
Search forums
What's new
New threads
New posts
Latest activity
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Reply to thread
Forums
Trading Platforms
MetaTrader 4
MQ4 Code Works
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
[QUOTE="TradeChaser, post: 204931, member: 66787"] For what it is worth, I got the lines to start drawing. What perplexes me, however, is that I could not run it in my original code, but I can now. In my original For-Loop, I create the arrays that feed the buffers. My understanding of the loop is I could check for a cross at the same time as iterating for the buffers. However, I got no such luck. After creating a second For-Loop completely separate from the first, I iterated again through the buffers, checking for a cross and drawing the object. Just for a teaching perspective, can you explain why my object was not drawing properly within the single For Loop? I copied the working code below. Originally, the second block was simply located in the scope of the first loop. Another oddity... The alert is working just fine in the original For Loop. scratching my head on this one. [CODE=mql4] for(int i=0;i<limit - 1;i++) { //---Determine MTF shift(timeperiod, i); Pair1[i] = pairs(pair1); ObjectSetString(0, "Pair1", OBJPROP_TEXT, pairslist[pair1]+ ": "+DoubleToStr(Pair1[0],3)); Pair2[i] = pairs(pair2); ObjectSetString(0, "Pair2", OBJPROP_TEXT, pairslist[pair2]+ ": "+DoubleToStr(Pair2[0],3)); max[i] = -15; min[i] = -85; if(Pair1[i+1] < Pair2[i+1] && Pair1[i] > Pair2[i]) Alert(pairslist[pair1]+pairslist[pair2]+" Bullish Cross"); if(Pair1[i+1] > Pair2[i+1] && Pair1[i] < Pair2[i]) Alert(pairslist[pair1]+pairslist[pair2]+" Bearish Cross"); } for(int i=0;i<limit - 1;i++) { if((Pair1[i+1] < Pair2[i+1]) && (Pair1[i] > Pair2[i])) { if (ObjectFind("Buy 3 Little Piggies"+i) != 0) { ObjectCreate( "Buy 3 Little Piggies"+i, OBJ_VLINE, 0, Time[i], 0 ); ObjectSet( "Buy 3 Little Piggies"+i, OBJPROP_COLOR, Blue ); } bought = true; sold = false; } if((Pair1[i+1] > Pair2[i+1]) && (Pair1[i] < Pair2[i])) { if (ObjectFind("Sell 3 Little Piggies"+i) != 0) { ObjectCreate( "Sell 3 Little Piggies"+i, OBJ_VLINE, 0, Time[i], 0 ); ObjectSet( "Sell 3 Little Piggies"+i, OBJPROP_COLOR, Red ); } bought = false; sold = true; } [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Top
Bottom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…