Jump to content

(REQ) Adding Max Spread to Trade Script


Recommended Posts

Could someone please add maximum spread option to the Trade Script below.

 

So that when I try to use the script to place a trade, it would not place the trade if the spread is wider than specified and instead it display a message "Spread is wider than specified".

 

//+------------------------------------------------------------------+

//| trade.mq4 |

//| Copyright © 2004, MetaQuotes Software Corp. |

//| http://www.metaquotes.net/ |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2004, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net/"

 

#include <stdlib.mqh>

#include <WinUser32.mqh>

//+------------------------------------------------------------------+

//| script "trading for all money" |

//+------------------------------------------------------------------+

int start()

{

//----

if(MessageBox("Do you really want to BUY 1.00 "+Symbol()+" at ASK price? ",

"Script",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);

//----

int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,"expert comment",255,0,CLR_NONE);

if(ticket<1)

{

int error=GetLastError();

Print("Error = ",ErrorDescription(error));

return;

}

//----

OrderPrint();

return(0);

}

//+------------------------------------------------------------------+

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...