TraderFW: but the script doesn't work.
|
|
TraderFW: but the script doesn't work. |
|
Thanks for reply. The problem is, that if i drag the script from the navigator window in the chart, no pending buy order will placed in the chart.
The journal tab displays no proceedings.
The MetaEditor compiler gives 3 warnings out:
variable 'cmd' not used
variable 'total' not used
variable 'error' not used
To check the OrderSend function i have placed the following code at the end of the script:
int TicketNumber; TicketNumber = OrderSend( . . . . . . . . ); if( TicketNumber > 0 ) { Print("Order placed # ", TicketNumber); } else { Print("Order Send failed, error # ", GetLastError() ); }
than i restarted the Meta Trader and drag the script from the navigator window in the chart again, but after that, in the journal tab appears no messages or errors.
Which steps are necessary to run the script?
I'm newbie to program and very grateful for your help guys! Thanks
Look in the Experts tab, not the journal
You need to click on "Auto Trading" in the toolbar if it has a red circle to enable auto trading
GumRai:
Look in the Experts tab, not the journal
You need to click on "Auto Trading" in the toolbar if it has a red circle to enable auto trading
Thanks a million! I did not know, that "Auto Trading" is to enable! Now the script works very well.
I have modified the script, because i do not want to enter stop loss and take profit values,
so i have removed the corresponding strings in the script (orange tagged),
but now the MetaEditor compiler issue the warning "implicit conversion from 'string' to 'number'.
This is the original script:
#property show_inputs //#property show_confirm extern double Lots = 0.1; extern int Slippage = 3; extern int Stop_Loss = 20; extern int Take_Profit = 20; //+------------------------------------------------------------------+ //| script "Open a new Buy Order" | //+------------------------------------------------------------------+ int start() { double Price = WindowPriceOnDropped(); bool result; int cmd,total,error,slippage; //---- int NrOfDigits = MarketInfo(Symbol(),MODE_DIGITS); // Nr. of decimals used by Symbol int PipAdjust; // Pips multiplier for value adjustment if(NrOfDigits == 5 || NrOfDigits == 3) // If decimals = 5 or 3 PipAdjust = 10; // Multiply pips by 10 else if(NrOfDigits == 4 || NrOfDigits == 2) // If digits = 4 or 3 (normal) PipAdjust = 1; //---- slippage = Slippage * PipAdjust; double stop_loss = Price - Stop_Loss * Point * PipAdjust; double take_profit = Price + Take_Profit * Point * PipAdjust; if(Ask > Price) { result = OrderSend(Symbol(),OP_BUYLIMIT,Lots,Price,slippage,stop_loss,take_profit,"",0,0,CLR_NONE); } if(Ask < Price) { result = OrderSend(Symbol(),OP_BUYSTOP,Lots,Price,slippage,stop_loss,take_profit,"",0,0,CLR_NONE); } //---- return(0); } //+------------------------------------------------------------------+
And here is my modified version:
#property show_inputs //#property show_confirm extern double Lots = 0.1; extern int Slippage = 3; //+------------------------------------------------------------------+ //| script "Open a new Buy Order" | //+------------------------------------------------------------------+ int start() { double Price = WindowPriceOnDropped(); bool result; int cmd,total,error,slippage; //---- int NrOfDigits = MarketInfo(Symbol(),MODE_DIGITS); // Nr. of decimals used by Symbol int PipAdjust; // Pips multiplier for value adjustment if(NrOfDigits == 5 || NrOfDigits == 3) // If decimals = 5 or 3 PipAdjust = 10; // Multiply pips by 10 else if(NrOfDigits == 4 || NrOfDigits == 2) // If digits = 4 or 3 (normal) PipAdjust = 1; //---- slippage = Slippage * PipAdjust; if(Ask > Price) { result = OrderSend(Symbol(),OP_BUYLIMIT,Lots,Price,slippage,"",0,0,CLR_NONE); } if(Ask < Price) { result = OrderSend(Symbol(),OP_BUYSTOP,Lots,Price,slippage,"",0,0,CLR_NONE); } //---- return(0); } //+------------------------------------------------------------------+
What does the warning "implicit conversion from 'string' to 'number' mean? Influence? How can it be elminated?
Many thanks for informing.
result = OrderSend(Symbol(),OP_BUYLIMIT,Lots,Price,slippage,0,0,"",0,0,CLR_NONE);If you don't want SL or TP, you still have to enter a value in the parameters. In this case 0
What does the warning "implicit conversion from 'string' to 'number' mean? Influence? How can it be elminated?
Many thanks for informing.
Great job, GumRai!
One last question.
To hedge the buy position: assuming that Meta Trader execute a pending buy order (entry point reached), is there a script which automatically can put a pending sell order (e.g. 10 pips under the buy price) at the buy moment?
Great job, GumRai!
One last question.
To hedge the buy position: assuming that Meta Trader execute a pending buy order (entry point reached), is there a script which automatically can put a pending sell order (e.g. 10 pips under the buy price) at the buy moment?
Not a thing that is ideally dealt with by a script, it would be better to write an EA.
In my opinion, it is a stupid idea to open a so called "Hedge" position with the same instrument. You may as well just close the original position.
99.99% of people just don't understand hedging.
Look in the Experts tab, not the journal
You need to click on "Auto Trading" in the toolbar if it has a red circle to enable auto trading
Yes, it worked for me, with "Auto Trading" enabled.
Often "Auto Trading" is disabled after an MT4 version update.
I have not been able to find a way to stop this behaviour, so each Monday morning I recheck "Auto Trading".
Not a thing that is ideally dealt with by a script, it would be better to write an EA.
In my opinion, it is a stupid idea to open a so called "Hedge" position with the same instrument. You may as well just close the original position.
99.99% of people just don't understand hedging.
Hi GumRai,
thanks for reply!
If i close the position with SL, it makes loss e.g. 10 pips.
Hedging this position would compensate the loss till the price is coming back.
Hedging a position by another instrument can generate additional losses, if the price also runs in the loss direction.
Therefore, why is hedging a position with the same instrument in your opinion a stupid idea?
Best regards

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi! There is a Scripts attached. The Script should set buy limit or buy stop orders in the chart with the mouse (drag and drop), but the script doesn't work.
I use Meta Trader 4.00 built 880.
Can anybody tell me, how can i patch the script?