if(OrdersTotal() < 1 && myOrderType==1) { bool MartingleOne = True; }
Cutting out the other code, you can see that MartingleOne, being a local variable can only be true when the if condition is met.
ie when there are no open orders
The following code will only be executed during the same tick as the order send, so the conditions for the 2nd print are not possible.
while(MartingleOne) { for(cnt=OrdersTotal();cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { if (OrderType()==OP_BUY) { Print(" ---- FIRST TEST LINE ----- "); if (OrderOpenPrice()-Ask >= (firstMartinglePosition * UsePoint)) // NEED HELP Here! { Print(" ----- SECOND TEST LINE ----- "); MartingleOne = false; } } } }
- Guaranteed to wipe your account. Just send the money to me. I'll be happier, you'll still be broke.
for(cnt=OrdersTotal();cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
There are OrdersTotal() open orders [0 .. OrdersTotal()-1] so the first OrderSelect(OrdersTotal()) will ALWAYS fail, but you continue on as if you do have a selected order.- Check What are Function return values ? How do I use them ? - MQL4 forum
Cutting out the other code, you can see that MartingleOne, being a local variable can only be true when the if condition is met.
ie when there are no open orders
The following code will only be executed during the same tick as the order send, so the conditions for the 2nd print are not possible.
- Guaranteed to wipe your account. Just send the money to me. I'll be happier, you'll still be broke.
-
There are OrdersTotal() open orders [0 .. OrdersTotal()-1] so the first OrderSelect(OrdersTotal()) will ALWAYS fail, but you continue on as if you do have a selected order.
- Check What are Function return values ? How do I use them ? - MQL4 forum
2. ok I will add -1
3. thanks for the link, yes was very helpful.
4. Great forum by the way!
Thanks for previous help.
I removed the bool condition and while loop, and added -1 to the orderselect() for loop.
I am still not able to print the second Test line.
I am able to store the OrderOpenPrice() from the original buy position into the BuyOpenPrice varible ( see first Test Line below).
2014.02.07 13:06:01 2013.12.30 16:00 MBFX EA v1.02 EURUSD,H4: ---- FIRST TEST LINE ----- Buy Open Price = 1.3788
2014.02.07 13:06:01 2013.12.30 16:00 MBFX EA v1.02 EURUSD,H4: open #7 buy 0.10 EURUSD at 1.37882 sl: 1.37382 tp: 1.38382 ok
However, I still can't get the line before the Second Test Line to execute!
int BuyTicket = OrderSend(Symbol(),OP_BUY,LotSize,OpenPrice,UseSlippage, BuyStopLoss,BuyTakeProfit,"Buy Order",Magic,0,Lime); } //+------------------------------------------------------------------+ //| First Buy Martingle | //+------------------------------------------------------------------+ if(BuyTicket > 0 && MartingleOneTicket == 0) { for(cnt=OrdersTotal()-1;cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { double BuyOpenPrice = OrderOpenPrice(); if (OrderType()==OP_BUY) { Print(" ---- FIRST TEST LINE ----- Buy Open Price = ", BuyOpenPrice); if (BuyOpenPrice -Ask >= (firstMartinglePosition * UsePoint)) // Issue Here! { Print(" ----- SECOND TEST LINE ----- "); double FirstBuyMartingleOpen = Ask; if(StopLoss > 0) { BuyStopLoss = FirstBuyMartingleOpen - (StopLoss * UsePoint); // Calculate stop loss } if(TakeProfit > 0) { BuyTakeProfit = FirstBuyMartingleOpen + (TakeProfit * UsePoint); // Calculate take profit } MartingleOneTicket = OrderSend(Symbol(),OP_BUY,LotSize*FirstMultiplier,FirstBuyMartingleOpen,UseSlippage, BuyStopLoss,BuyTakeProfit,"Buy Order",Magic,0,Blue); } } } } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Martingle Strategy.
EA places a buy Order, then when price falls below the spicified amount of pips below first order it places another buy order.
I'm having problems printing the second test line, which is where the second buy order would execute from.
e.g. Print(" ----- SECOND TEST LINE ----- ");
I can print the first test line, so I'm guessing it is the condition before the second test line.
Pulling my hair out … any help appriciated .